I am using the following script to add an item to a paypal shopping carton my web app. The script is placed into the URL property of the HTML Viewer control, but when I launch the app, the browser reports an error. Any clues why the following code doesn’t work;
I should have noted:The script runs flawlessly in my HTML editor, but can’t get past the second line. If I add the ampersands as Greg suggested the browser has a coronary and Paypal won’t accept the incoming post. Could it be the syntax of the ht="<script" async="'async" line?
[quote=187008:@chris benton]I am using the following script to add an item to a paypal shopping carton my web app. The script is placed into the URL property of the HTML Viewer control, but when I launch the app, the browser reports an error. Any clues why the following code doesn’t work;
Excuse my dumbness, I can’t find the ‘email link’ in the object library. I don’t think we are on the same page Michel. This script creates a ‘Add to cart’ server side button and drops down the cart when invoked.
Have you tried that in a regular browser before ? This code looks funny. If it is, as I suspect, a series of URL arguments, then it must be URL encoded, with"&" between fields.
I created an HTML file with just that into it, and it displays very nicely the button in Chrome. Any time you want to display something in the HTMLViewer, it is always better to try that in a regular browser before.
So basically, all you need to do is to paste the code above in an “ht” constant, then your Xojo code will be just the last line of what you posted :
I agree that the code looks funny especially the <script async="‘async" because there is a single inverted comma mixed with a pair of quotes i.e.’’ ’ " . The code you pasted works in Safari, but it does not produce an ‘add to cart’ button, instead produces a ‘buy it now’ button. This function is regulated by the ‘data-button=cart’ variable.
The most important part is that you were assembling your request without ampersands, which explains why you never got any button. Now seems to me the variable data-button=cart is indeed in the code.
The other approach I was suggesting in my first reply is instead of assembling a request that way, go to your Paypal account and create a button (it is usually in your preferences). There you will be able to set price, shipping, name, sku, make it a cart button, and this will generate the code for you. It may be simpler.
Here is an example of the code created by paypal with the procedure I told you :
[code]
[/code]
It displays very nicely a shopping cart button with the price and shipping charges you had in your code, and if you click on it, you can send me 286 .
This really is the way to go. It prevents people from fiddling with the page variables before submitting the add to cart request. I’ve had a number of clients who had to deal with customers giving themselves discounts this way. By having a named button instead like Michel’s example that has everything built-in you take away this opportunity for fraud.
[/quote]
Thanks Michel, I tried the example you posted and it works on a browser, but not in Xojo. What I want to do is create buttons on the fly, by sucking in parameters and variables from a server side text file. The encrypted value, value="SFKG7W77HAK3Q"> may mean something to Paypal, but its nothing I can work with. considering that I need to create valid cart buttons for over a hundred products, the above example just won't work for me. If I could just get the following code to work in Xojo most of my problems would be solved. BTW Michel, I am not paying 286 for a gizmo. They can be purchased a lot cheaper on ebay.
[code]ht=ht+" src=https://www.paypalobjects.com/js/external/paypal-button-minicart.min.js?merchant=merchantname@merchantdomain.com"
ht=ht+">"[/code]
[quote=187624:@chris benton]Thanks Michel, I tried the example you posted and it works on a browser, but not in Xojo. What I want to do is create buttons on the fly, by sucking in parameters and variables from a server side text file. The encrypted value, value=“SFKG7W77HAK3Q”> may mean something to Paypal, but its nothing I can work with. considering that I need to create valid cart buttons for over a hundred products, the above example just won’t work for me. If I could just get the following code to work in Xojo most of my problems would be solved. BTW Michel, I am not paying 286 for a gizmo. They can be purchased a lot cheaper on ebay.
The code you posted before and that I tried to make conformant to Paypal requirements by adding ampersands is probably your solution, then. Now as I have no idea where you found the specs for that way of building a button, I am afraid you are on your own.
Thanks Michel, it finally works, but I see 2 errors I made in the initial implementation;
No start and end in the script
I was using HTMLViewer’s URL property/method instead of LOADPAGE.
As I said before your pricing on Gizmos is still way too high, the Chinese make them much cheaper that you.
Thanks a ton
The following script as originally modified by Michel Bujardet is added to the open event of a HTMLViewer(HV). It produces a ‘add to cart button’ in the client space of hv. When the button is clicked Paypal’s cart is invoked within the client space of hv. What I cannot sort out is how to locate the cart and button within a specific area of the web app host page. Any suggestions would be greatly appreciated. Keep in mind that an ‘add to cart’ should be located in proximity to the product being sold.
About the only relevant thing that I can vary is the button size by adding ht=ht+" data-size=small"+chr(13) while will give you a smaller more elegant looking button.