adatasol-tourtools/omnipay-authorizenet

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

3.2.0 2019-02-06 23:29 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 characters} ...idiI6IjEuMSJ9"

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

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

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

$request = $gateway->purchase(
    [
        'notifyUrl' => '...',
        'amount' => $amount,
        'opaqueDataDescriptor' => $dataDescriptor,
        'opaqueDataValue' => $dataValue,
        ...
    ]
);

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 问题跟踪器 报告它,或者更好的是,分叉库并提交一个 pull request。