Skip to content

Commit

Permalink
README : add basic usage
Browse files Browse the repository at this point in the history
add VTWebGateway::purchase()
  • Loading branch information
andylibrian committed Feb 18, 2015
1 parent 743198b commit f700b47
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<?php

require_once __DIR__ . '/vendor/autoload.php';

use Omnipay\Omnipay;
use Omnipay\Common\CreditCard;

$gateway = Omnipay::create('Veritrans_VTWeb');
$gateway->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

Expand Down
5 changes: 5 additions & 0 deletions src/VTWebGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
8 changes: 8 additions & 0 deletions tests/VTWebGatewayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@ public function testAuthorize()
$this->gateway->authorize()
);
}

public function testPurchase()
{
$this->assertInstanceOf(
'Omnipay\Veritrans\Message\VTWeb\TransactionChargeRequest',
$this->gateway->purchase()
);
}
}

0 comments on commit f700b47

Please sign in to comment.