ページにペイパルボタンがあります。ペイパルボタン付きの2つのカスタムフィールドがあります。ipn.phpページでIPN応答を取得しています。このコードはペイパルサイトから入手しました。
SandBoxを使用してテストしている場合、支払いは購入者のアカウントから差し引かれ、販売者のアカウントに預け入れられます。ただし、以下のコードで最後に説明したデータベーステーブルにはデータが挿入されません。また、「カスタム」という名前の単一の変数で両方の変数値を送信しようとしましたが、それでもうまくいきません。私のコードを確認して、私が何を間違っているのか教えてください。過去2日間苦労しているので、助けてください。
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
$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'];
$custom_memname = $_POST['custom_memname']; // This is 1st custom variable
$custom_mempass = $_POST['custom_mempass']; // This is 2nd custom variable
$str_query_insert="insert into t_fmember(memberid,password) values('" .$custom_memname."','".$custom_mempass."')";
ExecuteQuery($str_query_insert);
}
このコードをipn.phpページに追加し、IPNシミュレーターを使用しましたが、まだ応答がありません。
$post_data_string = serialize($_POST);
mail('mymail@yahoo.com', 'PayPal IPN', $post_data_string);
可能であればさらに助けてください。ありがとうございました