Jibit composer 包

dev-main 2023-02-20 17:08 UTC

This package is auto-updated.

Last update: 2024-09-20 20:41:42 UTC


README

接口网关 Jibit PHP Composer 包

Jibit 作为 Shopex 官方最大的支付合作伙伴之一,提供具有连接多种网关和智能路径选择功能支付接口,旨在确保支付系统稳定性和增加企业收入。

兼容性

php 7.4 及以上

安装

composer require vahidkaargar/jibit

请求支付

use vahidkaargar\jibit;

$jibit = new Jibit("API_KEY", "API_SECRET");

$request = $jibit->paymentRequest('AMOUNT_RIAL', 'YOUR_INVOICE_ID', 'MOBILE_NUMBER', 'CALLBACK_URL');

if (!empty($request['pspSwitchingUrl'])) {
    // successful result and redirect to PG
    header('Location: ' . $request['pspSwitchingUrl']);
}
if (!empty($request['errors'])) {
    // fail result and show the error
    echo $request['errors'][0]['code'] . ' ' . $request['errors'][0]['message'];
}

验证支付

use vahidkaargar\jibit;

if (empty($_POST['amount']) || empty($_POST['purchaseId']) || empty($_POST['status'])) {
    echo 'No data found.';
} else {
    //get data from query string
    $amount = $_POST['amount'];
    $refNum = $_POST['purchaseId'];
    $state = $_POST['status'];

    $jibit = new Jibit("API_KEY", "API_SECRET");

    // Making payment verify
    $request = $jibit->paymentVerify($refNum);
    if (!empty($request['status']) && $request['status'] === 'SUCCESSFUL') {
        //successful result
        echo 'Successful! refNum:' . $refNum;

        //show session detail
        $order = $jibit->getOrderById($refNum);
        if (!empty($order['elements'][0]['pspMaskedCardNumber'])) {
            echo 'payer card pan mask: ' . $order['elements'][0]['pspMaskedCardNumber'];
        }
    } else {
        echo 'Verifying payment has been failed!';
    }
}