gpt4 book ai didi

php - iPhone SDK 付款后,我的 php IPN 回调中缺少 POST 参数

转载 作者:太空宇宙 更新时间:2023-11-03 16:36:24 24 4
gpt4 key购买 nike

我正在使用适用于 iOS 的 Paypal SDK 1.6。我有一个 IPN 回调 php 脚本,当我从 IPN Paypal 模拟器测试时,它工作正常(付款已验证)当我从 iPhone 付款测试时,我缺少一些 POST 参数。

编辑:代码

<?php
// Revision Notes
// 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr
// For more info see below:
// https://www.x.com/content/bulletin-ip-address-expansion-paypal-services
//"ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following:
// To continue posting back to https://www.paypal.com to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
// OR Alternatively, you will need to modify your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."


// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';

foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}

// post back to PayPal system to validate

$header = "POST /cgi-bin/webscr HTTP/1.0\r\n";

// If testing on Sandbox use:
$header .= "Host: www.sandbox.paypal.com:443\r\n";
//$header .= "Host: ipnpb.paypal.com:443\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";

// If testing on Sandbox use:
$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);
//$fp = fsockopen ('ssl://ipnpb.paypal.com', 443, $errno, $errstr, 30);

// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment

$mail_From = "From: me@mybiz.com";
$mail_To = "testenter code here@gmail.com";
$mail_Subject = "VERIFIED IPN";
$mail_Body = $req;

mail($mail_To, $mail_Subject, $mail_Body, $mail_From);


}
else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation

$mail_From = "From: me@mybiz.com";
$mail_To = "test@gmail.com";
$mail_Subject = "INVALID IPN";
$mail_Body = $req;

mail($mail_To, $mail_Subject, $mail_Body, $mail_From);

}
}
fclose ($fp);
}
?>

最佳答案

沙盒中的 IPN 模拟 Express Checkout 交易,这与您使用移动支付库获得的交易类型不同。

您可能得到的一个项目是 PayKey。使用 PayKey,您可以对 PaymentDetails API 进行第二次 API 调用,这应该会产生您要查找的其余信息。

引用:Payment Details API

关于php - iPhone SDK 付款后,我的 php IPN 回调中缺少 POST 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12971862/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com