Symfony2授权.net SIM错误
我想使用payum.org在Symfony中使用Authorize.net SIM卡支付方式。 它没有官方门户,但omnipay中有一个门户:omnipay授权网。payum中也有omnipay网桥,因此可以在payum中使用omnipay网关 因此,我使用此设置,在提交authorize.net表单后,我得到错误:Symfony2授权.net SIM错误,symfony,authorize.net,omnipay,payum,Symfony,Authorize.net,Omnipay,Payum,我想使用payum.org在Symfony中使用Authorize.net SIM卡支付方式。 它没有官方门户,但omnipay中有一个门户:omnipay授权网。payum中也有omnipay网桥,因此可以在payum中使用omnipay网关 因此,我使用此设置,在提交authorize.net表单后,我得到错误: [date] request.CRITICAL: Uncaught PHP Exception Omnipay\Common\Exception\InvalidRequestExc
[date] request.CRITICAL: Uncaught PHP Exception Omnipay\Common\Exception\InvalidRequestException: "Incorrect hash" at .../authorize/vendor/omnipay/authorizenet/src/Message/SIMCompleteAuthorizeRequest.php line 42 {"exception":"[object] (Omnipay\\Common\\Exception\\InvalidRequestException(code: 0): Incorrect hash at .../authorize/vendor/omnipay/authorizenet/src/Message/SIMCompleteAuthorizeRequest.php:42)"} []
Authorize.Net Developer Center Merchant,
Your script timed out while we were trying to post transaction results to it.
Transaction ID: XXX
Transaction Result: This transaction has been approved.
但这不是因为生成的哈希不正确,而是因为第二次调用捕获url时没有POST数据
在带3个软件包的Symfony2的清洁安装上:
composer.json:
"payum/payum-bundle": "0.15.*",
"omnipay/authorizenet": "~2.0",
"payum/omnipay-bridge": "*@stable"
config.yml:
payum:
security:
token_storage:
AppBundle\Entity\PaymentToken: { doctrine: orm }
storages:
AppBundle\Entity\Payment: { doctrine: orm }
gateways:
authorizeGateway:
omnipay_offsite:
type: AuthorizeNet_SIM
options:
hashSecret: 'Simon'
ApiLoginId: 'xxx'
transactionkey: 'xxx'
testMode: false
developerMode: true
控制器:
/**
* @Route("/prepare", name="prepare")
*/
public function prepareAction()
{
$gatewayName = 'authorizeGateway';
$storage = $this->get('payum')->getStorage('AppBundle\Entity\Payment');
$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('USD');
$payment->setTotalAmount(1);
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('foo@example.com');
$storage->update($payment);
$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
$gatewayName,
$payment,
'done' // the route to redirect after capture
);
return $this->redirect($captureToken->getTargetUrl());
}
/**
* @Route("/done", name="done")
*/
public function doneAction(Request $request)
{
...
}
转到/prepare会显示一秒钟重定向到authorize.net页面,我被重定向到external test.authorize.net/gateway/transact.dll(在https上)页面,在该页面中我指定了卡号(测试卡号)和将来的到期日期。
提交此表格可提供:
An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.
This transaction has been approved.
It is advisable for you to contact the merchant to verify that you will receive the product or service.
我收到了关于商户电子邮件收据的电子邮件和关于错误的电子邮件:
[date] request.CRITICAL: Uncaught PHP Exception Omnipay\Common\Exception\InvalidRequestException: "Incorrect hash" at .../authorize/vendor/omnipay/authorizenet/src/Message/SIMCompleteAuthorizeRequest.php line 42 {"exception":"[object] (Omnipay\\Common\\Exception\\InvalidRequestException(code: 0): Incorrect hash at .../authorize/vendor/omnipay/authorizenet/src/Message/SIMCompleteAuthorizeRequest.php:42)"} []
Authorize.Net Developer Center Merchant,
Your script timed out while we were trying to post transaction results to it.
Transaction ID: XXX
Transaction Result: This transaction has been approved.
事务处理正确,调用捕获脚本,哈希匹配,然后在没有post数据的情况下再次调用捕获-然后哈希不匹配,授权显示错误
从symfony profiler发出的请求:
Token IP Method URL Time Status
fe39ec 198.241.162.104 GET .../payment/capture/vVgoUCPtgCOglv6rLwhIbUp64RZ_oIql1_KDpWjdrdk Tue, 17 Nov 2015 09:47:36 +0100 500
bba47c 198.241.162.104 GET .../payment/capture/vVgoUCPtgCOglv6rLwhIbUp64RZ_oIql1_KDpWjdrdk Tue, 17 Nov 2015 09:47:36 +0100 200
c95b83 198.241.162.104 POST .../payment/capture/vVgoUCPtgCOglv6rLwhIbUp64RZ_oIql1_KDpWjdrdk Tue, 17 Nov 2015 09:47:36 +0100 302
a87347 myip GET .../payment/capture/vVgoUCPtgCOglv6rLwhIbUp64RZ_oIql1_KDpWjdrdk Tue, 17 Nov 2015 09:47:30 +0100 200
c95d57 myip GET .../prepare Tue, 17 Nov 2015 09:47:29 +0100 302
从我所看到的,当我们调用/准备时,我们被重定向到立即捕获,这将转到授权的表单。然后在几秒钟后(填写并提交信用卡数据时),授权(不同ip)发出post请求以进行捕获。这是302重定向(可能应该是一个带有javascript代码的SIM响应,以便返回我们的页面?)。捕获被称为secod time,GET和计算的哈希不匹配-这是500响应-authorize保留在其url上并显示错误消息。永远不会调用完成脚本
问题是什么?很难进一步调试它,因为有payum、omnipay桥接器、omnipay、authorize组合
我正在互联网上可访问的环境中进行测试,帐户处于打开状态,测试模式处于关闭状态
更新:
如果我向控制器添加notify令牌,如下所示:
/**
* @Route("/prepare", name="prepare")
*/
public function prepareAction()
{
$gatewayName = 'authorizeGateway';
$storage = $this->get('payum')->getStorage('AppBundle\Entity\Payment');
$payment = $storage->create();
$payment->setNumber(uniqid());
$payment->setCurrencyCode('USD');
$payment->setTotalAmount(1); // 1.23 EUR
$payment->setDescription('A description');
$payment->setClientId('anId');
$payment->setClientEmail('foo@example.com');
$storage->update($payment);
$captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
$gatewayName,
$payment,
'done' // the route to redirect after capture
);
$tokenFactory = $this->get('payum.security.token_factory');
$notifyToken = $tokenFactory->createNotifyToken($gatewayName, $payment);
$payment->setDetails(['notifyUrl' => $notifyToken->getTargetUrl()]);
$storage->update($payment);
return $this->redirect($captureToken->getTargetUrl());
}
我收到错误“不支持请求通知{model:ArrayObject}”:
Omnipay网桥0.15.x未设置notifyUrl,而as notify URL。当收到通知时(在重定向之前),捕获令牌将被删除,并且不再可用 有两种解决方案:
omnipay
网关工厂,而不是omnipay\u场外
notifyUrl
$tokenFactory=$this->get('payum.security.token_-factory');
$notifyToken=$tokenFactory->createNotifyToken($gatewayName,$payment)
$payment->setDetails(['notifyUrl'=>$notifyToken->getTargetUrl());
$storage->update($payment)尝试注释这一行:这一行也可能相关,通知url(post请求)与返回url不同。它们必须是两个不同的URL。嗨,谢谢你的回复。我现在选择了第二种选择。我没有太多的时间调试这个,但现在我得到了另一个错误“请求通知{model:ArrayObject}不受支持”。我更新了问题,详细说明了我是如何按照您的说明修改控制器代码的,以及我得到了什么错误(所以现在的最终结果仍然是一样的)网桥不会将notify请求代理给内部omnipay网关的方法。是否应该实施有没有任何项目可以通过authorize.net SIM卡的网桥实现此功能,我可以看一下?还是文件?PayumBundle:Notify:do被调用,我知道我必须实现自定义NotifyAction,该操作应返回omnipay/授权消息之一或调用SIMGateway::completePurchase?不,没有任何应用程序,至少我不知道它们。是的,您是对的,您必须向omnipay桥添加一个NotifyAction,该桥调用completePurchase方法。并使用详细信息更新模型,如下所示:我添加了操作服务:action.notify.custom:class:AppBundle\Services\NotifyAction标记:-{name:payum.action,prepend:true,all:true}在执行payum:gateway:debug:authorizeGateway(payum\Core\gateway)时可见:Actions:AppBundle\Services\NotifyAction但当授权返回payum\u notify\u do gateway时,gateway没有附加此操作(我在payum\Core\gateway::findActionSupported中选中$this->Actions),因此我仍然得到RequestNotSupportedException。我是否正确注册了操作?有什么问题没有采取行动?