贝宝:将电子邮件地址传递给退货/“谢谢";页 [英] PayPal: pass the email address to the return/"thank you" page

查看:21
本文介绍了贝宝:将电子邮件地址传递给退货/“谢谢";页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 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 变量包含一个交易号,您可以使用它发送到 Paypal 服务器的 post 请求并检索交易信息.

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 帐户中有一个设置,您需要启用并设置重定向 URL 才能使其工作.

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:

这里是一个如何解析向Paypal发送post请求并解析数据的示例.我只是从旧文件中挖掘出来的.所以不能保证它有效.这是基于 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
";
$header .= "Content-Type: application/x-www-form-urlencoded
";
$header .= "Content-Length: " . strlen($req) . "

";
$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, "
") == 0) {
            $headerdone = true;
        }
        else if ($headerdone) {
            $res .= $line;
        }
    }

    $lines = explode("
", $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;

这篇关于贝宝:将电子邮件地址传递给退货/“谢谢";页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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