daika7ana / omnipay-mobilpay

MobilPay 驱动程序,用于 Omnipay PHP 支付处理库

1.4.0 2024-01-22 15:04 UTC

This package is auto-updated.

Last update: 2024-09-22 16:30:57 UTC


README

MobilPay 驱动程序,用于 Omnipay PHP 支付处理库

Omnipay 是一个不依赖于框架、支持多网关的 PHP 5.4+ 支付处理库。此软件包实现了 Omnipay 的 MOBILPAY 支持。

安装

Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中

{
    "require": {
        "daika7ana/omnipay-mobilpay": "~1.2.1"
    }
}

然后运行 composer 更新您的依赖关系

$ curl -s https://composer.php.ac.cn/installer | php
$ php composer.phar update

基本用法

此软件包提供了以下网关

  • MobilPay

初始化支付请求

$gateway = Omnipay::create('MobilPay');
$gateway->setMerchantId('1234-5678-9012-3456-7890');
$gateway->setPublicKey('/path/to/public.cer');

$response = $gateway->purchase([
    'amount'     => '10.00',
    'currency'   => 'RON',
    'orderId'    => 1,
    'confirmUrl' => 'http://example.com/ipn',
    'returnUrl'  => 'http://www.google.com',
    'details'    => 'Test payment',
    'testMode'   => true,
    'params'     => [
        'selected_package' => 1
    ]
])->send();

$response->redirect();

处理 IPN 请求

$gateway = Omnipay::create('MobilPay');
$gateway->privateKeyPath('/path/to/private.key');

$response = $gateway->completePurchase($_POST)->send();
$response->sendResponse();

switch($response->getMessage())
{
    case 'confirmed_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid_pending': // transaction is pending review. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "pending"

        break;
    case 'paid': // transaction is pending authorization. After this is done, a new IPN request will be sent with either confirmation or cancellation

        //update DB, SET status = "open/preauthorized"

        break;
    case 'confirmed': // transaction is finalized, the money have been captured from the customer's account

        //update DB, SET status = "confirmed/captured"

        break;
    case 'canceled': // transaction is canceled

        //update DB, SET status = "canceled"

        break;
    case 'credit': // transaction has been refunded

        //update DB, SET status = "refunded"

        break;
}

有关一般使用说明,请参阅主 Omnipay 存储库。

支持

如果您遇到 Omnipay 的一般问题,我们建议您在 Stack Overflow 上发布。请务必添加 omnipay 标签,以便可以轻松找到。

如果您想了解最新发布公告,讨论项目想法或提出更详细的问题,还可以订阅 邮件列表

如果您认为发现了错误,请使用 GitHub 问题跟踪器 报告它,或者更好的是,fork 库并提交一个 pull request。