Http://paypal.ebay.cn/integrationcenter/list__resource_2.html
Introduction to Chinese PHP Development: http://www.paypal-china.org/wangzhai/197.html
The following is the PayPal payment code in Ecshop
This code is submitted to the PayPal payment interface
{{{
<form target= "_blank" method= "post" action= "HTTPS://WWW.PAYPAL.COM/CGI-BIN/WEBSCR" style= "Text-align:center"; ><input type= "hidden" value= "_xclick" name= "cmd"/><input type= "hidden" value= "xfuajiao@hotmail.com" name = "Business"/>//Merchant registered mailbox
<input type= "hidden" value= "2009102370175" "Name=" Item_name "/><input type=" hidden "value=" 2888.00 "Name=" Amount "/><input type=" hidden "value=" USD "name=" Currency_code "/><input type=" hidden "value=" http:// 127.0.0.1/ecshop/respond.php?code=paypal "Name=" return "/><input type=" hidden "value=" 3 "name=" Invoice "/> <input type= "hidden" value= "Utf-8" Name= "CharSet"/><input type= "hidden" value= "1" name= "no_shipping"/> <input type= "hidden" value= "name=" No_note "/><input type=" hidden "value=" http://127.0.0.1/ecshop/ Respond.php?code=paypal "Name=" Notify_url "/><input type=" hidden "value=" 2 "name=" rm "/><input type=" Hidden "value=" http://127.0.0.1/ecshop/"name=" Cancel_return "/><input type=" submit "value=" pay immediately using PayPal "/ ></form>
}}}
The following is an official offer to receive the parameters from PayPal and determine if payment is successful.
Support was successful after the submission of the form
<input type= "hidden" value= "Http://127.0.0.1/ecshop/respond.php?code=paypal" name= "return"/>
PayPal will take the initiative to jump to espond.php?code=paypal this page, the page can be real below the post obtained some data.
Copy Code code as follows:
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";
$header. = "content-type:application/x-www-form-urlencoded\r\n";
$header. = "Content-length:". Strlen ($req). "\r\n\r\n";
$fp = Fsockopen (' ssl://www.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
}
else if (strcmp ($res, "INVALID") = = 0) {
Log for manual investigation
}
}
Fclose ($FP);
}
?>