omnipay/authorizenet

用于 Omnipay 支付处理库的 Authorize.Net 网关

3.3.0 2019-04-27 22:33 UTC

README

用于 Omnipay PHP 支付处理库的 Authorize.Net 驱动程序

Build Status Latest Stable Version Total Downloads

Omnipay 是一个不依赖于框架、支持多网关的 PHP 5.3+ 支付处理库。本软件包实现了 Omnipay 对 Authorize.Net 的支持。

安装

Omnipay 通过 Composer 安装。要安装,只需使用 Composer 需求 league/omnipayomnipay/authorizenet

composer require league/omnipay omnipay/authorizenet:"3.x@dev"

基本用法

本软件包提供了以下网关

  • AuthorizeNet_AIM
  • AuthorizeNet_CIM
  • AuthorizeNet_SIM
  • AuthorizeNet_DPM

此外,AIM 驱动程序和 CIM(创建卡)支持 Accept.JS。更多详情请见下文。

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

Accept.JS

此网关使用 JavaScript 脚本在客户端(即支付表单中)对信用卡详细信息进行标记化,即发送标记化后的信用卡信息回商家网站,在该网站用作信用卡的代理。

信用卡被标记化为 Accept.JS 从 opaqueData 对象返回的两个值

  • dataDescriptor - 模糊数据类型,例如 "COMMON.ACCEPT.INAPP.PAYMENT"
  • dataValue - 模糊数据的值,例如 "eyJjb2RlIjoiNT... {256个字符} ...idiI6IjEuMSJ9"

这两个值必须通过 POST 传回商家应用程序,通常作为支付表单的一部分。请确保不要将原始信用卡详情传回您的网站。如何处理超出了这个简短说明的范围,但文档中始终欢迎示例。

在服务器上,标记化后的详细信息传递给 paymentauthorize 请求对象。您仍然需要传递 CreditCard 对象,因为该对象包含付款人和收件人的详细信息,但只需在该对象的信用卡详情中留空。例如

// $gateway is an instantiation of the AIM driver.
// $dataDescriptor and $dataValue come from the payment form at the front end.

use Omnipay\Common\CreditCard;

$request = $gateway->purchase(
    [
        'notifyUrl' => '...',
        'amount' => $amount,
        //
        'opaqueDataDescriptor' => $dataDescriptor,
        'opaqueDataValue' => $dataValue,
        //
        'card' => new CreditCard([
            'firstName' => 'Anne',
            'lastName' => 'Payee',
            ...
        ]),
        ...
    ]
);

CIM 创建卡功能使用:必须在您的前端支付表单上实现 Accept.js,一旦 Accept.js '标记化' 客户的卡,只需发送两个模糊字段,并从您的 POST 请求中删除卡的(号码、到期日和 CVV)。

Accept.js 的目标是完全去除卡信息进入您的服务器,因此请确保在向服务器发送之前删除该数据。

CIM 的创建卡功能将自动为您的 Authorize.Net 账户上请求的每个客户创建客户配置文件和支付配置文件,其中包含 '标记化' 的卡,您可以使用这些支付配置文件稍后向客户请求付款。

为了创建客户和支付配置文件,将模糊字段和包含账单信息的卡数组传递给 CIM 驱动程序的 createCard 方法

// $gateway is an instantiation of the CIM driver. //Omnipay::create( 'AuthorizeNet_CIM' )
// $dataDescriptor and $dataValue come from the payment form at the front end.

$request = $gateway->createCard(
    [
        'opaqueDataDescriptor' => $dataDescriptor,
        'opaqueDataValue' => $dataValue,
        'name' => $name,
        'email' => $email, //Authorize.net will use the email to identify the CustomerProfile 
        'customerType' => 'individual',
        'customerId' => $user_customer_id,//a customer ID generated by your system or send null
        'description' => 'MEMBER',//whichever description you wish to send
        'forceCardUpdate' => true
        'card' => [
            'billingFirstName' => $name,
            'billingLastName' => $last_name,
            'billingAddress1' => $address,
            'billingCity' => $city,
            'billingState' => $state,
            'billingPostcode' => $zipcode,
            'billingPhone' => '',
            //... may include shipping info but do not include card (number, cvv or expiration)
        ],
    ]
);
$response = $request->send();
$data = $response->getData();

$data['paymentProfile']['customerProfileId'];
$data['paymentProfile']['customerPaymentProfileId'];

// Now you can use these 2 fields to reference this customer and this payment profile for later use with 
// the rest of the CIM driver features as usual.

DPM 和 SIM 签名

DPM 和 SIM 以前使用 mdh HMAC 算法使用 transactionKey 签名他们的请求。从 2019 年初开始,此算法被完全删除。相反,现在使用 SHA-512 HMAC 算法对 DPM 和 SIM 请求进行签名,并验证接收到的通知。

要开始使用 SHA-512 签名,请设置网关中的 signatureKey

$gateway->setSignatureKey('48D2C629E4A...{100}...E7CA3C4E6CD7223D');

可以在账户设置的 API凭据与密钥 部分生成 signatureKey

支持

如果您在使用 Omnipay 时遇到一般性问题,我们建议您在 Stack Overflow 上发布帖子。请务必添加 omnipay 标签,以便更容易被找到。

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

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