Skip to content

Commit

Permalink
Merge pull request #7 from sudiptpa/feature/tokenise-a-bank-account-card
Browse files Browse the repository at this point in the history
Added support for creating token (bank account, credit card).
  • Loading branch information
rotassator committed Jul 24, 2018
2 parents a6a4d5e + 38a4a0b commit 50123be
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 65 deletions.
74 changes: 70 additions & 4 deletions README.md
Expand Up @@ -7,10 +7,10 @@ processing library for PHP 5.3+. This package implements PayWay REST API support

This module aims to implement a usable subset of the [PayWay REST API](https://www.payway.com.au/rest-docs/index.html) (a product of Westpac Bank). The API is extensive, so the initial aim is to implement the following features:

* create and maintain customers
* generate single-use tokens
* take payments using tokenised credit card details (aiding PCI compliance)
* schedule regular payments
* Create and maintain customers
* Create single-use tokens (Credit Card, Bank Account)
* Take payments using tokenised credit card details (aiding PCI compliance)
* Schedule regular payments

These initial features have now been implemented.

Expand All @@ -24,3 +24,69 @@ Install the module using composer.
composer require rotassator/omnipay-payway-restapi
```

## Usage

### Take Payment

To take a one-time credit card payment.

```php
<?php

include 'vendor/autoload.php';

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

$gateway = Omnipay::create('PaywayRest_DirectDebit');

$gateway->setApiKeyPublic('REPLACE');
$gateway->setApiKeySecret('REPLACE');
$gateway->setMerchantId('REPLACE');
$gateway->setTestMode(true);

try {
$response = $gateway->createSingleUseCardToken([
'card' => new CreditCard([
'firstName' => 'First Name',
'lastName' => 'Last Name',
'number' => '4564710000000004',
'expiryMonth' => '02',
'expiryYear' => '2019',
'cvv' => '847',
]),
])->send();

$singleUseTokenId = $response->getData('singleUseTokenId');

if (empty($singleUseTokenId)) {
// handle error
}

$request = $gateway->purchase([
'singleUseTokenId' => $singleUseTokenId,
'customerNumber' => 'AB1245',
'principalAmount' => '10.00',
'currency' => 'AUD',
'orderNumber' => 12,
]);

$response = $request->send();

if ($response->isSuccessful()) {
// update order
}
} catch (Exception $e) {
// handle error
}

// Example for creating single-use token with Bank Account
$response = $gateway->createSingleUseBankToken([
'bankAccountBsb' => '999999',
'bankAccountNumber' => '999999999',
'bankAccountName' => 'Your Name',
])->send();

$singleUseTokenId = $response->getData('singleUseTokenId');
```

0 comments on commit 50123be

Please sign in to comment.