PHP integrated PayPal standard Payment, PHP integrated PayPal standard _php Tutorial

Source: Internet
Author: User
Tags strcmp

PHP integrated PayPal standard Payment, PHP integrated PayPal standard


PayPal payment feature has actually been updating the document and interface, here is a simple payment function is probably the following process

1, in the checkout page of the website, set up a form to submit to the PayPal website, there are some amount, product name, merchant collection account number, the return URL after the successful checkout, etc.

2, when the user checkout, by clicking the ' Use PayPal Checkout ' button to reach the PayPal checkout page, enter their own PayPal username and password and confirm payment

3,paypal will decide which page to return to the site based on the success of the payment, and in the background to the site of a page to initiate a POST request, this action is called IPN, tell the website the payment of the account, such as completed to complete the payment

4, the website receives the PayPal notify notice, can give the user the delivery or other processing logic

Here's a picture to explain

A simpler flowchart

We want to complete the process, in fact, only need two pages to deal with

Record the code:

checkout.php This page can actually be HTML

  

This form contains some items that must be added by PayPal, and it is important to note that notify.php is the one that PayPal will call in the background.
notify.php This page has two functions, one is to receive PayPal post content and tagged return, one is to receive the authentication information of PayPal after the internal logic processing
$req = ' cmd=_notify-validate '; foreach ($_post as $key = $value) {$value = UrlEncode (stripslashes ($value)); $req. = "& $key = $value";}//POST BA CK 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);  if (! $fp) {//HTTP ERROR} else {//http OK fputs ($fp, $header. $req), while (!feof ($fp)) {$res = Fgets ($fp, 1024x768); if (strcmp ($res, "verified") = = 0) {//process Business of website} else if (strcmp ($res, "INVALID") = = 0) {//Log for Manual Investigation}} fclose ($fp ); }

  

http://www.bkjia.com/PHPjc/1100147.html www.bkjia.com true http://www.bkjia.com/PHPjc/1100147.html techarticle PHP integrated PayPal standard Payment, PHP integrated PayPal standard PayPal payment feature has actually been updated in the document and interface, here is said to be a simple payment function probably flow below 1, in the net ...

  • Related Article

    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.