PayPal IPN支付网关
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PayPal IPN支付网关相关的知识,希望对你有一定的参考价值。
<?php // for live // $url = "https://www.paypal.com/cgi-bin/webscr"; // for sandbox $url = "https://www.sandbox.paypal.com/cgi-bin/webscr"; ?> <form name="paypal_ipn" action="<?php echo $url ?>" method="POST"> <input type="hidden" name="upload" value="1" /> <input type="hidden" name="cmd" value="_cart" /> <!-- The business email address, where you want to receive the payment --> <input type="hidden" name="business" value="[email protected]" /> <!-- The customer email address --> <input type="hidden" name="receiver_email" value="[email protected]" /> <input type="hidden" name="item_name_1" value="test product" /> <input type="hidden" name="quantity_1" value="1" /> <input type="hidden" name="amount_1" value="25.58" /> <input type="hidden" name="currency_code" value="USD" /> <input type="hidden" name="invoice" value="12345" /> <input type="hidden" name="amount" value="25.58" /> <!-- Where you want to return after PayPal Payment --> <input type="hidden" name="return" value="http://www.yoursite.com/finished.php" /> <!-- A back-end notification send to the specific page after successful payment --> <input type="hidden" name="notify_url" value="https://www.yoursite.com/finished_secure.php" /> <!-- Where you want to return after cancel the PayPal Payment --> <input type="hidden" name="cancel_return" value="http://www.yoursite.com" /> <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" border=0 /> </form> ============================ Start finished_secure.php file =============================== <?php $req = 'cmd=_notify-validate'; foreach($_POST as $key => $value) { $req .= "&$key=$value"; } $header .= "POST /cgi-bin/webscr HTTP/1.0 "; $header .= "Content-Type: application/x-www-form-urlencoded "; "; //$url = "ssl://www.paypal.com"; // for live $url = "ssl://www.sandbox.paypal.com"; // for sandbox $paypal_payment_amount = $_POST['mc_gross']; //print_r($_POST); To print all the variables get form PayPal if(!$fp){ echo "PayPal socket not opened."; } else{ // write any code to here } // error } } // end while } ?> ============================== End finished_secure.php file =================================
以上是关于PayPal IPN支付网关的主要内容,如果未能解决你的问题,请参考以下文章
Paypal 沙盒 IPN 模拟器 - 502 Bad Gateway