[英]PayPal IPN POST results in 0 PHP Laravel
I'm struggling with a simple storage script that should be called via PayPal IPN to save the current payment.我正在努力使用一个简单的存储脚本,该脚本应该通过 PayPal IPN 调用以保存当前付款。
I'm using我正在使用
$input = json_encode($request->all());
$paylog = Paylog::create([
'data' => $input,
]);
and the result from any incoming POST is always "0".并且任何传入 POST 的结果始终为“0”。
Where is my fault?我的错在哪里?
Perhaps you mean to access $_POST
也许您的意思是访问$_POST
IPN messages should be verified with a postback to ipnpb.paypal.com before doing anything with their contents在对其内容进行任何操作之前,应通过回发到 ipnpb.paypal.com 来验证 IPN 消息
IPN is a very old and clunky technology, why are you using it? IPN 是一项非常古老且笨重的技术,您为什么要使用它?
To obtain details on a 'current' payment, you should be using an API like v2/checkout/orders to facilitate the checkout.要获取有关“当前”付款的详细信息,您应该使用像 v2/checkout/orders 这样的 API 来方便结帐。 For this you need two routes on your server, one for 'Set Up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/为此,您的服务器上需要两条路线,一条用于“设置交易”,一条用于“捕获交易”,记录在此处: https : //developer.paypal.com/docs/checkout/reference/server-integration/
The best approval flow to pair with your two routes is https://developer.paypal.com/demo/checkout/#/pattern/server与您的两条路线配对的最佳审批流程是https://developer.paypal.com/demo/checkout/#/pattern/server
Solution:解决方案:
//Make sure encode values to UTF8
$input = json_encode(array_map('utf8_encode',$request->all()));
//And store
$paylog = Paylog::create([
'data' => $input,
]);
Or to make things a little more efficient:或者让事情变得更有效率:
$paylog = Paylog::create([
'data' => $json_encode(array_map('utf8_encode',$request->all())),
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.