94 lines
3.1 KiB
Markdown
94 lines
3.1 KiB
Markdown
# Omnipay: Inforbank
|
|
|
|
**Inforbank gateway for the Omnipay PHP payment processing library**
|
|
|
|
[Omnipay](https://github.com/omnipay/omnipay) is a framework agnostic, multi-gateway payment
|
|
processing library for PHP 5.3+. This package implements Inforbank support for Omnipay.
|
|
|
|
## Installation
|
|
|
|
Omnipay is installed via [Composer](http://getcomposer.org/). To install, simply add it
|
|
to your `composer.json` file:
|
|
|
|
```json
|
|
{
|
|
"repositories": [
|
|
{
|
|
"url": "https://git.verictas.com/InformaticaD4p/omnipay-plugin.git",
|
|
"type": "git"
|
|
}
|
|
],
|
|
"require": {
|
|
"inforbank/omnipay-inforbank": "dev-master"
|
|
}
|
|
}
|
|
```
|
|
|
|
And run composer to update your dependencies:
|
|
|
|
$ curl -s http://getcomposer.org/installer | php
|
|
$ php composer.phar update
|
|
|
|
## Basic Usage
|
|
|
|
The following gateways are provided by this package:
|
|
|
|
* Inforbank
|
|
|
|
For general usage instructions, please see the main [Omnipay](https://github.com/omnipay/omnipay)
|
|
repository.
|
|
|
|
## Example
|
|
|
|
```php
|
|
$gateway = \Omnipay\Omnipay::create('Inforbank');
|
|
$gateway->initialize(array(
|
|
'clientId' => 'PUT THE CLIENT_ID HERE',
|
|
'clientSecret' => 'PUT THE CLIENT_SECRET HERE'
|
|
));
|
|
|
|
// Start the purchase
|
|
if (!isset($_GET['status'])) {
|
|
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
|
|
$response = $gateway->purchase(array(
|
|
'amount' => "1.50",
|
|
'description' => "Testorder #1234",
|
|
'transactionId' => 1234,
|
|
'returnUrl' => $url
|
|
))->send();
|
|
|
|
if ($response->isRedirect()) {
|
|
// redirect to offsite payment gateway
|
|
$response->redirect();
|
|
} elseif ($response->isPending()) {
|
|
// This will never occur, because the gateway always returns a redirect to the bank pages.
|
|
return "Pending, Reference: ". $response->getTransactionReference();
|
|
} else {
|
|
// payment failed: display message to customer
|
|
return "Error " .$response->getCode() . ': ' . $response->getMessage();
|
|
}
|
|
} else {
|
|
/**
|
|
* Because the 'status' GET parameter is present, this is a return URL request and the purchase should be completed.
|
|
*/
|
|
// Check the status
|
|
$response = $gateway->completePurchase()->send();
|
|
if ($response->isSuccessful()) {
|
|
$reference = $response->getTransactionReference(); // TODO; Check the reference/id with your database
|
|
return "Transaction '" . $response->getTransactionId() . "' succeeded!";
|
|
} else {
|
|
return "Error " .$response->getCode() . ': ' . $response->getMessage();
|
|
}
|
|
}
|
|
```
|
|
|
|
## Support
|
|
|
|
If you are having general issues with Omnipay, we suggest posting on
|
|
[Stack Overflow](http://stackoverflow.com/). Be sure to add the
|
|
[omnipay tag](http://stackoverflow.com/questions/tagged/omnipay) so it can be easily found.
|
|
|
|
If you want to keep up to date with release anouncements, discuss ideas for the project,
|
|
or ask more detailed questions, there is also a [mailing list](https://groups.google.com/forum/#!forum/omnipay) which
|
|
you can subscribe to.
|