source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/gluon/contrib/google_wallet.py

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 1.1 KB
Line 
1from gluon.html import XML
2
3def button(merchant_id="123456789012345",
4           products=[dict(name="shoes",
5                          quantity=1,
6                          price=23.5,
7                          currency='USD',
8                          description="running shoes black")]):
9    t = '<input name="item_%(key)s_%(k)s" type="hidden" value="%(value)s"/>\n'
10    list_products = ''
11    for k, product in enumerate(products):
12        for key in ('name','description','quantity','price','currency'):
13            list_products += t % dict(k=k + 1, key=key, value=product[key])
14    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&amp;w=117&amp;h=48&amp;style=white&amp;variant=text&amp;loc=en_US" type="image"/>\n</form>""" % dict(merchant_id=merchant_id, list_products=list_products)
15    return XML(button)
Note: See TracBrowser for help on using the repository browser.