- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试在我的网站上实现 PayPal 直接付款。
我在调用 SetExpressCheckout 时从 PayPal 获得了一个 Succes token :
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&TRA NSACTIONID=29A40018PU668530B
我尝试以多种方式对 url 进行 depercent 处理,以将响应发送回 top paypal。我现在使用的是:
$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=29A4001 8PU668530B
我尝试用 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 重定向发回 token 时,(有或没有小写):
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= ...
说:
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow. Return to merchant At this time, we are unable to process your request. Please return to and try another option. Test Site
即使我使用非小写版本,我也会遇到同样的错误!
我意识到 localhost 是个问题。上传我的网站时,SetExpressCheckout token 没问题。
现在的问题是当我取回这个 token 时: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
)
我仍然收到 token 错误:
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
)
谢谢你帮我解决这个问题!
最佳答案
我意识到这个问题已有一年多了,但我认为它值得回答。
首先,根据您在数组中显示的内容, token 无效的响应是准确的:
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"];
让我知道是否可以进一步澄清。
关于 Paypal 错误。此交易无效。请返回收款人的网站,使用他们的常规结帐流程完成您的交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28896985/
我希望有不同的 Paypal 收款人,具体取决于正在查看的 URL 并使用直接结帐,以便用户永远不会离开我的网站。因此,例如,在 example.com/brandA 上,有人可以购买 brandA
我正在尝试使用 Active Merchant 集成 Paypal 自适应结账功能和 active_paypal_adaptive_payment gem 。 我有完全相同的问题已发布 here .我
我是一名优秀的程序员,十分优秀!