sadad-payment / library
Sadad PHP Library
1.0.0
2023-10-17 07:31 UTC
Requires
- php: >=7
- ext-curl: *
- ext-json: *
This package is not auto-updated.
Last update: 2024-12-15 13:00:19 UTC
README
Sadad Pay library is a PHP library to integrate Sadad payment APIs with PHP plugins, modules, e-commerce and websites.
License
The GPL-3.0-only License.
Install
You can install/require it via Composer
composer require sadad-payment/library
How to use it ..
Create refresh Token
$sadadConfig = array( 'clientId' => '', 'clientSecret' => '', 'isTest' => true, // true for test mode | false for live mode ); $sadadObj = new SadadLibrary( $sadadConfig ); $sadadObj->generateRefreshToken(); echo "Save the refresh Token ".$sadadObj->refreshToken. " into a secure place.";
Create an invoice
$invoice = array( 'ref_Number' => "order #110092", 'amount' => SadadLibrary::getKWDAmount( 'USD', 40 ), 'customer_Name' => "fname lname", 'customer_Mobile' => SadadLibrary::validatePhone( '+966987654321' ), 'customer_Email' => "email@email.com", 'currency_Code' => 'USD' ); $request = array( 'Invoices' => array( $invoice ) ); $sadadInvoice = $sadadObj->createInvoice( $request, $sadadObj->refreshToken ); $invoiceURL = $sadadInvoice['InvoiceURL']; echo "Pay Sadad Invoice <a href='$invoiceURL' target='_blank'>$invoiceURL</a>.";
Get invoice information
$invoiceInfo = $sadadObj->getInvoiceInfo( $sadadInvoice['InvoiceId'], $sadadObj->refreshToken ); echo "Sadad Invoice information <pre/>"; print_r($invoiceInfo);