meebio/omnipay-secure-trading

Omnipay PHP支付处理库的安全交易驱动程序

1.2.0 2019-08-08 08:14 UTC

This package is auto-updated.

Last update: 2024-09-08 19:21:38 UTC


README

Omnipay PHP支付处理库的安全交易网关

Latest Version on Packagist Software License Build Status Total Downloads

Omnipay 是一个框架无关、多网关支付处理库,适用于PHP 5.3+。本包实现了Omnipay对Secure Trading的支持。

安装

通过Composer

$ composer require meebio/omnipay-secure-trading

使用方法

本包提供以下网关

  • Secure Trading

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

此驱动程序支持以下交易类型

  • purchase($options) - 授权并在客户卡上立即扣款
  • completePurchase($options) - 处理购买后的离站网关返回
  • refund($options) - 退款已处理的交易
  • threeDSecure($options) - 通过3D Secure流程授权客户卡,与设置applyThreeDSecure为true的purchase($options)相同

网关实例化

$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');

驱动程序还支持使用cardReference而不是card进行支付。它可以在授权和购买请求中使用

$gateway->purchase([
    'amount'        => '10.00',
    'cardReference' => 'abc',
]);

3D Secure

要通过purchase请求启用3D Secure信用卡授权,需要将applyThreeDSecure参数设置为true。然后整个购买流程如下

$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');

$request = $gatewat->purchase([
    'transactionId'     => 'test-1234',
    'applyThreeDSecure' => true,
    'returnUrl'         => 'http://test-website.test/return-url',
    'amount'            => '2.99',
    'currency'          => 'GBP',
    'card'              => [
        'number'      => '4111111111111111',
        'expiryMonth' => '12',
        'expiryYear'  => '2020',
        'cvv'         => '123',
        'firstName'   => 'Forename',
        'lastName'    => 'Surname',
    ],
]);

$response = $request->send();
if ($response->isSuccessful()) {
    // card not enrolled or unknown enrollment
    // and payment is successful, no redirection needed
} elseif ($response->isRedirect()) {
    // redirect to offsite payment gateway
    $response->redirect();
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

在发生重定向的情况下,需要以下代码来处理客户从远程服务器返回后的支付

$gateway = Omnipay::create('SecureTrading');
$gateway->setSiteReference('siteReference123');
$gateway->setUsername('username123');
$gateway->setPassword('password123');
    
$request = $gateway->completePurchase([
    'md'    => $_POST['MD'],
    'paRes' => $_POST['PaRes'],
]);

$response = $request->send();
if ($response->isSuccessful()) {
    // payment is successful
} else {
    // payment failed: display message to customer
    echo $response->getMessage();
}

支持

如果您对Omnipay有任何一般性问题,我们建议在Stack Overflow上发布。请务必添加omnipay标签,以便更容易找到。

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

如果您认为您已经找到了一个错误,请使用GitHub问题跟踪器进行报告,或者更好的方法是分叉库并提交拉取请求。

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

测试

$ composer test

贡献

请参阅CONTRIBUTING以获取详细信息。

安全性

如果您发现任何安全问题,请通过jablonski.kce@gmail.com发送电子邮件,而不是使用问题跟踪器。

致谢

许可

MIT许可证(MIT)。请参阅许可文件以获取更多信息。