0

I am writing a php script in Paypal form. I am sending return url using $testUrl variable which will work after successful payment but it is not redirecting to that url.

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
   <select name="amount">
      <option value="10">10 SEK</option>
      <option value="20">20 SEK</option>
      <option value="30">30 SEK</option>
   </select>
    <?php $testUrl= "http://www.google.com"; ?> 
     <input type="hidden" name="cmd" value="_s-xclick" />
     <input type="hidden" name="hosted_button_id" value="3FWC3TJEYANK4" />
     <input type="image"  src="https://www.sandbox.paypal.com/en_US/i/btn/btn_donate_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_US/i/scr/pixel.gif" width="1" height="1" />
     <input type="hidden" name="notify_url" value="http://beeurban.ayond.com/wp-content/payment/ipn.php" />
     <input type="hidden" name="currency_code" value="SEK" />
     <input type="hidden" name="return" value="<?php echo $testUrl ; ?>" />  
   </form>
dotnetrocks
  • 2,589
  • 12
  • 36
  • 55
  • This is very difficult to answer. What does the documentation say about this? – user254875486 Nov 20 '12 at 07:51
  • do you need auto redirection to return URL or are you using the "Back to Merchant site" link after payment? – Tahir Yasin Nov 20 '12 at 07:54
  • @Lex In documentation, if we create a hidden input field with name return, it will take the value of that field.http://www.paypalobjects.com/IntegrationCenter/ic_std-variable-ref-donate.html – dotnetrocks Nov 20 '12 at 07:55
  • I tried with Andrew's answer but it didn't work. pls have a look at this code jsfiddle.net/tEmSw – dotnetrocks Nov 20 '12 at 09:01

3 Answers3

3

The auto return option need to be activate in your paypal account.

See here : Setting PayPal return URL and making it auto return?

Please look at @andrew's answer below : https://stackoverflow.com/a/13468873/1722914

Community
  • 1
  • 1
iizno
  • 829
  • 1
  • 9
  • 28
2

Your problem is that you're using a hosted button. You can't add additional fields to the button code like this when you're using hosted buttons. Everything has to be configured within the button manager in your PayPal account. Your notify_url probably isn't working either, from what I'm seeing, because that would have to be setup in the button manager, too...unless you have the same notify URL setup in your profile under Instant Payment Notification Preferences. Then that would take effect, but what you're passing here would be ignored.

In the button manager, Step 3 - Customized Advanced Features, has an option for "Take customers to this URL when they finish checkout" that you need to enable and fill in your return URL there. You'll also see under "advanced variables" that you can add notify_url there.

Unfortunately, you can't use dynamic values like you're attempting to do with that PHP variable for the return URL. If the return URL is something that can change depending on the order you'll need to use a non-hosted button.

To do that, in Step 2 - Track Inventory, Profit & Loss, you'll need to uncheck the Save button at PayPal box. This will give you different HTML code that will have more fields included, and then you can add your own values for return, notify_url, etc.

Drew Angell
  • 25,968
  • 5
  • 32
  • 51
  • I tried with answer but still it is not redirecting. Pls have a look at this code http://jsfiddle.net/tEmSw/ – dotnetrocks Nov 20 '12 at 08:49
  • Did you try the non-hosted button, or did you update the hosted button data from the button manager? Show me your updated button code and maybe I'll see the problem. – Drew Angell Nov 20 '12 at 18:42
  • Hi, I updated my code here http://jsfiddle.net/YPU4V/ . Also included php code there. Now, I am not getting any value for payment_amount variable after completing my payment. thanks a lot for help ! – dotnetrocks Nov 20 '12 at 19:03
  • It would be mc_gross or payment_gross. Refer to the [IPN/PDT variable reference](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables). You could also just dump out all $_POST values to your complete page to see exactly what you get back and work off that. – Drew Angell Nov 20 '12 at 21:29
0

http://jream.com/public/lab/paypal_ipn.class.php this may be helpful in guiding you

rOcKiNg RhO
  • 631
  • 1
  • 6
  • 16