Skip to content

Latest commit

 

History

History
167 lines (109 loc) · 4.17 KB

README.md

File metadata and controls

167 lines (109 loc) · 4.17 KB

Payabbhi PHP library

license Packagist Packagist

Make sure you have signed up for your Payabbhi Account and downloaded the API keys from the Portal.

Requirements

PHP 5.3.3 and later.

Composer

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');

Manual Installation

For manual installation, include init.php in your code.

require_once('/path/to/payabbhi-php/init.php');

Documentation

Please refer to:

Dependencies

The library requires the following extensions:

In case of manual installation, make sure that the dependencies are resolved.

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);

Development

Install dependencies:

$ composer install

Tests

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