Home > Backend Development > PHP Tutorial > Paypal instant payment php implementation code_PHP tutorial

Paypal instant payment php implementation code_PHP tutorial

WBOY
Release: 2016-07-21 15:33:33
Original
1060 people have browsed it

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 in ecshop paypal payment code

This code is submitted to the paypal payment interface
{{{

//Merchant’s registered email address


}}}

The following is officially provided, accepted to the parameters returned by paypal, and determine whether the payment was successful.

After successful support, the submission form contains




paypal will automatically jump to the page epond.php?code=paypal, which can display some data obtained by the following POST.



Copy code The code is 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.0rn";
$header .= "Content-Type: application/x-www-form-urlencodedrn";
$header .= "Content-Length: " . strlen($req ) . "rnrn";
$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);
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322630.htmlTechArticlehttp://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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template