Integrating Google Checkout

6 posts by 2 authors in: Forums > CMS Builder
Last Post: June 6, 2008   (RSS)

By gdl2306 - June 6, 2008

Hi,
I am attempting to create a product template which allow users to create a few products that visitors can buy using google checkout. Each product needs some html to link to the checkout. I think what I need to do is create some system fields to hide this code from the (non technical) user who creates the product but is included in the product web page. Can anyone say whether this is possible and if so how to go about it?
Gerald

Re: [Dave] Integrating Google Checkout

By gdl2306 - June 6, 2008

Thanks. Huge improvement to PageBuilder, by the way.

Google code per product is


<form method="POST"
action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/1234567890"
accept-charset="utf-8">

<input type="hidden" name="item_name_1" value="Peanut Butter"/>
<input type="hidden" name="item_description_1" value="Chunky peanut butter."/>
<input type="hidden" name="item_quantity_1" value="1"/>
<input type="hidden" name="item_price_1" value="3.99"/>
<input type="hidden" name="item_currency_1" value="USD"/>

<input type="hidden" name="ship_method_name_1" value="UPS Ground"/>
<input type="hidden" name="ship_method_price_1" value="10.99"/>

<input type="hidden" name="tax_rate" value="0.0875"/>
<input type="hidden" name="tax_us_state" value="NY"/>

<input type="hidden" name="_charset_"/>

<input type="image" name="Google Checkout" alt="Fast checkout through Google"
src="http://checkout.google.com/buttons/checkout.gif?merchant_id=1234567890&w=180&h=46&style=white&variant=text&loc=en_US"
height="46" width="180"/>

</form>

Gerald

Re: [gdl2306] Integrating Google Checkout

By Dave - June 6, 2008

Hi Gerald,

So what I'm thinking is you could just create fields for the values that you need to change. You probably have some of them setup already. In this case you'd need: name, description, price, and shipping (assuming it will always be UPS Ground"). It tax_rate and other values won't change we can leave those as is.

Then you'd insert those in the content as follows. Not that I'm using the PHP htmlspecialchars() function to encode the values so if there is a " in the value it doesn't break the tag. Also, I'll use the variable name $product, but feel free to use whatever your variable name is called.

<form method="POST"
action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/1234567890"
accept-charset="utf-8">

<input type="hidden" name="item_name_1" value="<?php echo htmlspecialchars($product['name']); ?>"/>
<input type="hidden" name="item_description_1" value="<?php echo htmlspecialchars($product['description']); ?>"/>
<input type="hidden" name="item_quantity_1" value="1"/>
<input type="hidden" name="item_price_1" value="<?php echo htmlspecialchars($product['price']); ?>"/>
<input type="hidden" name="item_currency_1" value="USD"/>

<input type="hidden" name="ship_method_name_1" value="UPS Ground"/>
<input type="hidden" name="ship_method_price_1" value="<?php echo htmlspecialchars($product['shipping']); ?>"/>

<input type="hidden" name="tax_rate" value="0.0875"/>
<input type="hidden" name="tax_us_state" value="NY"/>

<input type="hidden" name="_charset_"/>

<input type="image" name="Google Checkout" alt="Fast checkout through Google"
src="http://checkout.google.com/buttons/checkout.gif?merchant_id=1234567890&w=180&h=46&style=white&variant=text&loc=en_US"
height="46" width="180"/>

</form>


Does that example make sense? Give it a try and let me know if you have any questions or need more help!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Integrating Google Checkout

By gdl2306 - June 6, 2008

Thanks Dave. Just realized I am being a bit thick as I can produce this code for every product by simply including it within php loops. Cheers. Gerald

Re: [gdl2306] Integrating Google Checkout

By Dave - June 6, 2008

No problem at all, we're here to help! :)
Dave Edis - Senior Developer
interactivetools.com