贝宝:将电子邮件地址传递给退货/“谢谢";页

2023-06-23php开发问题
7

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

问题描述

我已经使用 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:

  • 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发送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;

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

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17