0

I must be missing something obvious. I'm trying to create a simple buy now button for an item that costs $10. I logged into Paypal and was able to create this button. However, I need one trick that I haven't been able to figure out.

In my javascript I have a UserID variable. I need to be able to set the notify_url dynamically for the button based on the UserID. I want to set the notify_url to something like this:

https://myserver/paypalnotify/verify/<userid>

How can I change my button at run-time based on the logged in user?

Any tips would be appreciated!

exvance
  • 1,339
  • 4
  • 13
  • 31
  • You can do it on at runtime, but it's better if you use a custom field because it will give you more flexibility. In any case, you'd have to share some of your code. I'm going to add an answer below, based on what you have given here ( I saw you on Elance ) – Jean Paul Oct 29 '14 at 00:26

1 Answers1

0

OK, so assuming you're using PHP on your backend, you want a script on your checkout page (where the button is ) that goes something like this.

<script>
     (function(){
         var user_id = '<?php echo $user_id; ?>' ;
         var notify_url = 'https://myserver/paypalnotify/verify/' + user_id;

         $('#notify_url_input').val(notify_url);//Assuming you're using jQuery
     })();
</script>

So your input should have

<input type="hidden" name="notify_url" id="notify_url_input" value="" />

I hope this helps, let me know if you have any questions.

Jean Paul
  • 912
  • 9
  • 18