payabbhi/payabbhi-php

Payabbhi PHP package provides client library for Payabbhi API's

v1.0.6 2019-12-03 12:02 UTC

This package is not auto-updated.

Last update: 2024-10-30 12:05:37 UTC


README

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

Start using the library as per Composer autoloading: simply include vendor/autoload.php, available as part of library installation via Composer.

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.

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

For manual installation, make sure that the dependencies are resolved.

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

Customers

Refer to PHP Lib Docs

Invoices

Refer to PHP Lib Docs:

Subscriptions

Refer to PHP Lib Docs:

Transfers

Refer to PHP Lib Docs

Events

Refer to PHP Lib Docs

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