Google Checkout in ASP.Net MVC

I have a pretty simple ASP.Net site that uses google validation (I have a button with PostBackUrl image set for address values ​​hidden in a Google address) that work fine.

I am moving this application to MVC and I am not sure how to handle this. I was thinking about using a jQuery form, but I don't think this will work in this situation, because there are times when they are redirected to google pages. Has anyone used google validation in an asp.net MVC application?

+7
asp.net-mvc google-checkout
source share
1 answer

You can do the same thing you did before, you just do it manually.

It looks like you are only using the basic version, right?

You create an HTML form in which the Action is set for the Google validation process, add the corresponding hidden fields (the model your controller will go through will be filled with the correct values ​​for them), and then you have a submit button (or image, if you want to).

So, an example Google Basic HTML page modified for some MVC-ish-ness would be something like this:

<form method="POST" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/<%= Model.MerchantId %>" accept-charset="utf-8"> <input type="hidden" name="item_name_1" value="<%= Model.Item.Name %>"/> <input type="hidden" name="item_description_1" value="<%= Model.Item.Description %>> <input type="hidden" name="item_quantity_1" value="<%= Model.Item.Quantity %>"/> <input type="hidden" name="item_price_1" value="<%= Model.Item.Price %>"/> <input type="hidden" name="item_currency_1" value="<%= Model.Item.Currency %>"/> <input type="hidden" name="ship_method_name_1" value="<%= Model.Shipping.Price %>"/> <input type="hidden" name="ship_method_price_1" value="<%= Model.Shipping.Price %>"/> <input type="hidden" name="ship_method_currency_1" value="<%= Model.Shipping.Currency %>"/> <input type="hidden" name="tax_rate" value="<%= Model.Tax.Rate %>"/> <input type="hidden" name="tax_us_state" value="<%= Model.Tax.State %>"/> <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=<%= Model.MerchantId %>&w=180&h=46&style=white&variant=text&loc=en_US" height="46" width="180"/> </form> 

Obviously, you can do everything even more MVC-ish using the Html.Hidden helper, etc., but this shows a really basic version of what you need to do.

+2
source share

All Articles