PHP Shopping site Payment PayPal How to use _php tutorial

Source: Internet
Author: User
Tags form post
Detailed reference:

Https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_ Websitestandard_htmlvariables

Defining Constants Paypalurl

Const PAYPAL_URL = ' https://www.sandbox.paypal.com/';

The data to be transferred is recorded as an array

$paypalData = Array (
' Add ' = 1,
' cmd ' = ' _ext-enter ',
' Redirect_cmd ' = ' _xclick ',
' Business ' = $paypalAccount,--------liangliangfeng211@gmail.com This is the payee's PayPal account
' Item_name ' = ' 51customimprint shopping cart ',
' Item_Number ' = $order->id,
' First_Name ' = $address->first_name,
' Last_Name ' = $address->last_name,
' Address1 ' = $address->address1,
' City ' = $address->city,
' state ' = $address->state_or_province,
' Zip ' = $address->zip_code,
' Amount ' = $order->subtotal,
' Shipping ' = $order->shipping_fee,
' No_note ' = 1,
' Currency_code ' = ' USD ',
' LC ' = = ' US '
);

Convert this array to a URL address

$paypalArguments = Array ();
foreach ($paypalData as $k = = $v) {
Array_push ($paypalArguments, $k. '=' . UrlEncode ($v));
}
$paypalUrl = self::P aypal_url. '?' . Implode (' & ', $paypalArguments);
$this->_redirect ($PAYPALURL);

Next, when we test, we should set the address of the PayPal interface to:

Https://www.sandbox.paypal.com/cgi-bin/webscr

The basic process
When the customer pays you, PayPal sends a notification to the server at the specified URL (type= "hidden" name= "Notify_url" value= "). This notification will include all of your customer's payment information (for example, customer name, amount), and a piece of encryption code. When the server receives a notification, it then sends the information (including the encryption code) back to the secure PayPal URL. PayPal will authenticate the transaction by checking the encrypted string. This transfer of IPN data back to PayPal prevents "spoofing", so you can ensure that IPN comes from PayPal. At the time of verification, PayPal will send a confirmation of its legitimacy back to your server.

tip : To enable instant payment notifications, you will need to enter a URL through which you can receive notifications from your user information.

With instant payment notifications enabled, each time you receive a payment, your server receives a notification that it will be sent to the specified URL as a hidden "form POST" and will include all payment information. The FORM variable for the notification is listed at the bottom of this page.

Each time you receive IPN from PayPal, you must complete the notification confirmation process as described below before implementing the order. Confirming the information listed will ensure that the transaction is legal.

Notification Confirmation IPN
To ensure that the payment has entered your PayPal account, you must verify that the e-mail address used as "Receiver_email" has been registered and confirmed in your PayPal account.

After the server receives an instant payment notification, you will need to confirm it by building an HTTP POST sent to PayPal. Your POST should be sent to HTTPS://WWW.PAYPAL.COM/CGI-BIN/WEBSCR

You must send all received form variables exactly as they were when you received the form variable. You will also need to append a variable named "_notify-validate" with a value of "cmd" (for example, Cmd=_notify-validate) to the POST string.

PayPal will reply to the POST and include a word "verified" or "INVALID" in the body of the reply. When you receive a verified reply, you need to perform several checks before the order is implemented:

Verify that "Payment_status" is "completed" because the system also sends IPN for other results, such as "Pending" or "Failed".
Check if "txn_id" is not duplicated to prevent fraudsters from reusing old, completed transactions.
Verify that "Receiver_email" is an email address that has been registered in your PayPal account to prevent payment from being sent to the fraudster's account.
Check other transaction details (such as item number and price) to confirm that the price has not changed after you have completed the above checks, you can use the IPN data to update your database and process your purchases.
If an "invalid" notification is received, it should be treated as a suspicious notification and should be investigated.

http://www.bkjia.com/PHPjc/322638.html www.bkjia.com true http://www.bkjia.com/PHPjc/322638.html techarticle Detailed reference: Https://cms.paypal.com/us/cgi-bin/?cmd=_render-content the data to be transmitted is recorded as an array $paypalData = Array (' Add ' = 1, ' cmd ' = ' _ext-enter ', ' redirect_cm ...

  • 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.