Search code examples
paypalpaypal-sandboxpaypal-ipnpaypal-adaptive-payments

Paypal is not overriding the return URL?


I need to override the given default Auto return URL from the paypal button HTML code. I followed these steps:

  1. Check the Auto return Url section and gave a default URL
  2. Generate a Buy Now button and left the Return and Cancel URL options as it is.
  3. Paste the button code

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
    <input type="hidden" name="return" value="http://www.someURL.com"/>
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="G3WQ*******">
    <input type="image" src="https://www.sandbox.paypal.com/en_GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
    <img alt="" border="0" src="https://www.sandbox.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1">
    </form>
    

After successful payment on Sandbox PayPal is always redirecting me to the default URL.

Why isn't overriding it? Any help would be appreciable.

I saw a couple of similar unanswered question on PayPal community and StackOverflow as well:


Solution

  • You won't be able to use the return field directly in the button when you're using a hosted button. That has to be set in the hosted button settings when creating the button (or editing it through the PayPal account.)

    If you want to be able to set your own return URL on the fly then you'll have to use a non-hosted button.