PayPal:将电子邮件地址传递给返回/“谢谢"邮件地址.页 [英] PayPal: pass the email address to the return/"thank you" page
问题描述
我已经使用 PayPal IPN和一个监听器.该按钮本身是向导生成的.
I've successfully created a small "pay now" button with PayPal IPN and a listener. The button itself is wizard-generated.
付款后,用户将重定向到我的主机上的退货/谢谢"页面.
After the payment, the user is redirected to a return/"thank you" page on my host.
一切正常,但是我也需要在谢谢"页面上收到客户的电子邮件:我该怎么办?
Everything works as expected, but I need to receive the customer e-mail on the "thank you" page too: how can I do that?
推荐答案
您可以使用付款数据传输"(PDT)获取用户电子邮件,该数据发送一个名为tx
的GET变量到您的重定向URL.
You can get the user email using the Payment Data Transfer (PDT), which sends a GET variable named tx
to your redirect url.
tx
变量包含一个交易号,您可以使用该交易号将其发送到贝宝服务器的过帐请求并检索交易信息.
The tx
variable contains a transaction number which you can use to send to a post request to Paypal's server and retrieve the transaction information.
我上次使用PDT是一年前的,但是我相信您的Paypal帐户中需要启用并设置重定向网址才能使设置正常工作.
The last time I used PDT was a year ago, but I believe there is a setting in your Paypal account that you need to enable and set a redirect url for this to work.
以下是一些链接,它们更详细地描述了PDT:
Here are some links that describes PDT in further detail:
- https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/pdt-techview-outside
- https://cms.paypal .com/us/cgi-bin/?cmd = _render-content& content_ID = developer/howto_html_paymentdatatransfer
- https://www.paypal.com/us/cgi-bin/webscr?cmd=p/xcl/rec/pdt-techview-outside
- https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_html_paymentdatatransfer
这里是如何解析向Paypal发送发帖请求并解析数据的示例.我只是从一个旧文件中挖出来的.因此,不能保证它会起作用.这是基于Paypal用作php示例的脚本的.您可以改用curl,那可能是更好的选择.我认为使用fsockopen存在某种安全性问题.
Here is an example of how to parse send a post request to Paypal and parse the data. I just dug this up from an old file. So no guarantees that it works. This is based off a script that Paypal uses as an example for php. You can use curl instead, and that's probably the better choice. I think there is some kind of security issue with using fsockopen.
//Paypal will give you a token to use once you enable PDT
$auth_token = 'token';
//Transaction number
$tx_token = $_GET['tx'];
$payPalUrl = ( $dev === true ) ? 'ssl://www.sandbox.paypal.com' : 'ssl://www.paypal.com';
$req = 'cmd=_notify-synch';
$req .= "&tx=$tx_token&at=$auth_token";
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ($payPalUrl, 443, $errno, $errstr, 30);
$keyarray = false;
if ( $fp ) {
fputs ($fp, $header . $req);
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
$headerdone = true;
}
else if ($headerdone) {
$res .= $line;
}
}
$lines = explode("\n", $res);
if (strcmp ($lines[0], "SUCCESS") == 0) {
//If successful we can now get the data returned in an associative array
$keyarray = array();
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
}
}
fclose ($fp);
return $keyarray;
这篇关于PayPal:将电子邮件地址传递给返回/“谢谢"邮件地址.页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!