krsman/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 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');

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

支持

如果您在使用 Omnipay 时遇到一般性问题,我们建议您在 Stack Overflow 上发帖。请务必添加 omnipay 标签,以便他人能够轻松找到。

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

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