Skip to content

Commit

Permalink
Update Readme, Tambah method check balance, & detail history
Browse files Browse the repository at this point in the history
  • Loading branch information
lintangtimur committed Oct 5, 2021
1 parent 5ecca57 commit 8b0b398
Show file tree
Hide file tree
Showing 5 changed files with 1,204 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ Telah di test pada OVO versi 3.43.0 | 24 September 2021 | PHP 7.2.2

| Method | Result | OVO Version
|---|---| --- |
| `OTP` | OK | 3.43.0(24 sept 21)
| `OTPValidation` | OK | 3.43.0 (24 sept 21)
| `accountLogin` | OK | 3.43.0 (24 sept 21)
| `OTP` | OK | 3.43.0(5 okt 21)
| `OTPValidation` | OK | 3.43.0 (5 okt 21)
| `accountLogin` | OK | 3.43.0 (5 okt 21)
| `getBudget` | OK | 3.43.0 (24 sept 21)
| `balanceModel` | OK | 3.43.0 (24 sept 21)
| `logout` | not tested | 3.43.0 (24 sept 21)
| `unreadHistory` | not tested | 3.43.0 (24 sept 21)
| `unreadHistory` | tested | 3.43.0 (5 okt 21)
| `getWalletTransaction` | OK | 3.43.0 (24 sept 21)
| `detailHistory` | tested | 3.43.0 (5 okt 21)
| `balance` | tested | 3.43.0 (5 okt 21)
| `generateTrxId` | not tested | 3.43.0 (24 sept 21)
| `transferOvo` | not tested | 3.43.0 (24 sept 21)


## PORTS
Jika PHP tidak nyaman bagimu bisa mencoba bahasa pemrograman lain, atau jika ingin menulis dibahasa tersebut silahkan ajukan Issue baru nanti akan saya list disini

Expand Down
26 changes: 26 additions & 0 deletions src/Ovoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,30 @@ public function payCheckStatus($orderId)

return $ch->post(OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/checkstatus', $data, $this->_aditionalHeader())->getResponse();
}

/**
* Detail History
*
* @param string $merchantId get from wallet history
* @param string $merchantInvoice get from wallet history
* @return \Stelin\Response\DetailHistoryResponse
*/
public function detailHistory($merchantId, $merchantInvoice)
{
$ch = new Curl;

return $ch->get(OVOID::BASE_ENDPOINT . 'wallet/transaction/' . $merchantId . '/' . $merchantInvoice, null, $this->_aditionalHeader())->getResponse();
}

/**
* Check balance OVO
*
* @return \Stelin\Response\BalanceResponse
*/
public function balance()
{
$ch = new Curl;

return $ch->get(OVOID::BASE_ENDPOINT . 'wallet/inquiry', null, $this->_aditionalHeader())->getResponse();
}
}
5 changes: 5 additions & 0 deletions src/ParseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ParseResponse
OVOID::OVO_API_AWS . 'v3/user/accounts/otp/validation' => 'Stelin\Response\OTPValidationResponse',
OVOID::OVO_API_AWS . 'v3/user/public_keys' => 'Stelin\Response\PublicKeyResponse',
OVOID::OVO_API_AWS . 'v3/user/accounts/login' => 'Stelin\Response\AccountLoginResponse',
OVOID::BASE_ENDPOINT . 'wallet/inquiry' => 'Stelin\Response\BalanceResponse',

];

Expand All @@ -54,12 +55,16 @@ public function __construct($chResult, $url)

$parts = parse_url($url);

$uriSegments = explode('/', parse_url($url, PHP_URL_PATH));

if ($parts['path'] == '/wallet/v2/transaction') {
$this->response = new \Stelin\Response\WalletTransactionResponse($jsonDecodeResult);
} elseif ($parts['path'] == '/payment/orders/v1/list') {
$this->response = new \Stelin\Response\PaymentOrdersResponse($jsonDecodeResult);
} elseif (strpos($parts['path'], '/gpdm/ovo/ID/v1/billpay/get-denominations/') !== false) {
$this->response = new \Stelin\Response\DenominationsReponse($jsonDecodeResult);
} elseif ($uriSegments[1] == 'wallet' && $uriSegments[2] == 'transaction') {
$this->response = new \Stelin\Response\DetailHistoryResponse($jsonDecodeResult);
} else {
$this->response = new $this->storeClass[$url]($jsonDecodeResult);
}
Expand Down
315 changes: 315 additions & 0 deletions src/Response/BalanceResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,315 @@
<?php
namespace Stelin\Response;

/**
* OVO Cash dalam Rupiah
*/
class BR001
{
/**
* @var int
*/
private $cardBalance;

/**
* @var string
*/
private $cardNo;

/**
* @var string
*/
private $paymentMethod;

/**
* @return int|null
*/
public function getCardBalance(): ?int
{
return $this->cardBalance;
}

/**
* @param int|null $cardBalance
*
* @return BR001
*/
public function setCardBalance(?int $cardBalance): BR001
{
$this->cardBalance = $cardBalance;

return $this;
}

/**
* @return string|null
*/
public function getCardNo(): ?string
{
return $this->cardNo;
}

/**
* @param string|null $cardNo
*
* @return BR001
*/
public function setCardNo(?string $cardNo): BR001
{
$this->cardNo = $cardNo;

return $this;
}

/**
* @return string|null
*/
public function getPaymentMethod(): ?string
{
return $this->paymentMethod;
}

/**
* @param string|null $paymentMethod
*
* @return BR001
*/
public function setPaymentMethod(?string $paymentMethod): BR001
{
$this->paymentMethod = $paymentMethod;

return $this;
}
}

/**
* OVO POINT
*/
class BR600
{
/**
* @var int
*/
private $cardBalance;

/**
* @var string
*/
private $cardNo;

/**
* @var string
*/
private $paymentMethod;

/**
* @return int|null
*/
public function getCardBalance(): ?int
{
return $this->cardBalance;
}

/**
* @param int|null $cardBalance
*
* @return BR600
*/
public function setCardBalance(?int $cardBalance): BR600
{
$this->cardBalance = $cardBalance;

return $this;
}

/**
* @return string|null
*/
public function getCardNo(): ?string
{
return $this->cardNo;
}

/**
* @param string|null $cardNo
*
* @return BR600
*/
public function setCardNo(?string $cardNo): BR600
{
$this->cardNo = $cardNo;

return $this;
}

/**
* @return string|null
*/
public function getPaymentMethod(): ?string
{
return $this->paymentMethod;
}

/**
* @param string|null $paymentMethod
*
* @return BR600
*/
public function setPaymentMethod(?string $paymentMethod): BR600
{
$this->paymentMethod = $paymentMethod;

return $this;
}
}

class BRData
{
/**
* @var BR001
*/
private $BR001;

/**
* @var BR600
*/
private $BR600;

/**
* OVO Cash dalam rupiah
* @return BR001|null
*/
public function get001(): ?BR001
{
return $this->BR001;
}

/**
* @param BR001|null $BR001
*
* @return BRData
*/
public function set001(?BR001 $BR001): BRData
{
$this->BR001 = $BR001;

return $this;
}

/**
* OVO point
* @return BR600|null
*/
public function get600(): ?BR600
{
return $this->BR600;
}

/**
* @param BR600|null $BR600
*
* @return BRData
*/
public function set600(?BR600 $BR600): BRData
{
$this->BR600 = $BR600;

return $this;
}
}

class BalanceResponse
{
/**
* @var int
*/
private $status;

/**
* @var BRData
*/
private $data;

/**
* @var string
*/
private $message;

public function __construct($data)
{
$this->status = $data->status;
$this->message = $data->message;
if ($data->data == null) {
$this->data = null;
} else {
$d = new BRData();
$d->set001((new BR001)->setCardBalance($data->data->{'001'}->card_balance)
->setCardNo($data->data->{'001'}->card_no)
->setPaymentMethod($data->data->{'001'}->payment_method))
->set600((new BR600)->setCardBalance($data->data->{'600'}->card_balance)
->setCardNo($data->data->{'600'}->card_no)
->setPaymentMethod($data->data->{'600'}->payment_method));
$this->data = $d;
}
}

/**
* @return int|null
*/
public function getStatus(): ?int
{
return $this->status;
}

/**
* @param int|null $status
*
* @return BalanceResonse
*/
public function setStatus(?int $status): BalanceResonse
{
$this->status = $status;

return $this;
}

/**
* @return BRData|null
*/
public function getData(): ?BRData
{
return $this->data;
}

/**
* @param BRData|null $data
*
* @return BalanceResonse
*/
public function setData(?BRData $data): BalanceResonse
{
$this->data = $data;

return $this;
}

/**
* @return string|null
*/
public function getMessage(): ?string
{
return $this->message;
}

/**
* @param string|null $message
*
* @return BalanceResonse
*/
public function setMessage(?string $message): BalanceResonse
{
$this->message = $message;

return $this;
}
}
Loading

0 comments on commit 8b0b398

Please sign in to comment.