medboubazine / chargily-checkout
Chargily ePay Gateway - PHP
此软件包的官方仓库似乎已消失,因此该软件包已被冻结。
1.1.5
2022-03-28 18:01 UTC
Requires
- php: >=7.2.5
- guzzlehttp/guzzle: ^7.0
This package is auto-updated.
Last update: 2024-01-13 13:37:28 UTC
README
通过Chargily ePay Gateway简化您的集成
安装
- 通过Composer(推荐)
composer require medboubazine/chargily-checkout
- 作为ZIP下载我们不推荐此选项。但请注意定期下载更新版本 下载
快速入门
- 创建重定向文件 redirect.php
use Medboubazine\Chargily\Chargily; require './vendor/autoload.php'; $chargily = new Chargily([ //crenditionals 'api_key' => 'your-api-key', // you can you found it on your epay.chargily.com.dz Dashboard 'api_secret' => 'your-api-secret', // you can you found it on your epay.chargily.com.dz Dashboard //urls 'urls' => [ 'back_url' => "valid-url-to-redirect-after-payment", // this is where client redirected after payment processing 'webhook_url' => "valid-url-to-process-after-payment-sucess", // this is where you recieve 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' => 'client_email@mail.com', // 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.99 'description' => 'payment-description', // this is the payment description ], //options 'options' => [ 'headers' => [], 'timeout' => 20, ], ]); // 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"; }
- 创建处理文件 process.php
use Medboubazine\Chargily\Chargily; require './vendor/autoload.php'; $chargily = new Chargily([ //crenditionals 'api_key'=>'your-api-key', 'api_secret'=>'your-api-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 "invoice"=>[ "id" => 5566321, "client" => "Client name", "invoice_number" => "123456789", "due_date" => "2022-01-01 00:00:00", "status" => "paid", "amount" => 2500, "fee" => 72.5, "discount" => 0, "comment" => "Payment description", "tos" => 1, "mode" => "EDAHABIA", "invoice_token" => "randoom_token_here", "due_amount" => 25725, "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'); } exit;
配置
- 可用的配置
key | 描述 | 重定向url | 处理url |
---|---|---|---|
api_key | 必须是由组织提供的字符串 | 必需 | 必需 |
api_secret | 必须是由组织提供的字符串 | 必需 | 必需 |
urls | 必须为数组 | 必需 | 非必需 |
urls[back_url] | 必须为字符串且为有效的URL | 必需 | 非必需 |
urls[process_url] | 必须为字符串且为有效的URL | 必需 | 非必需 |
mode | 必须在 CIB,EDAHABIA 中 | 必需 | 非必需 |
payment[number] | 必须是字符串或整数 | 必需 | 非必需 |
payment[client_name] | 必须是字符串 | 必需 | 非必需 |
payment[client_email] | 必须是字符串且为有效的电子邮件地址 这是客户确认后收到付款收据的地方 | 必需 | 非必需 |
payment[amount] | 必须是数值且大于或等于75 | 必需 | 非必需 |
payment[discount] | 必须是数值且介于0和99.99之间(按百分比折扣) | 必需 | 非必需 |
payment[description] | 必须是字符串 | 必需 | 非必需 |
选项 | 必须为数组 | 必需 | 非必需 |
options[headers] | 必须为数组 | 必需 | 非必需 |
options[timeout] | 必须是数值 | 必需 | 非必需 |
注意
- 如果您遇到问题,请打开一个问题 点击这里