Make sure you have signed up for your Payabbhi Account and downloaded the API keys from the Portal.
PHP 5.3.3 and later.
The library can be installed via Composer. Run the following command:
$ composer require payabbhi/payabbhi-php
In order to use the library, use Composer's autoload feature:
require_once('vendor/autoload.php');
For manual installation, include init.php
in your code.
require_once('/path/to/payabbhi-php/init.php');
Please refer to:
The library requires the following extensions:
In case of manual installation, make sure that the dependencies are resolved.
// 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');
// 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();
// 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();
// 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);
$attributes = array(
'payment_id' => $payment_id,
'order_id' => $order_id,
'payment_signature' => $payment_signature
);
$client->utility->verifyPaymentSignature($attributes);
$client->utility->verifyWebhookSignature($payload,$actualSignature,$secret);
// replayInterval is optional
$client->utility->verifyWebhookSignature($payload,$actualSignature,$secret,$replayInterval);
Install dependencies:
$ composer install
Install dependencies as mentioned above (which will resolve PHPUnit), set ACCESS_ID and SECRET_KEY as environment variable then you can run the test suite:
$ export ACCESS_ID="<access-id>"
$ export SECRET_KEY="<secret-key>"
$ ./vendor/bin/phpunit
Or to run an individual test file:
$ export ACCESS_ID="<access-id>"
$ export SECRET_KEY="<secret-key>"
$ ./vendor/bin/phpunit tests/PaymentTest.php