On Sunday, January 2, 2022 at 1:55:56 AM UTC-8 mauri...@gmail.com wrote:
> Hello I got this error when trying out the Estore app. > File "/home/maurice/web2py/applications/EStore/controllers/default.py" > <http://127.0.0.1:8000/admin/default/edit/EStore/controllers/default.py>, > line > 157, in pay > description="Purchase".encode('utf-8') > File "/home/maurice/web2py/gluon/contrib/stripe.py", line 115, in __init__ > self.signature = sha1(repr((self.amount,self.description))).hexdigest() > TypeError: Unicode-objects must be encoded before hashing > > This is probably a PY3-ism issue. The value you give description in 3.10.1 is of type bytes, and the sha1 code probably expects a string. In 2.7.18, that same expression yields an instance of type string. /dps > > part of the code in default is: > > @auth.requires_login() > def checkout(): > if session.checkout_form and not request.post_vars: > for key in session.checkout_form: > db.cart_order[key].default = session.checkout_form[key] > form = SQLFORM(db.cart_order).process(dbio=False) > if form.accepted: > session.checkout_form = form.vars > redirect(URL('pay')) > return locals() > > def pay():#Not working, error # description: TypeError: Unicode-objects > must be encoded before hashing > from gluon.contrib.stripe import StripeForm > results = price_cart() > stripe_form = StripeForm( > pk=STRIPE_PUBLIC_KEY, > sk=STRIPE_SECRET_KEY, > amount=int(100*results['total_with_shipping']), # (amount is in > cents)amount=int(100*results['total_with_shipping']), > currency='eur', > currency_symbol='€', > description="Purchase".encode('utf-8') > ) > stripe_form.process() > > Help in correcting this error will be appreciated. > Thank you > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/b5bd81b1-01a0-42d9-b35c-db2e027e2c5bn%40googlegroups.com.