PHP
Learn how to integrate and use Plural PHP SDK with your PHP based website to accept payments.
This document provides a step-by-step guide for integrating the Plural's PHP Laravel SDK. It offers convenient methods for accepting and fetching orders, calculating EMIs, and verifying hashes.
Watch this video to learn how to integrate Plural PHP Laravel SDK for your PHP applications.
Download the Sampleapp
You can download the Sampleapp from the GitHub Link: https://github.com/pluralonline/plural-php-laravel-sdk-sampleapp.
Prerequisites
Before integrating the SDK into your Project, make sure the following requirements are met:
- PHP version 7.4 or higher, up to 8.1.
- Composer installed in your project.
Note:
TLS 1.2 information:
- For PHP 5.5.19 and above should have TLS version 1.2.
- For PHP 7 and above, TLS version 1.2 is typically available.
Installation
If your project uses Composer for managing dependencies, you can easily install the PHP library by
following these steps:
- Open your terminal or command prompt.
- Navigate to your project's root directory where your
composer.json
file is located. - Run the below Composer command to install the PHP library:
composer require pinelabs/php
To locally add a PHP library to your composer.json
file, follow these steps:
- Download the PHP library and place it in a directory within your project. You can obtain the
library files from a source like GitHub, or by downloading a release archive. - In your PHP library, make sure it has an autoloading mechanism defined, usually within a
composer.json
file. This is important to ensure that Composer can autoload the library's classes.
An examplecomposer.json
file for the library might look like this:
{
"name": "vendor-name/library-name",
"autoload": {
"psr-4": {
"VendorName\\LibraryName\\": "src/"
}
}
}
- Open your project's composer.json file and add a reference to the locally downloaded library. To
do this, you can use the path repository type. Add a repositories section and specify the local
path to the library, like this:
{
"repositories": [
{
"type": "path",
"url": "relative/path/to/library"
}
],
"require": {
"vendor-name/library-name": "*"
}
}
Example file using Pine Labs SDK:
{
"repositories": [
{
"type": "path",
"url": "./pinelab-sdk"
}
],
"require": {
"pinelabs/php":"@dev"
}
}
Replace relative/path/to/library
with the actual path to the directory where the library is
located within your project.
- After updating your project's
composer.json
file, open your terminal or command prompt,
navigate to your project's root directory (where thecomposer.json
file is located), and run:
composer update
Note:
- Use Composer Install or Composer Update to ensure you have the latest version of the library.
- The SDK is namespaced under
Pinelabs\Php
.- The API returns errors instead of throwing exceptions.
- Options are passed as an array instead of multiple arguments, wherever applicable, to ensure greater flexibility and easier configuration.
Implementation
- Refer to the GitHub Document for detailed instructions.
Handle Payments
To know the status of the payment you can use the below options.
- Inquiry API: Use this API to check transaction statuses.
- Webhook Notification: We send Webhook notifications on the successful payment or any changes to the payment's response object.
Updated 6 months ago