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:

  1. PHP version 7.4 or higher, up to 8.1.
  2. 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:

  1. Open your terminal or command prompt.
  2. Navigate to your project's root directory where yourcomposer.json file is located.
  3. 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:

  1. 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.
  2. 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 example composer.json file for the library might look like this:
{
  "name": "vendor-name/library-name",
  "autoload": {
    "psr-4": {
      "VendorName\\LibraryName\\": "src/"
    }
  }
}
  1. 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.

  1. After updating your project's composer.json file, open your terminal or command prompt,
    navigate to your project's root directory (where the composer.json file is located), and run:
composer update

📘

Note:

  1. Use Composer Install or Composer Update to ensure you have the latest version of the library.
  2. The SDK is namespaced under Pinelabs\Php.
  3. The API returns errors instead of throwing exceptions.
  4. Options are passed as an array instead of multiple arguments, wherever applicable, to ensure greater flexibility and easier configuration.

Implementation

Handle Payments

To know the status of the payment you can use the below options.

  1. Inquiry API: Use this API to check transaction statuses.
  2. Webhook Notification: We send Webhook notifications on the successful payment or any changes to the payment's response object.