【发布时间】:2020-08-26 01:33:54
【问题描述】:
尝试实现Paypal即时支付通知https://developer.paypal.com/docs/ipn/#use-ipn-in-your-checkout-flow
情况如下:
1) 访问者想要访问数据库(访问者输入一些东西来检查输入的数据是否存在于数据库中)
2)我收集访问者输入的数据,记录在mysql中,创建一些token,也记录在mysql中
3) 将令牌添加到数据中,我发送到贝宝。
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 响应中取回令牌?
【问题讨论】: