Payabbhi PHP library
, (*1)
Make sure you have signed up for your Payabbhi Account and downloaded the API keys from the Portal., (*2)
Requirements
PHP 5.3.3 and later., (*3)
Composer
The library can be installed via Composer. Run the following command:, (*4)
$ composer require payabbhi/payabbhi-php
Start using the library as per Composer autoloading:
simply include vendor/autoload.php
, available as part of library installation via Composer., (*5)
require_once('vendor/autoload.php');
Manual Installation
In case Composer is not used, download the latest release from Releases.
For using the manually downloaded library, simply include init.php
in your code., (*6)
require_once('/path/to/payabbhi-php/init.php');
For manual installation, make sure that the dependencies are resolved., (*7)
Documentation
Please refer to:
- PHP Lib Docs
- Integration Guide, (*8)
Dependencies
The library requires the following extensions:, (*9)
In case of manual installation, make sure that the dependencies are resolved., (*10)
Getting Started
Authentication
// Set your credentials
$client = new \Payabbhi\Client('access_id', 'secret_key');
// Optionally set your app info.
// app_version and app_url are optional
$client->setAppInfo('app_name','app_version','app_url');
Orders
// Create order
$order = $client->order->create(array('merchant_order_id' => $merchantOrderID,
'amount' => $amount,
'currency' => $currency));
// Retrieve a particular order object
$order = $client->order->retrieve($orderId);
// Retrieve a set of order objects based on given filter params
$orders = $client->order->all(array('count' => 2));
// Retrieve a set of payments for a given order
$payments = $client->order->retrieve($orderId)->payments();
Payments
// Retrieve all payments
$payments = $client->payment->all();
// Retrieve a particular payment
$payment = $client->payment->retrieve($id);
// Capture a payment
$payment->capture();
// Fully Refund a payment
$refund = $payment->refund();
// Retrieve a set of refund objects for a given payment with optional filter params
$refunds = $payment->refunds();
Refunds
// Create a refund
$fullRefund = $client->refund->create($paymentID);
// Create a partial refund
$partialRefund = $client->refund->create($paymentID, array('amount'=>$refundAmount));
// Retrieve a set of orders with the given filter params
$refunds = $client->refund->all(array('count' => 2));
// Retrieve a particular refund object
$refund = $client->refund->retrieve($refundId);
Verifying payment signature
$attributes = array(
'payment_id' => $payment_id,
'order_id' => $order_id,
'payment_signature' => $payment_signature
);
$client->utility->verifyPaymentSignature($attributes);
Verifying webhook signature
$client->utility->verifyWebhookSignature($payload,$actualSignature,$secret);
// replayInterval is optional
$client->utility->verifyWebhookSignature($payload,$actualSignature,$secret,$replayInterval);
Customers
Refer to PHP Lib Docs, (*11)
Invoices
Refer to PHP Lib Docs:
- Invoices
- Invoice Items, (*12)
Subscriptions
Refer to PHP Lib Docs:
- Products
- Plans
- Subscriptions, (*13)
Transfers
Refer to PHP Lib Docs, (*14)
Events
Refer to PHP Lib Docs, (*15)
Development
Install dependencies:, (*16)
``` bash
$ composer install, (*17)
## Tests
Install dependencies as mentioned above (which will resolve [PHPUnit](http://packagist.org/packages/phpunit/phpunit)), set ACCESS_ID and SECRET_KEY as environment variable then you can run the test suite:
```bash
$ export ACCESS_ID="<access-id>"
$ export SECRET_KEY="<secret-key>"
$ ./vendor/bin/phpunit
Or to run an individual test file:, (*18)
$ export ACCESS_ID="<access-id>"
$ export SECRET_KEY="<secret-key>"
$ ./vendor/bin/phpunit tests/PaymentTest.php