Sadad PHP Library allows developers to start their integration with Sadad by using the composer package on the merchant web application.

The web application should support the composer packages.
Installation
You can install the sadad-payment/library via composer packages.
In the command line (cmd), you can run the below command to get the PHP composer package.
composer require sadad-payment/library
Create Refresh Token
$sadadConfig = array(
'clientId' => '',// client Key that exists in Sadad Pay account
'clientSecret' => '',// client Secret that exists in Sadad Pay account
'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 protected]",
'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);
In the Sadad profile under API section, merchant can add the Success URL/Fail URL for the application.