Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: How can I implement dynamic pricing for a PayPal button?

  1. #1
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile How can I implement dynamic pricing for a PayPal button?

    I have created a sandbox paypal account to test the payment transactions.Its a personal account. I have created a buy now button which has a fixed price. I want to implement dynamic price for this button.Is it possible to edit the current button to implement dynamic pricing.Please help me .

    The code is given below.

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="325KDMR5R82CU">
    <input type="hidden" name="amount" value="170.00">
    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_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">
    </form>

    Thanks in Advance
    Ghanasyam

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You might not be able to overwrite it with a hosted button (not all inputs of a hosted button can be overwritten but some can, I forget which, but you could always create a 'normal' button and work from there), and it would depend upon what you mean by dynamic. But what you have in your post is what you would do more or less:

    Code:
    <input type="hidden" name="amount" value="170.00">
    You would access that and change it via javascript (can be done without page reload, but would essentially allow a savvy user to set their own price) or a server side (more secure) language. Or even just hard code it to a different form element:

    Code:
    <select name="amount">
    <option value="170.00">Regular ($170)</option>
    <option value="185.00">Deluxe ($185)</option>
    </select>
    which would give the user the choice.

    Exactly what you would do and which language to use depends upon the circumstances under which you want the price to change and upon how secure that needs to be. You could always make changes via javascript but then validate the price via a server side language before actual submission to PayPal.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ghanasyam (09-14-2011)

  4. #3
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    thank you john for your support.I made a mistake earlier by adding <input type="hidden" name="amount" value="170.00"> with button code.It wasnt with the actual code.I added it to check whether i can change the actual fixed amount of 300 USD TO 170 USD.By dynamic pricing i mean changing the amount of the paypal button dynamically.For example if i enter the price of an item dynamically using a textbox , then the amount of the button also should change.I hope u got the exact requirement.

    the actual code of button was :

    <input type="hidden" name="cmd" value="_s-xclick">
    <input type="hidden" name="hosted_button_id" value="325KDMR5R82CU">
    <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_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">



    Thanks in advance

    Ghanasyam

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by ghanasyam View Post
    . . . adding <input type="hidden" name="amount" value="170.00"> with button code.It wasnt with the actual code.I added it to check whether i can change the actual fixed amount of 300 USD TO 170 USD . . .
    Well, did that experiment work? If so, you can do this:

    Code:
    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
     <input type="hidden" name="cmd" value="_s-xclick">
     <input type="hidden" name="hosted_button_id" value="325KDMR5R82CU">
     <label>Name Your Price: <input type="text" name="amount" value="170.00"></label>
     <input type="image" src="https://www.sandbox.paypal.com/en_US/i/btn/btn_paynowCC_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">
     </form>
    But that means that the user could enter like 2.00 for 300.00 item.

    And, as I said, I forget whether or not you can change a hosted button in that manner. If not, you have to make a normal button and save its code to your page and change its amount input to the one shown in the above code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    ghanasyam (09-14-2011)

  7. #5
    Join Date
    Sep 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    thank you john.My issue is solved.I have created normal button and avoided the host button. Now only i understood that there are different payment buttons in paypal.Your advice helped to search for a normal button generation methods.

    thanks

    Ghanasyam

  8. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    hosting your own button in this way is dangerous: the reason PayPal has hosted buttons is to avoid fraud. I've built dynamic buttons like this before, but I wouldn't feel comfortable doing it without the following precautions:

    1) keep the button on a password-protected page. Limit the number of people who can see the button to people who have registered with you and/or are actually interested in making a purchase. Don't make it available to the general public.

    2) MORE IMPORTANTLY, validate each purchase. Keep a database record of each custom button you produce, and use Paypal's IPN (Instant Payment Notifications) and PDT (Payment Data transfer) APIs to confirm that the details are exactly correct. Reject any transaction that does not exactly match your records, down to the last detail.

    By not using PayPal's hosted buttons, you are taking the responsibility for preventing fraud onto yourself. And PayPal will hold you responsible if you accept a fraudulent payment.

  9. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What exactly is fraud in this case? I'm not sure how you could be liable if someone gives you money. (I'm not arguing-- I'd like to know more.)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    it's mostly protection on your end, and especially when you have a product that ships automatically (e.g., a file download).
    example:

    1) you have a paypal button in plain html, for a $200 product.

    2) user looks at source, reproduces button with $2 price.

    3) you get the payment notification (which was successful), but don't validate properly.

    4) PayPal won't help you. If it comes to legal action and you try to involve them, all they will say is "the payment was successfully completed." You only have $2, but you still owe them the product. You're out $198.

    That's the whole reason PayPal has encrypted/hosted buttons: preset transaction details that can't be messed with.

  11. The Following User Says Thank You to traq For This Useful Post:

    djr33 (09-15-2011)

  12. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I see. So the issue is that someone could unfairly pay you the wrong amount. I thought you were suggesting there was more of a problem than just the amount of money. That's of course a major problem though.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  13. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    But not as I understand it here. That's because the original question (though I advised against it) was how to let the user set the price.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •