繁体   English   中英

Paypal 即时付款通知需要将付款人订单与付款匹配

[英]Paypal Instant Payment Notification need to match payer order with payment

尝试实施 Paypal 即时付款通知https://developer.paypal.com/docs/ipn/#use-ipn-in-your-checkout-

情况如下:

1)访问者想要访问数据库(访问者输入一些东西来检查输入的数据是否存在于数据库中)

2)我收集访客输入的数据,记录在mysql,创建一些token,也记录在mysql

3)将令牌添加到数据中,我发送到 paypal。

4) 付款成功后,我允许访问者访问数据库并显示访问者输入数据的结果。 所以需要知道访客输入/订购了什么。

到 Paypal 我发送这样的数据:

$data['return'] = 'https://www.my-website.info/payment-successful.php?response='. $token_to_send_to_paypal;//here we can put URL when payment is Successful.
$data['cancel_return'] = 'https://www.my-website.info/payment-cancelled.php';//here we can put cancel URL when payment is not completed.
$data['notify_url'] = 'https://www.my-website.info/payment-notify.php';//PayPal call this file for ipn
$data['item_number'] = $token_to_send_to_paypal;

然后

$query_string = http_build_query($data);//http_build_query — Generate URL-encoded query string

然后重定向到 paypal IPN

header( 'location:'. $paypal_url. '?'. $query_string );

从 Paypal 成功付款后,我得到了一些数据。 我看到我得到了item_number=the same as token i created sent to paypal

以上是目前我可以将访客的订单与付款相匹配的唯一方法。 但可能的(?)问题是访问者也知道令牌。

任何想法/更好的方法如何将访客的订单与付款相匹配? 我的意思是如何将我的令牌发送到 Paypal 并在 Paypal 响应中取回令牌?

但可能的(?)问题是访问者也知道令牌。

为什么这是个问题? 这不是问题。 访问者无法创建可验证的 IPN。

真正的答案是您应该切换到更好的结帐方式,并且根本不使用 IPN,因为这样您就不需要它了。 这是一个更好的结帐: https://developer.paypal.com/demo/checkout/#/pattern/server

有了更好的结帐,这里是您将从服务器调用的捕获 API: https://developer.paypal.com/docs/cap-checkout/reference//server-integration

这样就不需要 IPN。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM