PHP Access PayPal payment

Source: Internet
Author: User

First step, open https://www.paypal.com/official website, apply for a PayPal account.
Second step, login account, and enter https://developer.paypal.com/developer/accounts/. You can see that you apply for the automatic attachment of two test accounts, account categories are: Business and Personal,personal's account has $9999.
Third step, to set the password for two accounts, click the account to expand, and then click Profile, Pop-up account information box, set password and other attributes.
Step Fourth, write the following code in the Project payment page
(PayPal's test environment domain name is www.sandbox.paypal.com, the official domain name is www.paypal.com.) )

<form action= "HTTPS://WWW.PAYPAL.COM/CGI-BIN/WEBSCR" method= "POST" name= "PayPal" >

<input type= "hidden" name= "cmd" value= "_xclick" > <input type= "hidden" name= "Business" value= "PayPal Collection Account" > <input type= "hidden" name= "Item_name" value= "Product name-PCB Online Payment" > <input type= "hidden" name= "Item_Number "Value=" can be written to the order ID (alternate) "> <input type=" hidden "name=" Cancel_return "value=" Cancel payment return URL "> <input type=" Hidde N "name=" Notify_url "value=" payment complete return URL "> <input type=" hidden "name=" return "value=" payment complete returns URL "> <!--currency type, USD is USD--> <input type= "hidden" name= "Currency_code" value= "USD" > <!--payment amount--> <input type= "hidden" NA Me= "Amount" value= "8.88" > <input type= "Submit" value= "Pay Now" class= "Sbtn4"/> </form> 

Step Fifth, process return information
confirms 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 e-mail address that has been registered in your PayPal account to prevent payment from being sent to the fraudster's account.
Check other transaction details (e.g. item number and price) to confirm that the price has not changed after the above inspection, you can use IPN data to update your database and handle shopping.
If an "invalid" notification is received, it should be treated as a suspicious notification and should be investigated.

/** * method to process return information * * Public Function notify () {if ($this->user_id = = False) {
        $this->redirect (' User/login ');
        } $result = $_post;
        $order _id = $result [' Item_Number '];
            if ($order _id) {$order = D (' order ')->find ($order _id);
            $this->assign (' Order_num ', $order [' order_num ']);
                1, the first update order status if (($order [' pay_status '] = = 0) && ($result [' payment_status '] = = ' Completed ')) {//Payment successful
            $this->update_order ($result); //2 To add payment records if ($order [' pay_status '] = = 0) {$this->add_payment_logs ($result)
            ;
        }} $this->assign (' order_id ', $order _id);
        $this->assign (' Payment_status ', $result [' payment_status ']);

        $this->assign (' Payment_gross ', $result [' Payment_gross ']);
        $this->assign (' Seo_title ', ' notify ');
    $this->display (); }

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.