xenon / paystation

Paystation 是一个为孟加拉国支付网关提供商的 PHP 库。您可以将它集成到您的 PHP 应用程序中,并通过 mfs、信用卡等方式获取客户支付。

1.0.2 2023-06-21 13:29 UTC

This package is auto-updated.

Last update: 2024-09-10 09:41:06 UTC


README

xenon/paystation 是一个为孟加拉国支付网关提供商的 PHP 库。您可以将它集成到您的 PHP 应用程序中,并通过 mfs、信用卡等方式获取客户支付。

安装

composer require xenon/paystation

示例代码

步骤1:创建支付并重定向到支付URL

use Xenon\Paystation\Exception\PaystationPaymentParameterException;
use Xenon\Paystation\Paystation;

require 'vendor/autoload.php';

try {
    $config = [
        'merchantId' => 'xxx',
        'password' => 'xxxx'
    ];
    $pay = new Paystation($config);
    $pay->setPaymentParams([
        'invoice_number' => 'XXXXXXXXXXXX',
        'currency' => "BDT",
        'payment_amount' => 1,
        'reference' => "102030",
        'cust_name' => "Jhon Max",
        'cust_phone' => "01700000001",
        'cust_email' => "max@gmail.com",
        'cust_address' => "Dhaka, Bangladesh",
        'callback_url' => "http://www.yourdomain.com/success.php",
        // 'checkout_items' => "orderItems"
    ]);
    $pay->payNow(); //will automatically redirect to gateway payment page
} catch (Exception $e) {
    var_dump($e->getMessage());
}

步骤2:验证支付

 $config = [
    'merchantId' => 'xxx',
    'password' => 'xxxx'
 ];
$pay = new Paystation($config);
$status  = $pay->verifyPayment("invoice_number","trx_id"); //this will retrieve response as json

交易验证成功的示例 JSON 响应

    {
        "status_code": "200",
        "status": "success",
        "message": "Transaction found",
        "data": {
            "invoice_number": "ddsf648feebc415138XXXXX",
            "trx_status": "Success",
            "trx_id": "AFJ7IXXX",
            "payment_amount": 1,
            "order_date_time": "2023-06-19 11:57:04",
            "payer_mobile_no": "01750XXXX",
            "payment_method": "bKash",
            "reference": "102030",
            "checkout_items": null,
            "cust_phone": "01700000001"
        }
    }

交易验证失败的示例 JSON 响应

{
    "status_code": "1006",
    "status": "failed",
    "message": "Transaction not found in system"
}

重要方法

  • setPaymentParams()
  • payNow()
  • verifyPayment()

这个库目前处于 beta 版本,如果您有兴趣贡献,我们非常鼓励。为这个仓库创建一个分支,并提交一个 pull request。如果在开发过程中或部署后遇到任何问题或错误,应该创建一个 issue。