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>
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.