payomatix / web-sdk
Payomatix Web SDK for PHP
Requires
- php: >=7.0
- vlucas/phpdotenv: ^5.6
README
Payomatix PHP SDK
This Payomatix PHP Library provides easy access to Payomatix APIs for php apps. It abstracts the complexity involved in direct integration and allows you to make quick calls to the APIs.
Table of Contents
- Requirements
- Dependencies
- Installation
- Initialization
- Getting Started
- Status
- Custom Request Timeouts
- Debugging Errors
- Terms and Conditions
- License
- References
Requirements
- Payomatix Merchant account with API Keys
- Minimum PHP versions: >= 7.0.0
Dependencies
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically.
Installation
Installation via Composer.
To install the package via Composer, run the following command.
composer require payomatix/web-sdk
To use the bindings, use Composer's autoload:
require 'vendor/autoload.php';
Initialization
Create a .env file or copy from .env.example
file
Save your SECRET_KEY in the .env
file as PAYOMATIX_SECRET_KEY
cp .env.example .env
Your .env
file should look this.
PAYOMATIX_SECRET_KEY=PAYXXXXXXXXXXXXXXXX.XXXXXXSECKEY
Getting Started
The SDK provides two methods of making collections
Simple usage for non-seamless payments looks like:
<?php require_once 'vendor/autoload.php'; use Payomatix\Payomatix; $payomatix = new Payomatix(); // customize curl timeouts $payomatix->setOptions([ 'timeout' => 60 ]); $response = $payomatix->nonSeamlessPayment([ 'other_data' => [ 'first_name' => 'your-name', 'last_name' => 'your-name', 'address' => 'address', 'state' => 'state', 'city' => 'city', 'zip' => '123456', 'country' => 'IN', 'phone_no' => '1234567890', 'card_no' => '4242424242424242', ], 'email' => 'test@jondoe.com', 'amount' => '30.00', 'currency' => 'USD', 'merchant_ref' => 'ce35d90-fc2e-4a43-a900-1872d9c00890', 'return_url' => 'https://mysite.com/redirect/dce35d90-fc2e-4a43-a900-1872d9c00890', 'notify_url' => 'https://mysite.com/notify/ce35d90-fc2e-4a43-a900-1872d9c00890' ]); if (isset($response['redirect_url']) && !empty($response['redirect_url'])) { header('Location: ' . $response['redirect_url']); } else { print_r($response); }
Same way, you can initiate seamless payments like:
<?php require_once 'vendor/autoload.php'; use Payomatix\Payomatix; $payomatix = new Payomatix(); $response = $payomatix->seamlessPayment([ 'first_name' => 'your-name', 'last_name' => 'your-name', 'address' => 'address', 'country' => 'IN', 'state' => 'state', 'city' => 'city', 'zip' => '123456', 'phone_no' => '1234567890', 'email' => 'test@jondoe.com', 'amount' => '30.00', 'currency' => 'INR', 'return_url' => 'https://mysite.com/redirect/dce35d90-fc2e-4a43-a900-1872d9c00890', 'notify_url' => 'https://mysite.com/notify/ce35d90-fc2e-4a43-a900-1872d9c00890', 'merchant_ref' => 'ce35d90-fc2e-4a43-a900-1872d9c00890', 'type_id' => '1', 'card_no' => '4242424242424242', 'ccexpiry_month' => '01', 'ccexpiry_year' => '2029', 'cvv_number' => '123' ]); if (isset($response['redirect_url']) && !empty($response['redirect_url'])) { header('Location: ' . $response['redirect_url']); } else { print_r($response); }
Status
You can use the SDK to retrieve the status of transaction using merchant_ref
or order_id
as below:
<?php require_once 'vendor/autoload.php'; use Payomatix\Payomatix; $payomatix = new Payomatix(); $response = $payomatix->status([ 'merchant_ref' => 'ce35d90-fc2e-4a43-a900-1872d9c00890' ]); if (isset($response['redirect_url']) && !empty($response['redirect_url'])) { header('Location: ' . $response['redirect_url']); } else { print_r($response); }
Custom Request Timeouts
By default PHP cURL request timeouts are set. To modify request timeouts (connect or total, in seconds) you'll need to tell the API client like this.
<?php require_once 'vendor/autoload.php'; use Payomatix\Payomatix; $payomatix = new Payomatix(); $payomatix->setOptions([ 'timeout' => 60, 'connect_timeout' => 60, 'ssl_verifyhost' => false ]);
Debugging Errors
We understand that you may run into some errors while integrating our library. You can contact our developer team for support.
For Authorization
and Validation
error responses, double-check your Secret key. If you get a server
error, kindly engage the team for support.
Terms and Conditions
By using this library, you agree with our Terms and Conditions.
Copyright (c) Payomatix Inc.
License
This SDK is open-sourced software licensed under the MIT license.