Skip to content

Commit d6cfe26

Browse files
committed
added basic example
1 parent 129b976 commit d6cfe26

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

README.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,50 @@ The following gateways are provided by this package:
2727

2828
* ZipPay
2929

30-
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository.
30+
For general usage instructions, please see the main [Omnipay](https://github.com/thephpleague/omnipay) repository.\
31+
32+
33+
A quick example looks something like this:
34+
35+
Process your Authorization
36+
```php
37+
$omniZip = Omnipay::create('ZipPay_Rest');
38+
$omniZip->setApiKey($zipApiKey);
39+
$authTx = $omniZip->authorize([
40+
'reference'=> $ref,
41+
'amount' => 10.00,
42+
'currency' => 'AUD',
43+
'returnUrl' => 'https://mysite.com/zip/return',
44+
'card' => $this->OmniPayCardFactory(), //Customers Details, no credit card number
45+
'items' => $this->zipItemList(), // Array of items implementing Omnipay\ZipPay\ItemInterface
46+
]);
47+
$result = $authTx->send();
48+
if($response->isRedirect()) { // Authorize worked
49+
$resData = $result->getData();
50+
$this->saveAuthorizeId($resData['id']);
51+
$response->redirect(); //Sends customer off to ZipPay to complete signup
52+
}
53+
```
54+
55+
Return url (eg /zip/return)
56+
```php
57+
if (!isset($_REQUEST['result']) || $_REQUEST['result'] !== 'approved')
58+
throw new \RuntimeError('Problem with your authorization');
59+
$omniZip = Omnipay::create('ZipPay_Rest');
60+
$omniZip->setApiKey($zipApiKey);
61+
$compTx = $omniZip->completeAuthorize([
62+
'authorityType' => 'checkout_id',
63+
'authorityValue' => $this->getAuthorizeId(),
64+
'amount' => 10.00,
65+
'currency' => 'AUD',
66+
'captureFunds' => true;
67+
]);
68+
$result = $compTx->send();
69+
if($result->isSuccessful())
70+
$this->paid();
71+
else
72+
$this->paymentFailed();
73+
```
3174

3275
## Support
3376

0 commit comments

Comments
 (0)