venveo / authorizenet
为Omnipay支付处理库提供的Authorize.Net网关
Requires
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- omnipay/common: ^3
Requires (Dev)
- omnipay/tests: ^3
- phpro/grumphp: ^0.14
- squizlabs/php_codesniffer: ^3
This package is auto-updated.
Last update: 2024-09-20 04:20:32 UTC
README
Omnipay PHP支付处理库的Authorize.Net驱动
Omnipay是一个框架无关的多网关支付处理库,适用于PHP 5.3+。此包实现了Omnipay对Authorize.Net的支持。
安装
Omnipay通过Composer安装。要安装,只需使用Composer要求league/omnipay
和omnipay/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发送回商户应用程序。务必不要将原始信用卡详情发送回您的网站。如何处理超出了本简短的说明,但示例始终欢迎在文档中。
在服务器上,标记后的详情传递到payment
或authorize
请求对象。您仍然需要传递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中的创建卡片功能将自动为您的每个客户创建客户配置文件和支付配置文件(使用'tokenized'卡片),这些客户是在您的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标签,以便可以轻松找到。
如果您想及时了解发布公告、讨论项目的想法或提出更详细的问题,还可以订阅一个邮件列表。
如果您认为您发现了一个bug,请使用GitHub问题跟踪器报告它,或者更好的做法是,fork这个库并提交一个pull request。