How to redirect after payment using PayPal's j

2019-04-17 02:18发布

问题:

Here's my script tag:

<script src="/data/js/paypal-button.min.js?merchant=MERCHANT_CODE"
    data-button="subscribe"
    data-name="Product - 1 Year Subscription"
    data-amount="49.99"
    data-recurrence="1"
    data-period="Y"
    data-callback="http://url"
    data-cancel_return="http://url"
    data-env="sandbox"
></script>

I don't know why and how I should properly do it but I tried with several of PayPal's data attributes like notify, return, return_url and more but nothing seems to work.

I pay and then get on this page:

But no redirect to the callback page, what am I doing wrong please?

Thanks and have a nice day!

回答1:

Try this:

<script src="/data/js/paypal-button.min.js?merchant=MERCHANT_CODE"
        data-button="subscribe"
        data-name="Product - 1 Year Subscription"
        data-amount="49.99"
        data-recurrence="1"
        data-period="Y"
        data-callback="http://url"
        data-cancel_return="http://url"
        data-callback="http://yourdomain" 
        data-return="http://yourdomain" 
        data-env="sandbox"
    ></script>

You have to enable Auto Return in your PayPal account. Otherwise it will ignore the return field.

From the documentation:

To set up Auto Return:

  1. Log in and click the Profile subtab under My Account.
  2. Click the Website Payment Preferences link under Selling Preferences.
  3. Click the On radio button to enable Auto Return.
  4. Enter the Return URL. Note: You must meet the Return URL requirements in order to set up Auto Return. Learn more about Return URL.

IPN stands for Instant Payment Notification. It will give you more reliable/useful information than what you'll get from auto-return.

Here is the link to the documentation: https://www.paypal.com/cgi-bin/webscr?cmd=p/mer/express_return_summary-outside