wiraazharan / leanx-sdk
This package is to assist LeanX integration
1.1.5
2024-08-21 07:55 UTC
Requires
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^7.0
README
LeanxSdk is a PHP SDK designed to simplify integration with the LeanX payment API. This SDK provides easy-to-use methods for generating payment links, validating payments, and checking payment statuses.
API Docs : https://docs.leanx.io/api-docs
- Easy setup and usage for LeanX payment integration.
- Flexible configuration with dynamic base URLs and endpoints.
- Comprehensive support for generating and managing payments.
Basic Usage
To get started with LeanxSdk
, follow these steps:
Instantiate the SDK
use Wiraazharan\LeanxSdk\LeanxSdk; // Base URL for LeanX API (use sandbox or live URL as needed) $baseUrl = 'https://api.leanx.dev'; // Replace 'your-auth-token' with your actual LeanX auth token $authToken = 'LP-922AFF8C-MM|cdffb385-7f8b-4fa8-9bdf-5563c7b6c2cb|a59592d0bf0620ac09ee406b91f7006b59b96a35d1406dc3101e383dfa9abf820686064e7b281adc71a3a3a36eed5xxxxxxxxxxxxe41ad25a0d07axxxxx'; // Replace 'hashKey' with your actual LeanX Hash Key $hashKey = 'a59592d0bf0620ac09ee406b91f7006b59b96a35d1406dc3101e383dfa9abf820686064e7b281adc71a3a3xxxxxxxe1ae77b39e41ad25a0d07a2525531'; // Replace 'UUID' with your actual LeanX UUID $UUID = 'cdffb385-7f8b-xxxxxxx-c7b6c2cb'; // Create a new instance of the SDK $sdk = new LeanxSdk($baseUrl, $authToken, $hashKey, $UUID);
Generate a Payment Link
$parameters = [ 'amount' => 100.00, 'full_name' => 'John Doe', 'email' => 'john.doe@example.com', 'phone_number' => '0123456789', 'invoice_no' => 'INV12345', 'redirect_url' => 'https://yourwebsite.com/redirect', 'callback_url' => 'https://yourwebsite.com/callback' ]; $response = $sdk->GeneratePaymentLinkv1($parameters); print_r($response);
Check Payment Status
$invoiceNo = 'INV12345'; $response = $sdk->CheckPaymentStatusV1($invoiceNo); print_r($response);
Payment Services List
$parameters = [ "payment_type" => "WEB_PAYMENT", "payment_status" => "active", "payment_model_reference_id" => 1, ]; $response = $sdk->GetPaymentServices($parameters); print_r($response);
HMAC Endpoints
Generate a Payment Link
$parameters = [ 'amount' => 100.00, 'full_name' => 'John Doe', 'email' => 'john.doe@example.com', 'phone_number' => '0123456789', 'invoice_no' => 'INV12345', 'redirect_url' => 'https://yourwebsite.com/redirect', 'callback_url' => 'https://yourwebsite.com/callback' ]; $response = $sdk->GeneratePaymentLinkv1WithHashmac($parameters); print_r($response);
Generate Auto Bill Page
$parameters = [ 'amount' => 100.00, 'full_name' => 'John Doe', 'email' => 'john.doe@example.com', 'phone_number' => '0123456789', 'invoice_no' => 'INV12345', 'redirect_url' => 'https://yourwebsite.com/redirect', 'callback_url' => 'https://yourwebsite.com/callback' ]; $response = $sdk->CreateAutoBillPagev1WithHashmac($parameters); print_r($response);
Check Payment Status
$invoiceNo = 'INV12345'; $response = $sdk->CheckPaymentStatusV1WithHmac($invoiceNo); print_r($response);
Payment Services List
$parameters = [ "payment_type" => "WEB_PAYMENT", "payment_status" => "active", "payment_model_reference_id" => 1, ]; $response = $sdk->GetPaymentServicesHmac($parameters); print_r($response);
Callback Decode Helper
$callbackData = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnZvaWNlX25vIjoiSU5WMTIzNDUwMDAzIiwiY2xpZW50X2RhdGEiOnsibWVyY2hhbnRfaW52b2ljZV9ubyI6IklOVjEyMzQ1MDAwMyIsInV1aWQiOiJjZGZmYjM4NS03ZjhiLTRmYTgtOWJkZi01NTYzYzdiNmMyY2IiLCJvcmRlcl9pZCI6Ik5vbmUifSwiaW52b2ljZV9zdGF0dXNfaWQiOjIsImludm9pY2VfdHlwZV9pZCI6MSwiaW52b2ljZV90eXBlIjoiTk9STUFMX0NPTExFQ1RJT04iLCJpbnZvaWNlX3N0YXR1cyI6IlNVQ0NFU1MiLCJhbW91bnQiOiI1MS4wMCIsInBheW1lbnRfbW9kZWxf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