下面的代码基于Drupal 7中的Webform PayPal集成上的示例
$paypal = array();
$paypal['cmd'] = '_xclick';
$paypal['business'] = variable_get('event_reg_paypal_address');
$paypal['receiver_email'] = $paypal['business'];
$paypal['page_style'] = 'huang_checkout';
$paypal['amount'] = variable_get('event_reg_paypal_cost');
$paypal['currency_code'] = 'GBP';
$paypal['item_name'] = 'Test Event Registration';
$paypal['tax'] = 0;
$paypal['custom'] = $submission->sid;
$paypal['return'] = $base_url.'/test/thanks';
$paypal['notify_url'] = $base_url.'/test/thanks';
$paypal['cancel_return'] = $base_url;
$paypal['first_name'] = //first name from submission
$paypal['country'] = 'UK';
$query = http_build_query($paypal, '', '&');
$url = $paypal_host . $query;
drupal_goto($url);它是自定义模块代码的一部分,实现了hook_webform_submission_insert()。当表单提交时,$url变量是从$paypal数组构建的,然后用户的浏览器重定向到,例如,
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=pete27_11_94-facilitator%40hotmail.com&receiver_email=pete27_11_94-facilitator%40hotmail.com&page_style=huang_checkout&amount=0.01&currency_code=GBP&item_name=Test+Event+Registration&tax=0&custom=24&return=http%3A%2F%2Fwww.pitmart.com%2Fformulak%2Ftest%2Fthanks&notify_url=http%3A%2F%2Fwww.pitmart.com%2Fformulak%2Ftest%2Fthanks&cancel_return=http%3A%2F%2Fwww.pitmart.com%2Fformulak&first_name=sdfgsdfg&country=UK
在我的paypal开发人员帐户中,有一个用户的电子邮件地址,如url,类型为business,但每次提交时我都会收到错误消息。
We cannot process this transaction because there is a problem with the PayPal email address supplied by the seller. Please contact the seller to resolve the problem. If this payment is for an eBay listing, you can contact the seller via the "Ask Seller a Question" link on the listing page. When you have the correct email address, payment can be made at www.paypal.com.
我在一个现场服务器上进行测试,不是无法访问的本地服务器。
我原以为会被带到paypal登录表单,但只是得到错误。
是否有可能以这种方式将数据传递给paypal?(直接放在网址中,而不是由表格“张贴”)
我是否遗漏了一些会导致此失败的变量/数据?是否有列出此类paypal请求的最小配置的文档?
编辑-缺少了currency_code。自添加后,仍在接收错误。
发布于 2013-08-15 12:27:45
问题是,您正在对所有内容进行URL编码,包括应该分离值的符号。
也就是说,这很好:name=sdfgsdfg&country=UK
顺便说一句,“英国”不是一个有效的国家。PayPal国家代码遵循ISO 3166-2,因此应该是“GB”。
https://stackoverflow.com/questions/18228196
复制相似问题