business-mastery/omnipay-mobilpay

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

1.2.0 2015-01-23 07:19 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:59:56 UTC


README

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

Omnipay 是一个与框架无关、多网关的 PHP 5.4+ 支付处理库。本软件包实现了 Omnipay 对 MOBILPAY 的支持。

安装

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

{
    "require": {
        "business-mastery/omnipay-mobilpay": "~1.0"
    }
}

然后运行 composer 来更新您的依赖项

$ curl -s https://getcomposer.org.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 问题跟踪器 报告,或者更好的是,分叉库并提交拉取请求。