0
paypalプロセスが成功した直後(リダイレクトされたページ上)にユーザー情報(電子メール)とpaypal請求情報(価格、数量)を取得してから、mysqlに挿入したい表。paypalフォームにカスタムフィールドを追加してリダイレクトページに追加
私もボタンすぐに購入<input type="hidden" name="notify_url">
を使用して、値の例です設定:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="lf2">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="xxxxx">
<input type="hidden" name="custom">
<input type="hidden" name="notify_url">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
$notify_url='http://mysite.com/ipn/index.php?order_sld=123';
<script language="javascript">
document.getElementsByName('custom').value='123';
document.getElementsByName('notify_url').value='<?=$notify_url?>';
document.forms['lf2'].submit();
</script>
と私のIPN/index.phpのスクリプトは次のとおりです。
function FetchOrder()
{
$array = array();
$array['transactionID']=$_POST["txn_id"];
$array['item']=$_POST["item_name"];
$array['amount']=$_POST["mc_gross"];
$array['currency']=$_POST["mc_currency"];
$datefields=explode(" ",$_POST["payment_date"]);
$array['time']=$datefields[0];
$array['date']=str_replace(",","",$datefields[2])." ".$datefields[1]." ".$datefields[3];
$array['timestamp']=strtotime($array['date']." ".$array['time']);
$array['status']=$_POST["payment_status"];
$array['firstname']=$_POST["first_name"];
$array['lastname']=$_POST["last_name"];
$array['email']=$_POST["payer_email"];
$array['custom']=$_POST["option_selection1"];
$array['sld']=$_POST["notify_url"];
if ($array['transactionID'] AND $array['amount']) {
return send_email($array);
} else {
return 0;
}
}
/**
* Send email
*/
function send_email($array)
{
$to = "[email protected]";
$email = "[email protected]";
$name = "Sajid";
$subject = "Testing Paypal IPN";
$msg = "<table>
<tr><td>Transaction ID: </td><td>".$array['transactionID']."</td></tr>
<tr><td>Item: </td><td>".$array['item']."</td></tr>
<tr><td>Amount: </td><td>".$array['amount']."</td></tr>
<tr><td>Currency: </td><td>".$array['currency']."</td></tr>
<tr><td>Time: </td><td>".$array['time']."</td></tr>
<tr><td>Date: </td><td>".$array['date']."</td></tr>
<tr><td>Timestamp: </td><td>".$array['timestamp']."</td></tr>
<tr><td>Status: </td><td>".$array['status']."</td></tr>
<tr><td>First Name: </td><td>".$array['firstname']."</td></tr>
<tr><td>Last Name: </td><td>".$array['lastname']."</td></tr>
<tr><td>Email: </td><td>".$array['email']."</td></tr>
<tr><td>Custom: </td><td>".$array['custom']."</td></tr>
<tr><td>SLD: </td><td>".$array['sld']."</td></tr>
</table>";
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= "From: $name <$email>" . "\r\n";
// Mail it to client.
mail($to, $subject, $msg, $headers);
return 1;
}
FetchOrder();
が、メールのみ含まれています
Transaction ID: 6BD19776WW7238524
Item:
Amount: 12.00
Currency: USD
Time: 04:04:21
Date: 05 Jan 2012
Timestamp: 1325761461
Status: Completed
First Name: ABC
Last Name: XYZ
Email: [email protected]
Custom:
SLD:
どうしたらいいのか教えてください...