Purchasing a product with different pricing levels

Hello, I've been able to successfully read license fields in my app using the GetFeatureValue function.

So here's my next question, and I apologize if this has been answered somewhere, but I searched for a while and couldn't find anything. How do I edit/alter your LimeLM example code (specifically the HTML/PHP code for PayPal) to allow the user to select different features with different prices before checkout?

For example, I'd like to display a web page that says:

My product (without any options) - $100My product (with option A) - $150Option A upgrade (for existing customers) - $50

The user selects via a checkbox or radio button or something. Then when they click the Buy Now button to go to PayPal, the correct price is reflected and the options are handled by the LimeLM paychecker.php code, etc.

Thanks for any help.

, edited

To be more specific, it seems like the things I need to alter are:

- the HTML form submission (<form>) to PayPal. What do I do with the <input> fields to add the options?- the ValidatePP function. How do I use this to read the values from the form submission?

How do I edit/alter your LimeLM example code (specifically the HTML/PHP code for PayPal) to allow the user to select different features with different prices before checkout?

I'm not sure what the question is. You open the "payment.php" file, alter the page to add the additional options (the HTML and JavaScript will depend on how you want it to look, operate, etc.). Then modify paychecker to check for the additional field you POST to PayPal's servers. If certain fields are present (meaning the customer paid for them), then calculate the new expected price and see if it matches what PayPal submitted. If so, then generate a product key with those license fields.

Make sense?

If you have a more specific question I'll be able to give you a more specific answer.

I did have more specific questions, and I asked them above. Here they are again:- How do I add <input> fields in the HTML form for my extra options? Can you give me an example of an input field for an extra option?- In the ValidatePP function, how do I check to see if those fields are present? Again, an example would be helpful.

I'm asking because I don't see example code for those things on any of your help pages. "Alter the page" is not a helpful instruction. I am not an expert web programmer. I would expect a bit more courtesy and patience considering that I have paid you hundreds if not thousands of dollars.

"Alter the page" is not a helpful instruction. I am not an expert web programmer. I would expect a bit more courtesy and patience considering that I have paid you hundreds if not thousands of dollars.

I didn't mean to be flippant. The problem is that the code you need to add/modify really depends on what you want to do. It's not something that can be summed up in a code snippet. The actual LimeLM web API call to generate the product keys *can* be summed up in a code snippet, but what you're asking is a good deal more than that.

The code you'll need to alter that will set certain features is the call to LimeLM::GeneratePKeys(). It's in the PaymentSettings.php file. So instead of this to generate a key without any custom license fields set:

LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email)

Use this to set some fields:

LimeLM::GeneratePKeys($LimeLM_VersionID, 1, $quantity, $email, array('field name 1', 'field name 2'), array('what to set in field 1', 'what to set in field 2'))
- How do I add <input> fields in the HTML form for my extra options? Can you give me an example of an input field for an extra option?

It's much more work then simply adding a new input field (that is, you might need to hire someone to do it because it can't be summed up in a snippet). You need to do a few things:

  1. Add a "custom" hidden field to the form.
  2. Add an input (or inputs) that let the customer select options.
  3. Add JavaScript to the page that reads those inputs and populates that hidden custom field in a way that can then be read in ValidatePP() so you know what custom options the user chose.
  4. Add javascript that modifies the price based on the custom selections.
  5. Modify ValidatePP() to see what options the customer selected, recalculate the "expected price" to see if it matches what the user actually paid. And if so, tell the "SendPKeys()" function to generate product keys with the appropriate custom license fields set.

Do you see what I'm saying? That's a good 12 hours work for me working alone (from start to finish). That's why it's not as simple as a snippet of code. You might need to hire someone to help you customize our example payment page to your specific business needs.

Or you might try someone like FastSpring for payment. They make stuff like that easier. And modifying the code to generate product keys in LimeLM from your FastSpring form is relatively easy (something that I could give you a snippet to).

Ok, thanks, that is helpful. If you have a minute though, I'd still appreciate a specific example of adding a custom input field to the form, and how to check in ValidatePP to see if that option is there. Those are the two things I'd really like a code snippet for. Aren't they just 1-line examples?

I think some better documentation for these things on your Help pages would be nice for everyone to see.

The problem with FastSpring is that the fees are outrageous. I can't believe any business would willingly give away 9% or even 6% of their sale.

Aren't they just 1-line examples?

No, that's what I've been trying to say. The script on your webserver (the actual "buy" page) never directly "talks" to ValidatePP on your server. That complicates things, and thus adds hours of work (hence, why I say you should hire someone to handle this for you). It goes something like this:

Your Buy page talks to PayPal. [Stuff happens on PayPal servers] PayPal may or may not talk to your servers, calling ValidatePP().

In other words, you need to do a bit of work to actually pass data from your form, through PayPal, and then ultimately to the ValidatePP() function. The actual work you have to do I've listed on my previous post in this thread. It's not complicated, it's just time consuming.

If you do get stuck, let me know and I'll help you out.

I think some better documentation for these things on your Help pages would be nice for everyone to see.

I agree. In the future we'll probably make a simple example. It's just not a priority right now for the pre-built example.

The problem with FastSpring is that the fees are outrageous. I can't believe any business would willingly give away 9% or even 6% of their sale.

It's a trade-off. They simplify the experience, but they charge more than most payment providers. Apple takes 1/3 of a customer's revenue for being in their store and Apple adds very little to the overall experience.

This is what I'm asking for:

<input type="hidden" name="custom" ...

Assuming a numerical value for the option (1, 2, 3, etc.), please finish the line. Let's say the name of the option is "myOption". What I specifically don't understand is, if the name is "custom", then where do I put the text "myOption" to specify the variable name?

Similarly,

if ($_POST['custom'] == ...

Assuming the "myOption" option I specified in the <input> field, how to I check for the variable "myOption", and get its value? Please finish the line.

I know this seems trivial but I want to make sure I understand how to match up the option for these two things. There isn't a specific example for the variable/value of a custom field, even on PayPal's site.

So you see, I am only asking for 2 lines. 1 line each right?

To put it another way, in pseudocode, this is what I am looking for:

if (myOption == 1) { // generate product key with no custom license field}else if (myOption == 2) { // generate product key with custom license field}else if (myOption == 3) { // edit existing product key to add custom license field}

I just don't understand how to set and get the variable and its value using HTML/PHP syntax.

Assuming the "myOption" option I specified in the <input> field, how to I check for the variable "myOption", and get its value?

You can't. Only "custom" gets passed to ValidatePP(). That's what I've been saying. Plus you have to re-caulculate the price based on what the customer chooses. It's not a 1-liner.

Please finish the line.

It's more than finishing an if-statement. Scroll up to my other post. I list what you need to do (I'm not exaggerating -- that's actually what you have to do). It's not a 1-liner, but it's not impossible. It's just time-consuming. Is there something that is throwing you off?

So if only one string can be passed as the value for the custom input field, it seems like the solution would be to use that string to store multiple independent options.

For example:

<input type="hidden" name="custom" value="referrer=1234&size=L">

After searching for a while I came across that example on this page: http://www.michaelsherron.com/paypal-IPN-custom-variables

Is that right? If so, that's the answer I've been looking for.

Yes, that's what I've been saying. You still need to modify the "custom" hidden input field when the user selects options (use JavaScript). And you still need to modify the price based on the user selection (again, use JavaScript). And you need to verify the submitted price matches the options the user selected.

I understand what you were saying. But look at your posts. Never did you give me the specific example I asked for. I had to go find it myself. It would probably have taken you 1 minute to give me the example I found.

In reality, the problem is you didn't understand what I was saying. Read my posts. I was only asking about how to format the custom input field, and how to parse it later. The other things you mentioned are things I already know how to deal with, such as adding JavaScript or checking the price.

I was right that the formatting was only a one-line issue. And the parsing is a bit more than one line, but it's just a matter of splitting the string at the ampersands.

This became much more difficult than it had to be. As a business owner myself, I suggest that, in the future, you should assume your customer is asking a valid question, and make sure you understand what he or she is asking. It will save time for everyone.