开发者

How to tell which option someone picks from a drop-down?

开发者 https://www.devze.com 2023-03-02 14:10 出处:网络
I\'ll save the ran开发者_如何学Ct about how poor PayPal\'s documentation is for another time. Basically I have three buy it now buttons, each one is a drop down menu. What variables should I use to ge

I'll save the ran开发者_如何学Ct about how poor PayPal's documentation is for another time. Basically I have three buy it now buttons, each one is a drop down menu. What variables should I use to get my IPN handler to differentiate between the three different buttons, and once it figures out which button, to differentiate between the options within each button. (PHP)

The buttons have names like "upgrade1" and "upgrade2" and "upgrade3", and the options look like:

  • 1 Month - $9.99
  • 2 Months - $18.99
  • 3 Months - $25.99


well if you have your own names of the buttons, you wont get anything in IPN... The important thing to remember is that PayPal is not using your button names. You have to use pre-defined names from paypal for your buttons. I can see 2 solutions here:

<select name="item_name">
        <option value="one_month">1 Month - $9.99</option>
        <option value="two_months">2 Months - $18.99</option>
        <option value="three_months">3 Months - $25.99</option>
</select>
then in your IPN you can find out by
//which is your item name 'one_month', 'two_months' etc.
$item_name = $_POST['item_name'];
or you could use custom field if you are already using different name for the purchase.
<select name="custom">
        <option value="one_month">1 Month - $9.99</option>
        <option value="two_months">2 Months - $18.99</option>
        <option value="three_months">3 Months - $25.99</option>
</select>
which in IPN it it will be as custom variable
//which is your item name 'one_month', 'two_months' etc.
$custom = $_POST['custom'];

there might be more solutions but those one are the easiest and I the most right, in my opinion.

EDIT: and just so you know, for security reasons you should check if the amount payed is the same as the price of that item.

hope it helps

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号