2结帐OmniPay-授权失败 [英] 2Checkout OmniPay - Authorization Failed

查看:114
本文介绍了2结帐OmniPay-授权失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 OmniPay API 时,我从2Checkout收到授权失败响应.

I'm getting an Authorization Failed response from 2Checkout when using OmniPay API.

我已经成功地将Stripe与OmniPay挂钩,所以我接着就挂钩了2Checkout.当您执行此操作时,Github上的初始软件包会警告您从用户collizo4sky获取较新的版本.因此,我这样做了,然后使其能够正常工作而没有致命错误.

I had successfully hooked up Stripe with OmniPay, so then I went about hooking up 2Checkout. When you go to do that, the initial package on Github warns you to get the newer version from a user collizo4sky. So, I did, and then got it to work slightly without fatal error.

在我的Web表单中,我正确地生成了一个令牌,并且2Checkout上的沙箱日志确认了这一点.然后,我在OmniPay中使用以下代码尝试为卡充值:

In my web form, I generate a token properly and the sandbox logs at 2Checkout confirm this. I then use this code in OmniPay to attempt to charge the card:

use Omnipay\Omnipay;
$sMerchantTransID = rand(11111111,99999999);
$oGateway = Omnipay::create('TwoCheckoutPlus_Token');
$oGateway->setPrivateKey($config->TWOCHECKOUT_PRIVATE_KEY);
$oGateway->setAccountNumber($config->TWOCHECKOUT_SELLERID);
$oGateway->setTestMode(true);
$oResponse = $oGateway->purchase(array(
    'amount' => $sPrice,
    'currency' => 'USD',
    'token' => $sToken,
    'transactionId' => $sMerchantTransID
))->send();
if (!$oResponse->isSuccessful()) {
    die('ERROR: ' . $oResponse->getMessage());
}

但是,该消息返回时显示授权失败".因此,在此路径中,我进入了用于collizo4sky软件包的OmniPay API的源代码...

However, the message comes back with "Authorization Failed". So, I went into the source code of the OmniPay API for collizo4sky's package in this path...

omnipay/vendor/collizo4sky/omnipay-2checkout/src/Message/TokenPurchaseRequest.php

...并添加了一些sendData()类方法的日志文件调试.这就是它的回应,并请注意,出于明显的隐私原因,我更改了一些值:

...and added some log file debugging of the sendData() class method. This is what it responded with, and note that I changed some of the values for obvious privacy reasons:

array (
  'sellerId' => '901414261',
  'privateKey' => 'EAEC8615-4C48-4D98-B7E5-4B6D8865E1BA',
  'merchantOrderId' => 65639323,
  'token' => 'FDI1ZTM3N2UtY2VkZS00NTM1LWE5MTctYzI4MjA5YWI4Yjhm',
  'currency' => 'USD',
  'total' => '519.00',
)

是的,sellerID和privateKey来自沙箱帐户,就像我首先在Web表单中生成令牌时可发布的密钥一样.

Yes, the sellerID and the privateKey came from the sandbox account, as did the publishable key when I generated the token in the web form in the first place.

因此,无论如何,当将其提交到沙箱URL时,它会返回以下响应:

So, anyway, when this is submitted to the sandbox URL, it returns with this response:

HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Cache-Control: no-cache, no-store, must-revalidate
Date: Fri, 22 Apr 2016 03:30:37 GMT
Expires: 0
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

{"validationErrors":null,"response":null,"exception":{"errorMsg":"Authorization Failed","httpStatus":"400","exception":false,"errorCode":"600"}}

我在做什么错了?

然后,我尝试使用他们提供的 2Checkout支持的PHP库.我进行了完全相同的事务,并且它也返回授权失败".

I then tried using the 2Checkout-supported PHP library that they provide. I did the exact same transaction and it too returns "Authorization Failed".

我想知道这是否是我帐户上的设置,即使我正在使用沙箱?我的意思是,我尚未获得生产批准,并且一直在努力使沙盒运行,以便可以进行演示.

I'm wondering if it's a setting on my account even though I'm using a sandbox? I mean, I have not yet been approved in production, and was trying to get the sandbox going until then so that I could do a demo.

我还重新生成了沙箱中的API密钥,然后再次尝试,但失败了.

I also regenerated API keys in the sandbox and tried again, and that failed.

我使用的信用卡是他们在沙箱API密钥下的沙箱上提供的信用卡,我使用的CVV为123,有效期为12/18.然后我以为可能需要4位数字的年份,因此我对其进行了更新并再次尝试,但同样也因授权失败"而出现相同的错误.

The credit card I used was the one they provide on the sandbox under the sandbox API keys, and I used a CVV of 123 with 12/18 as the expiration date. I then thought maybe it wanted a 4 digit year, so I updated that and tried again, and that failed too with the same consistent error of "Authorization Failed".

当我检查授权失败"的含义时,似乎是信用卡出了问题.

When I check on what "Authorization Failed" means, it appears that it's the credit card that's the problem.

到目前为止,我的直觉告诉我我做的所有事情都正确无误,这是我帐户上的一个标志.我的意思是,如果我的普通帐户尚未获得批准,沙盒是否仍然可以正常工作?

My gut feeling so far is telling me that I'm doing everything correct and that it's a flag on my account that's the issue. I mean, if my regular account is not yet approved, will the sandbox still work?

推荐答案

我可以通过的唯一方法是在帐户">网站管理"下的沙箱设置中将演示"模式手动设置为关闭",然后至少传递一个帐单邮寄地址.我很想了解如何不满足帐单邮寄地址要求(例如,对于数字下载商品),但还没有找到一种方式,或者甚至有可能这样做.

The only way that I could get a transaction to go through was to set the Demo mode to "Off" manually in the sandbox settings under Account > Site Management, and then to pass in at least a billing address. I'd love to find out how to not have the billing address requirement (such as for digital download goods), but have not found a way to do so just yet, or if that's even possible.

请注意,如果将演示模式"设置为开",并且不发送账单地址,则交易会顺利进行,但不会在销售"选项卡下显示为销售.这不是很有用,因为当您上线时,您想要可以退款的实际销售,并且演示模式不会模拟实际的费用,而只是模拟该卡的授权. (至少我已经知道了.)

Please note that if you set Demo Mode to "On", plus don't send a billing address, the transaction will go through okay but then it won't appear as a sale under the Sales tab. That's not very useful, because when you go live you want an actual sale that you can refund, and Demo Mode doesn't simulate an actual charge, merely an authorization of that card. (At least that's what I've figured out.)

transactionId参数上,我在此处使用了一个快捷方式.请使其成为系统中的唯一编号(例如UNIX时间生成的某个编号),否则可能会导致潜在的冲突.

On the transactionId parameter, I took a shortcut for purposes here. Please make it a unique number in your system (like some number generated with UNIX time) or you could end up with a potential collision.

我还尝试仅注释掉电子邮件或电话,或同时注释掉这两种方法,但都行不通-您会收到参数错误".然后,我尝试仅发送card下的以下字段:billingNameemailbillingPostcodebillingCountry-并且也因"Parameter Error"而失败.因此,然后我添加了billingState-"Parameter Error".然后,添加billingCity-参数错误".因此,为了使交易顺利进行,除非有人可以向我展示一些设置优先选项或技术,否则必须提供帐单邮寄地址",并且还必须包括电子邮件和电话,这令我大吃一惊.我敢肯定,对于某些人来说,这是一个风头浪尖,例如那些试图出售数字下载之类的无形资产的人.还要注意,我尝试了官方2Checkout创建的PHP API ,并再次尝试了所有这些测试,然后再次收到参数错误",除非使用了完整的帐单邮寄地址(包括电子邮件和电话). 我敢肯定,对于某些企业来说,包括帐单和电子邮件在内的完整帐单邮寄地址要求将是一件令人头疼的事.

I also tried commenting out just the email, or just the phone, or both, and that didn't work -- you'll get "Parameter Error". Then, I tried sending in only these fields under card: billingName, email, billingPostcode, and billingCountry -- and that failed with "Parameter Error" too. So then I added billingState -- "Parameter Error". Then, added billingCity -- "Parameter Error". So, in order for the transaction to go through, unless someone can show me some setting override or technique, the Billing Address is required, and must also include email and phone, to my wild surprise. That's a showstopper for some people, I'm sure, such as those trying to sell non-tangibles like digital downloads. Note also that I tried the official 2Checkout-created PHP API and tried all these tests again with that, and again, received "Parameter Error" unless the full billing address (including email and phone too) was utilized. This full billing address requirement with also email and billing phone is going to be a bummer for some businesses, I'm sure.

编辑:如果我猜对了,此答案是一个正式答案.来自2Checkout工作人员本身吗?它肯定看起来就是那样.无论如何,他说绝对需要帐单地址,因为正如他所说,这是我们的银行合作伙伴进行地址验证的要求."

This answer, if I'm guessing right, is an official answer from someone working at 2Checkout, itself? It sure does look that way. Anyway, he says that the billing address is definitely required because, as he states, "This is a requirement of our banking partners for address verification."

您需要试验一个真实的实时交易,但是我发现至少在沙箱模式下,如果我在官方2Checkout PHP库,或OmniPay API中的billingPhone,那么交易就可以了.他们只是想查看该参数,尽管它可以为空.但是请不要相信我的话-在实时交易中对其进行测试(并退还您自己的钱)以再次确认,因为我只是在沙盒中进行此操作. 此答案似乎已从2Checkout本身正式确认他们允许这样做.

You'll need to experiment with a real live transaction, but I discovered in at least sandbox mode that, if I pass an empty string for the phoneNumber field on the official 2Checkout PHP library, or the billingPhone in the OmniPay API, then the transaction goes through okay. They just want to see that parameter, although it can be empty. But don't take my word for it -- test it on a live transaction (and refund yourself) to reconfirm, as I was only doing this in the sandbox. This answer seems to officially confirm from 2Checkout itself that they allow this.

固定代码:

use Omnipay\Omnipay;
$sMerchantTransID = rand(11111111,99999999);
$oGateway = Omnipay::create('TwoCheckoutPlus_Token');
$oGateway->setPrivateKey($config->TWOCHECKOUT_PRIVATE_KEY);
$oGateway->setAccountNumber($config->TWOCHECKOUT_SELLERID);
$oGateway->setTestMode(true); // turns on Sandbox access
$oResponse = $oGateway->purchase(array(
    'amount' => $sPrice,
    'currency' => 'USD',
    'token' => $sToken,
    'transactionId' => $sMerchantTransID,
    'card' => array(
        'billingName' => $sName,
        'billingAddress1' => $sStreet1,
        'billingAddress2' => $sStreet2,
        'billingCity' => $sCity,
        'billingState' => $sState,
        'billingPostcode' => $sZip,
        'billingCountry' => $sCountry,
        'email' => $sEmail,
        'billingPhone' => $sPhone
    )
))->send();
if (!$oResponse->isSuccessful()) {
    die('ERROR: ' . $oResponse->getMessage());
}

这篇关于2结帐OmniPay-授权失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆