Real-time paypal account php implementation code _ PHP Tutorial

Source: Internet
Author: User
The real-time php implementation code of paypal. Paypal.ebay.cnintegrationcenterlist?resource_2.html Chinese php development introduction: www.paypal-china.orgwangzhai197.html The following is the payment code of paypal in ecshop http://paypal.ebay.cn/integrationcenter/list__resource_2.html

Php development introduction: http://www.paypal-china.org/wangzhai/197.html
The following is the payment code for paypal in ecshop:

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



}}}

The following are officially provided parameters that are received by paypal and whether the payment is successful.

After successful submission




Paypal will automatically jump to espond. php? Code = paypal: The page shows the following POST data.



The code is as follows:


// Read the post from PayPal system and add 'cmd'
$ Req = 'cmd = _ policy-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 ";
$ 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 previusly 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 );
}
?>

Http://www.bkjia.com/PHPjc/322630.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322630.htmlTechArticlehttp://paypal.ebay.cn/integrationcenter/list__resource_2.html Chinese php development introduction: http://www.paypal-china.org/wangzhai/197.html below is the payment code of paypal in ecshop this code...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.