How to tell which option someone picks from a drop-down?
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:
then in your IPN you can find out by
<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>
or you could use custom field if you are already using different name for the purchase.
//which is your item name 'one_month', 'two_months' etc.
$item_name = $_POST['item_name'];
which in IPN it it will be as custom variable
<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 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
精彩评论