From f700b47d78fa3ca53c77d661ec0dc35edd16ce4f Mon Sep 17 00:00:00 2001 From: Andy Librian Date: Wed, 18 Feb 2015 20:00:13 +0700 Subject: [PATCH] README : add basic usage add VTWebGateway::purchase() --- README.md | 43 +++++++++++++++++++++++++++++++++++++- src/VTWebGateway.php | 5 +++++ tests/VTWebGatewayTest.php | 8 +++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 56e6794..3be2386 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,51 @@ Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply ## Basic Usage -TBD +The following gateways are provided by this package: + +- VT-Web + + +```php +setServerKey('server-key-replace-with-yours'); +$gateway->setEnvironment('sandbox'); // [production|sandbox] default to production + +$data = array( + 'transactionId' => '123456', + 'amount' => '145000.00', + 'card' => new CreditCard(), + 'vtwebConfiguration' => array( + 'credit_card_3d_secure' => true, + ), + 'currency' => 'IDR', +); + +$response = $gateway->purchase($data)->send(); + +if ($response->isSuccessful()) { + // payment success, update database + // using VT-Web, you will always get redirected to offsite (veritrans page) + // so here won't be reached. +} elseif ($response->isRedirect()) { + // redirect to offsite payment gateway + $response->redirect(); +} else { + echo $response->getMessage(); +} +``` + For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository. +And for more information about Veritrans features, please see [Veritrans Documentation](http://docs.veritrans.co.id/welcome/welcome.html) ## Support diff --git a/src/VTWebGateway.php b/src/VTWebGateway.php index 400dfa7..b38108b 100644 --- a/src/VTWebGateway.php +++ b/src/VTWebGateway.php @@ -43,4 +43,9 @@ public function authorize(array $parameters = array()) { return $this->createRequest('\Omnipay\Veritrans\Message\VTWeb\TransactionChargeRequest', $parameters); } + + public function purchase(array $parameters = array()) + { + return $this->createRequest('\Omnipay\Veritrans\Message\VTWeb\TransactionChargeRequest', $parameters); + } } diff --git a/tests/VTWebGatewayTest.php b/tests/VTWebGatewayTest.php index 3d687ee..1e3d3c4 100644 --- a/tests/VTWebGatewayTest.php +++ b/tests/VTWebGatewayTest.php @@ -44,4 +44,12 @@ public function testAuthorize() $this->gateway->authorize() ); } + + public function testPurchase() + { + $this->assertInstanceOf( + 'Omnipay\Veritrans\Message\VTWeb\TransactionChargeRequest', + $this->gateway->purchase() + ); + } }