PayPal returns data back to your site via what they call IPN. Its really just a callback to a URL you specify.
You can set this URL via the variable notify_url you can send to PayPal.
Example:
<input name="notify_url" value="http://yourdomain.com/notify_url.php" type="hidden">
The notify_url.php in the example above receives some POST variables from PayPal when the payment is completed, even if the customer never returns to your website.
Some of the important variables returned by PayPal is:
- mc_gross
- invoice
- settle_amount
- protection_eligibility
- address_status
- payer_id
- tax
- address_street
- payment_date
- payment_status
- charset
- address_zip
- mc_shipping
- mc_handling
- first_name
- mc_fee
- address_country_code
- exchange_rate
- address_name
- notify_version
- settle_currency
- custom
- payer_status
- business
- address_country
- address_city
- verify_sign
- payer_email
- txn_id
- payment_type
invoice is returned if you set it. It can be used as your own order-id/transaction-id.
txn_id is generated by PayPal and it is their own id for the transaction.
If you add items yourself you will PayPal also returns num_cart_items, item_name1 (item_name2, item_name3), quantity1 (quantity2, quantity3) and such.
More reading at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
Of course then you still have the problem to solve, how to check all this data and connect it to a customer in your own database, which you probably have.
What I do is to save a temporary "order" before I send the customer to PayPal with a invoice id, same id i send to PayPal as invoice. This way my notify_url.php page can check my database for a invoice id and compare the order/payment.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…