【问题标题】:PayPal: pass the email address to the return/"thank you" pagePayPal:将电子邮件地址传递到退货/“谢谢”页面
【发布时间】:2012-04-15 03:57:49
【问题描述】:

我已经使用PayPal IPN and a listener 成功创建了一个小的“立即付款”按钮。按钮本身是由向导生成的。

付款后,用户被重定向到我主机上的退货/“谢谢”页面。

一切正常,但我还需要在“谢谢”页面上收到客户的电子邮件:我该怎么做?

【问题讨论】:

    标签: php paypal e-commerce paypal-ipn


    【解决方案1】:

    您可以使用支付数据传输 (PDT) 获取用户电子邮件,它会将名为 tx 的 GET 变量发送到您的重定向网址。

    tx 变量包含一个交易号,您可以使用该交易号发送到 Paypal 服务器的发布请求并检索交易信息。

    我上一次使用 PDT 是一年前,但我相信您的 Paypal 帐户中有一个设置需要启用并设置重定向 URL 才能使用。

    以下是一些更详细地描述 PDT 的链接:

    这是一个如何解析发送到 Paypal 的 post 请求并解析数据的示例。我只是从一个旧文件中挖掘出来的。所以不能保证它有效。这是基于 Paypal 用作 php 示例的脚本。您可以改用 curl,这可能是更好的选择。我认为使用 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      • 2017-07-28
      • 1970-01-01
      • 2016-12-22
      • 2011-09-19
      • 2023-04-05
      • 1970-01-01
      相关资源
      最近更新 更多