支付宝错误。此交易无效。请返回收款人的网站以使用他们的常规结账流程完成您的交易
Posted
技术标签:
【中文标题】支付宝错误。此交易无效。请返回收款人的网站以使用他们的常规结账流程完成您的交易【英文标题】:PayPal error. This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow 【发布时间】:2015-05-07 22:50:31 【问题描述】:我正在尝试对我的网站实施 PayPal 直接付款。
在调用 SetExpressCheckout 时,我从 PayPal 收到了成功令牌:
Array
(
[TIMESTAMP] => 2015-03-06T10:16:55Z
[CORRELATIONID] => 7d0a42f74fa6b
[ACK] => Success
[VERSION] => 121
[BUILD] => 15420584
[AMT] => 125.00
[CURRENCYCODE] => EUR
[AVSCODE] => X
[CVV2MATCH] => M
[TRANSACTIONID] => 29A40018PU668530B
)
响应如下所示:
TIMESTAMP=2015%2d03%2d06T10%3a16%3a55Z&CORRELATIONID=7d0a42f74fa6b&ACK=Success&VERSION=121&BUILD=15420584&AMT=125%2e00&CURRENCYCODE=EUR&AVSCODE=X&CVV2MATCH=M&TRANSACTIONID=29A408
我已尝试以多种方式降低 URL 以将响应发送回顶部贝宝。我现在用的是:
$result = rawurldecode($result);
结果如下所示: TIMESTAMP=2015-03-06T10:16:55Z&CORRELATIONID=7d0a42f74fa6b&ACK=Success&VERSION=121&BUILD=15420584&AMT=125.00&CURRENCYCODE=EUR&AVSCODE=X&CVV2MATCH=M&TRANSACTIONID=29A40018PU668530B
我尝试用 strtolower 来处理请求,结果变成了这样:
小写的结果:
timestamp=2015-03-06t10:31:45z&correlationid=490f48424be02&ack=success&version=121&build=15420584&amt=125.00¤cycode=eur&avscode=x&cvv2match=m&transactionid=80g4320670816912n
我已经意识到 cycode 之前那个奇怪的字符:¤
当我尝试使用这样的 php 重定向发回令牌时,(带或不带小写字母):
header('Location: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&'.$result);
我被重定向到: https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_flow&SESSION=...
说:
此交易无效。请返回收件人的网站 使用他们的常规结账流程完成您的交易。返回 给商家 目前,我们无法处理您的请求。 请返回并尝试其他选项。测试地点
即使我使用的是非小写版本,我也会遇到同样的错误!
我意识到 localhost 是个问题。上传我的网站时,SetExpressCheckout 令牌很好。
现在问题是当我取回这个令牌时: TOKEN=EC%2d0PA6125744246545G&TIMESTAMP=2015%2d03%2d06T13%3a10%3a09Z&CORRELATIONID=10c7929423b68&ACK=Success&VERSION=121&BUILD=15640276
并使用以下参数发送 GetExpressCheckoutDetails 请求:
Array
(
[METHOD] => GetExpressCheckoutDetails
[USER] => ...
[PWD] => ...
[SIGNATURE] => ...
[VERSION] => 121
[TOKEN] => TOKEN=EC-0PA6125744246545G&TIMESTAMP=2015-03-06T13:10:09Z&CORRELATIONID=10c7929423b68&ACK=Success&VERSION=121&BUILD=15640276
)
我仍然收到令牌错误:
Array
(
[TIMESTAMP] => 2015-03-06T13:10:10Z
[CORRELATIONID] => 4ec125d8280f3
[ACK] => Failure
[VERSION] => 121
[BUILD] => 15640276
[L_ERRORCODE0] => 10410
[L_SHORTMESSAGE0] => Invalid token
[L_LONGMESSAGE0] => Invalid token.
[L_SEVERITYCODE0] => Error
)
感谢您在这方面帮助我!
【问题讨论】:
那个“奇怪的字符”是 &CURREN,因为您将整个字符串解码为单个查询字符串值。 【参考方案1】:我知道这个问题已经有一年多了,但我认为值得回答。
首先,根据您在数组中显示的内容,令牌无效的响应是准确的:
TOKEN=EC-0PA6125744246545G&TIMESTAMP=2015-03-06T13:10:09Z&CORRELATIONID=10c7929423b68&ACK=Success&VERSION=121&BUILD=15640276
这应该在与号 (&) 处停止,如下所示,$response
数组可以像这样访问,以将单个值传递到您的下一个 API 请求中:
$response["TOKEN"]; // this will ONLY return "EC-0PA6125744246545G" - remember that
// these tokens don't last beyond a few hours, but your next call should be
// a few seconds after the SetEC.
解析处理特定方法:http_build_query()
// this is a method in a class that I built. Use it as needed
public function startRequest($params = array())
// this creates a handle to use later to add the request parameters to the curl call
$request = http_build_query($params);
$ch = curl_init();
// cURL settings
// the variable $this->_endpoint in this case points to:
// https://api-3t.sandbox.paypal.com/nvp - you may be using SOAP,
// so URL will be different
$curlOptions = array(
CURLOPT_URL => $this->_endpoint,
CURLOPT_VERBOSE => 1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $request
);
curl_setopt_array($ch, $curlOptions);
// send request - $response will hold the API response
$response = curl_exec($ch);
$response
变量是来自 PayPal 的数组响应,可以这样使用:
$responseText = '';
foreach($response as $k=>$v)
$responseText .= $k ."=". $v ."\r\n";
// log the API response (and the request) to a file - always a good idea,
// in case you need support for issues later on.
file_put_contents(path_to_log_file, current_time . ' MST - API response: \r\n' . $responseText ."\r\n===========\r\n", FILE_APPEND);
// also, you can access each value in the $response array so that you can use them
// in later calls like DoEC:
$response["TOKEN"];
如果我可以进一步澄清任何事情,请告诉我。
【讨论】:
以上是关于支付宝错误。此交易无效。请返回收款人的网站以使用他们的常规结账流程完成您的交易的主要内容,如果未能解决你的问题,请参考以下文章