user460114
user460114

Reputation: 1848

Paypal checkout return data

I have a paypal button as follows:

<form id="fmPaypal" method="post" action= "https://www.sandbox.paypal.com/cgi-bin/webscr">
        <input type="hidden" name="cmd" value="_xclick">
        <input type="hidden" name="currency_code" value="NZD">
        <input type="hidden" name="business" value="[email protected]">
        <input type="hidden" name="item_name" value="Order">
        <input type="hidden" id="item_number" name="item_number" value="123">
        <input type="hidden" name="amount" value="0.01">
        <input type="hidden" name="no_shipping" value="1">
        <input type="hidden" name="return" value="http://www.blah.com/checkout/return.cfm" />
        <input type="hidden" name="cancel_return" value="http://www.blah.com/checkout/cancel" />
</form>

This works and users are redirected to paypal ready for payment.

But, should I expect to get some data returned from paypal via the return URL? e.g. results of the transaction? Or should I assume that the payment processed successfully if the user is redirected to the return url?

Tried getting this information from the docs without success.

Upvotes: 2

Views: 15516

Answers (2)

Telvin Nguyen
Telvin Nguyen

Reputation: 3559

https://developer.paypal.com/webapps/developer/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HI0709B

You have to enable the rm option on your form while you want to use return url

  • return(Optional) The URL to which PayPal redirects buyers' browser after they complete their payments. For example, specify a URL on your site that displays a "Thank you for your payment" page. Default – PayPal redirects the browser to a PayPal webpage. 1,024

  • rm: (Optional) Return method. The FORM METHOD used to send data to the URL specified by the return variable. Allowable values are:

0 – all shopping cart payments use the GET method

1 – the buyer's browser is redirected to the return URL by using the GET method, but no payment variables are included

2 – the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included The default is 0.

Note: The rm variable takes effect only if the return variable is set.

Here is reference document what IPN return

https://developer.paypal.com/webapps/developer/docs/classic/ipn/gs_IPN/

Then I quoted it here for convenient review

$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'];

you should have this document PDF already, but I think I should put it here also https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/ipnguide.pdf

Of cause I have to remind about the important thing, you have to enable "Auto Return" on your account

Auto Return is turned off by default. To turn on Auto Return:

Log in to your PayPal account at https://www.paypal.com. The My Account Overview page appears. Click the Profile subtab. The Profile Summary page appears. Click the My Selling Tools link in the left column. Under the Selling Online section, click the Update link in the row for Website Preferences. The Website Payment Preferences page appears Under Auto Return for Website Payments, click the On radio button to enable Auto Return. In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments. NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted or cannot be validated, PayPal will not activate Auto Return. Scroll to the bottom of the page, and click the Save button.

Upvotes: 12

Darkagelink
Darkagelink

Reputation: 645

The user will complete or cancel the payment on the PayPal platform and is redirected back to your website;

they complete the payment either when the user is redirected back or via an Instant Payment Notification (IPN).

Upvotes: 2

Related Questions