Skip to content

Commit

Permalink
beli pulsa
Browse files Browse the repository at this point in the history
  • Loading branch information
lintangtimur committed May 2, 2019
1 parent 35d07cc commit 4d77e94
Show file tree
Hide file tree
Showing 8 changed files with 246 additions and 10 deletions.
114 changes: 114 additions & 0 deletions src/Ovoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class OVOID
*/
const BASE_ENDPOINT = 'https://api.ovo.id/';

const AWS = 'https://apigw01.aws.ovo.id/';

/**
* Authorization Token
*
Expand Down Expand Up @@ -244,4 +246,116 @@ public function getWalletTransaction($page, $limit = 10)
$this->_aditionalHeader()
)->getResponse();
}

/**
* Billpay
*
* @return \Stelin\Response\BillpayResponse
*/
public function getBillers()
{
$ch = new Curl;

return $ch->get(OVOID::AWS . 'gpdm/ovo/ID/v2/billpay/get-billers?categoryID=5C6', null, $this->_aditionalHeader())->getResponse();
}

/**
* get denomination
*
* @param int $product_id product_id can be found from getBillers() endpoint
* @return \Stelin\Response\DenominationsReponse
*/
public function getDenominationByProductId($product_id)
{
$ch = new Curl;

return $ch->get(OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/get-denominations/' . $product_id, null, $this->_aditionalHeader())->getResponse();
}

/**
* bayar
*
* @param string $billerId get this from getBillers()
* @param string $customerId phone number
* @param string $denomId get this from getDenominationByProductId()
* @param string $productId get this from getBillers()
* @return \Stelin\Response\InquiryResponse
*/
public function inquiry($billerId, $customerId, $denomId, $productId)
{
$ch = new Curl;
$data = [
'biller_id' => (string)$billerId,
'customer_id' => $customerId,
'denomination_id' => $denomId,
'payment_method' => [
'001'
],
'phone_number'=> $customerId,
'product_id' => (string)$productId,
'period' => 0
];

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

/**
* setelah menjalankan fungsi inquiry() lakukan fungsi customerUnlock
*
* @param string $securityCode
* @return void
*/
public function customerUnlock($securityCode)

This comment has been minimized.

Copy link
@derodevil

derodevil Jul 30, 2019

Where does $securityCode come from?

This comment has been minimized.

Copy link
@lintangtimur

lintangtimur Jul 30, 2019

Author Owner

6digits security code, when you create your OVO account, you must set your own security code

{
$ch = new Curl;
$data = [
'appVersion' => '2.8.0',
'securityCode'=> $securityCode
];

return $ch->post(OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/unlock', $data, $this->_aditionalHeader())->getResponse();
}

/**
* pay
*
* @param string $billerId
* @param string $customerId
* @param string $oder_id
* @param string $productId
* @return \Stelin\Response\PayResponse
*/
public function pay($billerId, $customerId, $order_id, $productId)
{
$ch = new Curl;
$data = [
'biller_id' => $billerId,
'customer_id' => $customerId,
'order_id' => $order_id,
'payment_method'=> [
'001'
],
'phone_number'=> $customerId,
'product_id' => $productId
];

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

/**
* get PayCheckStatusResponse
*
* @param string $oderId orderId reference
* @return \Stelin\Response\PayCheckStatusResponse
*/
public function payCheckStatus($orderId)
{
$ch = new Curl;

$data = [
'order_reference' => $orderId
];

return $ch->post(OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/checkstatus', $data, $this->_aditionalHeader())->getResponse();
}
}
27 changes: 17 additions & 10 deletions src/ParseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@ class ParseResponse
* @var array
*/
public $storeClass = [
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/login2FA' => 'Stelin\Response\Login2FAResponse',
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/login2FA/verify' => 'Stelin\Response\Login2FAVerifyResponse',
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/loginSecurityCode/verify' => 'Stelin\Response\LoginSecurityCodeResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/front/' => 'Stelin\Response\FrontResponse',
OVOID::BASE_ENDPOINT . 'v1.0/budget/detail' => 'Stelin\Response\BudgetResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/customers/transfer' => 'Stelin\Response\CustomerTransferResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/genTrxId' => 'Stelin\Response\GenTrxIdResponse',
OVOID::BASE_ENDPOINT . 'v1.0/notification/status/count/UNREAD' => 'Stelin\Response\NotificationUnreadResponse',
OVOID::BASE_ENDPOINT . 'v1.0/notification/status/all' => 'Stelin\Response\NotificationAllResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/logout' => 'Stelin\Response\LogoutResponse'
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/login2FA' => 'Stelin\Response\Login2FAResponse',
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/login2FA/verify' => 'Stelin\Response\Login2FAVerifyResponse',
OVOID::BASE_ENDPOINT . 'v2.0/api/auth/customer/loginSecurityCode/verify' => 'Stelin\Response\LoginSecurityCodeResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/front/' => 'Stelin\Response\FrontResponse',
OVOID::BASE_ENDPOINT . 'v1.0/budget/detail' => 'Stelin\Response\BudgetResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/customers/transfer' => 'Stelin\Response\CustomerTransferResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/genTrxId' => 'Stelin\Response\GenTrxIdResponse',
OVOID::BASE_ENDPOINT . 'v1.0/notification/status/count/UNREAD' => 'Stelin\Response\NotificationUnreadResponse',
OVOID::BASE_ENDPOINT . 'v1.0/notification/status/all' => 'Stelin\Response\NotificationAllResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/logout' => 'Stelin\Response\LogoutResponse',
OVOID::AWS . 'gpdm/ovo/ID/v2/billpay/get-billers?categoryID=5C6' => 'Stelin\Response\BillpayResponse',
OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/inquiry' => 'Stelin\Response\InquiryResponse',
OVOID::BASE_ENDPOINT . 'v1.0/api/auth/customer/unlock' => 'Stelin\Response\CustomerUnlockResponse',
OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/pay' => 'Stelin\Response\PayResponse',
OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/checkstatus' => 'Stelin\Response\PayCheckStatusResponse'
];

private $response;
Expand All @@ -43,6 +48,8 @@ public function __construct($chResult, $url)

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

namespace Stelin\Response;

class BillpayResponse
{
/**
*
*
* @var array
*/
private $biller_list;

public function __construct($data)
{
$this->biller_list = $data;
}

/**
* list of bill
*
* @return array
*/
public function getBillerList()
{
return $this->biller_list;
}
}
10 changes: 10 additions & 0 deletions src/Response/CustomerUnlockResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Stelin\Response;

class CustomerUnlockResponse
{
public function __construct($data)
{

}
}
17 changes: 17 additions & 0 deletions src/Response/DenominationsReponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace Stelin\Response;

class DenominationsReponse
{
private $denominations;

public function __construct($data)
{
$this->denominations = $data;
}

public function getDenominations()
{
return $this->denominations;
}
}
23 changes: 23 additions & 0 deletions src/Response/InquiryResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Stelin\Response;

class InquiryResponse
{

private $response;

public function __construct($data)
{
$this->response= $data;
}

/**
* Undocumented function
*
* @return array
*/
public function getResponse()
{
return $this->response;
}
}
16 changes: 16 additions & 0 deletions src/Response/PayCheckStatusResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
namespace Stelin\Response;

class PayCheckStatusResponse
{
private $PayCheckStatusResponse;
public function __construct($data)
{
$this->PayCheckStatusResponse = $data;
}

public function getPayCheckStatusResponse()
{
return $this->PayCheckStatusResponse;
}
}
21 changes: 21 additions & 0 deletions src/Response/PayResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Stelin\Response;

class PayResponse
{
private $response;
public function __construct($data)
{
$this->response = $data;
}

/**
* response
*
* @return void
*/
public function getPayResponse()
{
return $this->response;
}
}

0 comments on commit 4d77e94

Please sign in to comment.