better google wallet, checks parameters
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.2.1 (2012-11-01 21:35:48) stable
|
Version 2.2.1 (2012-11-01 22:01:51) stable
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
from gluon import XML
|
from gluon import XML
|
||||||
|
|
||||||
|
|
||||||
def button(merchant_id="123456789012345",
|
def button(merchant_id="123456789012345",
|
||||||
products=[dict(name="shoes",
|
products=[dict(name="shoes",
|
||||||
quantity=1,
|
quantity=1,
|
||||||
price=23.5,
|
price=23.5,
|
||||||
currency='USD',
|
currency='USD',
|
||||||
description="running shoes black")]):
|
description="running shoes black")]):
|
||||||
t = '<input name="item_%(key)s_%(k)s" type="hidden" value="%(value)s"/>'
|
t = '<input name="item_%(key)s_%(k)s" type="hidden" value="%(value)s"/>\n'
|
||||||
list_products = ''
|
list_products = ''
|
||||||
for k, product in enumerate(products):
|
for k, product in enumerate(products):
|
||||||
for key, value in product.items():
|
for key in ('name','description','quantity','price','currency'):
|
||||||
list_products += t % dict(k=k + 1, key=key, value=value)
|
list_products += t % dict(k=k + 1, key=key, value=product[key])
|
||||||
button = '<form action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/%s" id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" target="_top">%s<input name="_charset_" type="hidden" value="utf-8"/><input alt="" src="https://checkout.google.com/buttons/buy.gif?merchant_id=%s&w=117&h=48&style=white&variant=text&loc=en_US" type="image"/></form>' % (merchant_id, list_products, merchant_id)
|
button = """<form action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/%(merchant_id)s" id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" target="_top">\n%(list_products)s<input name="_charset_" type="hidden" value="utf-8"/>\n<input alt="" src="https://checkout.google.com/buttons/buy.gif?merchant_id=%(merchant_id)s&w=117&h=48&style=white&variant=text&loc=en_US" type="image"/>\n</form>""" % dict(merchant_id=merchant_id, list_products=list_products)
|
||||||
return XML(button)
|
return XML(button)
|
||||||
|
|||||||
Reference in New Issue
Block a user