chargily epay php
v3.0.0
دمج بوابة Epayment مع Chargily بسهولة.
composer require chargily/epay-php // Configurations file
return [
' key ' => ' your-api-key ' , // you can you found it on your epay.chargily.com.dz Dashboard
' secret ' => ' your-api-secret ' , // you can you found it on your epay.chargily.com.dz Dashboard
]; use Chargily ePay Chargily ;
require ' path-to-vendor/vendor/autoload.php ' ;
$ epay_config = require ' epay_config.php ' ;
$ chargily = new Chargily ([
//credentials
' api_key ' => $ epay_config [ ' key ' ],
' api_secret ' => $ epay_config [ ' secret ' ],
//urls
' urls ' => [
' back_url ' => " valid-url-to-redirect-after-payment " , // this is where client redirected after payment processing
' webhook_url ' => " valid-url-to-receive-payment-informations " , // this is where you receive payment informations
],
//mode
' mode ' => ' EDAHABIA ' , //OR CIB
//payment details
' payment ' => [
' number ' => ' payment-number-from-your-side ' , // Payment or order number
' client_name ' => ' client name ' , // Client name
' client_email ' => ' [email protected] ' , // This is where client receive payment receipt after confirmation
' amount ' => 75 , //this the amount must be greater than or equal 75
' discount ' => 0 , //this is discount percentage between 0 and 99
' description ' => ' payment-description ' , // this is the payment description
]
]);
// get redirect url
$ redirectUrl = $ chargily -> getRedirectUrl ();
//like : https://epay.chargily.com.dz/checkout/random_token_here
//
if ( $ redirectUrl ){
//redirect
header ( ' Location: ' . $ redirectUrl );
} else {
echo " We cant redirect to your payment now " ;
} use Chargily ePay Chargily ;
require ' path-to-vendor/vendor/autoload.php ' ;
$ epay_config = require ' epay_config.php ' ;
$ chargily = new Chargily ([
//credentials
' api_key ' => $ epay_config [ ' key ' ],
' api_secret ' => $ epay_config [ ' secret ' ],
]);
if ( $ chargily -> checkResponse ()) {
$ response = $ chargily -> getResponseDetails ();
//@ToDo: Validate order status by $response['invoice']['invoice_number']. If it is not already approved, approve it.
//something else
/*
$response like the follwing array
$response = array(
"invoice" => array(
"id" => 5566321,
"client" => "Client name",
"invoice_number" => "123456789",
"due_date" => "2022-01-01 00:00:00",
"status" => "paid",
"amount" => 75,
"fee" => 25,
"discount" => 0,
"comment" => "Payment description",
"tos" => 1,
"mode" => "EDAHABIA",
"invoice_token" => "randoom_token_here",
"due_amount" => 10000,
"created_at" => "2022-01-01 06:10:38",
"updated_at" => "2022-01-01 06:13:00",
"back_url" => "https://www.mydomain.com/success",
"new" => 1,
);
)
*/
exit ( ' OK ' );
}| مفتاح | وصف | إعادة توجيه عنوان URL | عملية عنوان URL |
|---|---|---|---|
| api_key | يجب أن تكون سلسلة من قبل المنظمة | مطلوب | مطلوب |
| api_secret | يجب أن تكون سلسلة من قبل المنظمة | مطلوب | مطلوب |
| عناوين URL | يجب أن يكون صفيف | مطلوب | غير مطلوب |
| عناوين URL [back_url] | يجب أن تكون سلسلة وعنوان URL صالح | مطلوب | غير مطلوب |
| عناوين URL [process_url] | يجب أن تكون سلسلة وعنوان URL صالح | مطلوب | غير مطلوب |
| وضع | يجب أن يكون في CIB ، إدهابيا | مطلوب | غير مطلوب |
| الدفع [رقم] | يجب أن تكون سلسلة أو int | مطلوب | غير مطلوب |
| الدفع [client_name] | يجب أن تكون سلسلة | مطلوب | غير مطلوب |
| الدفع [client_email] | يجب أن تكون سلسلة و صالصة البريد الإلكتروني هذا هو المكان الذي يتلقى فيه العميل إيصال الدفع بعد التأكيد | مطلوب | غير مطلوب |
| الدفع [المبلغ] | يجب أن يكون رقميًا أو شجاعًا أو متساويًا من 75 | مطلوب | غير مطلوب |
| الدفع [خصم] | يجب أن تكون رقمية وبين 0 و 99.99 (نسبة الخصم) | مطلوب | غير مطلوب |
| الدفع [الوصف] | يجب أن تكون سلسلة | مطلوب | غير مطلوب |
| خيارات | يجب أن يكون صفيف | مطلوب | غير مطلوب |
| خيارات [الرؤوس] | يجب أن يكون صفيف | مطلوب | غير مطلوب |
| خيارات [مهلة] | يجب أن تكون رقمية | مطلوب | غير مطلوب |