sadad-payment / library
Sadad PHP 库
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-09-22 11:49:43 UTC
README
Sadad Pay 库是一个 PHP 库,用于将 Sadad 支付 API 集成到 PHP 插件、模块、电子商务和网站上。
许可证
仅限于 GPL-3.0 许可证。
安装
您可以通过 Composer 安装/要求它
composer require sadad-payment/library
如何使用它 ..
创建刷新令牌
$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.";
创建发票
$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>.";
获取发票信息
$invoiceInfo = $sadadObj->getInvoiceInfo( $sadadInvoice['InvoiceId'], $sadadObj->refreshToken ); echo "Sadad Invoice information <pre/>"; print_r($invoiceInfo);