Skip to content

Commit

Permalink
Transfer antar bank
Browse files Browse the repository at this point in the history
  • Loading branch information
lintangtimur committed Jul 16, 2019
1 parent 6b1fa94 commit a997eaa
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 10 deletions.
15 changes: 15 additions & 0 deletions src/Meta/ActionMark.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Stelin\Meta;

/**
* Action Mark
*
* Transfer OVO
* Transfer Antar BANK
*/
class ActionMark
{
const TRANSFER_OVO = 'trf_ovo';
const TRANSFER_BANK = 'trf_other_bank';
}
95 changes: 87 additions & 8 deletions src/Ovoid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Stelin\HTTP\Curl;
use Stelin\Meta\Meta;
use Stelin\Meta\ActionMark;

/**
* OVOID
Expand Down Expand Up @@ -140,11 +141,16 @@ public function balanceModel()
/**
* kirim cash sesama OVO
*
* @param string $to_mobilePhone
* @param int $amount
* @param string $message
* Dapat dilakukan sebanyak 2kali, ketika ingin transfer lebih dari 2kali tidak bisa dilakukan
* karena membutuhkan Signature Header berupa SHA1 untuk memvalidasi TrxId
* UnlockAndValidateTrxId
* WARNING:
*
* @param string $to_mobilePhone
* @param int $amount
* @param string $message
* @throws \Stelin\Exception\AmountException
* @return \Stelin\Reponse\CustomerTransferResponse
* @return \Stelin\Response\CustomerTransferResponse
*/
public function transferOvo($to_mobilePhone, $amount, $message = null)
{
Expand All @@ -157,24 +163,97 @@ public function transferOvo($to_mobilePhone, $amount, $message = null)
'to' => $to_mobilePhone,
'amount' => $amount,
'message' => $message ? null : '',
'trxId' => $this->generateTrxId($to_mobilePhone, $amount)->getTrxId()
'trxId' => $this->generateTrxId($amount, ActionMark::TRANSFER_OVO)->getTrxId()
];

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

/**
* transer antar bank
*
* @param string $accountName nama akun
* @param string $accountNo No akun OVO Cash
* @param string $accountNoDestination No rekening yang dituju
* @param int $amount jumlah yang akan ditransfer
* @param string $bankCode kode bank yang dituju
* @param string $bankName nama bank
* @param string $message
* @param string $notes
* @return \Stelin\Response\TransferDirectResponse
*/
public function transferBank($accountName, $accountNo, $accountNoDestination, $amount, $bankCode, $bankName, $message, $notes)
{
if ($amount < 10000) {
throw new \Stelin\Exception\AmountException('Minimal 10.000');
}

$ch = new Curl;

$data = [
'accountName' => $accountName,
'accountNo' => $accountNo,
'accountNoDestination' => $accountNoDestination,
'amount' => $amount,
'bankCode' => $bankCode,
'bankName' => $bankName,
'message' => $message,
'notes' => $notes,
'transactionId' => $this->generateTrxId($amount, ActionMark::TRANSFER_BANK)->getTrxId()
];

return $ch->post(OVOID::BASE_ENDPOINT . 'transfer/direct', $data, $this->_aditionalHeader())->getResponse();
}

/**
* transfer inquiry
*
* @param string $accountNo no rekening yang dituju
* @param int $amount jumlah yang akan ditransfer
* @param string $bankCode kode bank yang dituju
* @param string $bankName nama bank yang dituju
* @param string $message
* @return \Stelin\Response\TransferInquiryResponse
*/
public function transferInquiry($accountNo, $amount, $bankCode, $bankName, $message)
{
$ch = new Curl;

$data = [
'accountNo'=> $accountNo,
'amount' => $amount,
'bankCode' => $bankCode,
'bankName' => $bankName,
'message' => $message
];

return $ch->post(OVOID::BASE_ENDPOINT . 'transfer/inquiry', $data, $this->_aditionalHeader())->getResponse();
}

/**
* Get Bank Reference
*
* @return \Stelin\Response\Ref_BankResponse
*/
public function getRefBank()
{
$ch = new Curl;

return $ch->get(OVOID::BASE_ENDPOINT . 'v1.0/reference/master/ref_bank', null, $this->_aditionalHeader())->getResponse();
}

/**
* generate trxid
*
* @param string $mobilePhone
* @param int $amount
* @param \Stelin\Meta\ActionMark $actionMark
* @return \Stelin\Response\GenTrxIdResponse
*/
private function generateTrxId($mobilePhone, $amount)
private function generateTrxId($amount, $actionMark)
{
$ch = new Curl;
$data = [
'actionMark' => 'trf_ovo',
'actionMark' => $actionMark,
'amount' => $amount
];

Expand Down
6 changes: 4 additions & 2 deletions src/ParseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class ParseResponse
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'
OVOID::AWS . 'gpdm/ovo/ID/v1/billpay/checkstatus' => 'Stelin\Response\PayCheckStatusResponse',
OVOID::BASE_ENDPOINT . 'v1.0/reference/master/ref_bank' => 'Stelin\Response\Ref_BankResponse',
OVOID::BASE_ENDPOINT . 'transfer/inquiry' => 'Stelin\Response\TransferInquiryResponse',
OVOID::BASE_ENDPOINT . 'transfer/direct' => 'Stelin\Response\TransferDirectResponse'
];

private $response;
Expand All @@ -38,7 +41,6 @@ class ParseResponse
public function __construct($chResult, $url)
{
$jsonDecodeResult = json_decode($chResult);

//-- Cek apakah ada error dari OVO Response
if (isset($jsonDecodeResult->code)) {
throw new \Stelin\Exception\OvoidException($jsonDecodeResult->message . ' ' . $url);
Expand Down
23 changes: 23 additions & 0 deletions src/Response/BankResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Stelin\Response;

class BankResponse
{
private $resp;

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

/**
* Get Bank Transfer Response
*
* @return mixed
*/
public function getBankResponse()
{
return $this->resp;
}
}
26 changes: 26 additions & 0 deletions src/Response/Ref_BankResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace Stelin\Response;

/**
* LIST BANK
*/
class Ref_BankResponse
{
private $response;

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

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

class TransferDirectResponse
{
private $resp;

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

public function getTransferDirectResponse()
{
return $this->resp;
}
}
18 changes: 18 additions & 0 deletions src/Response/TransferInquiryResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace Stelin\Response;

class TransferInquiryResponse
{
private $response;

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

public function getTransferInquiryResponse()
{
return $this->response;
}
}

0 comments on commit a997eaa

Please sign in to comment.