I worked on a way to pay through various methods. It involves a user selecting the appropriate method he/she likes or wants to use.
#Controller
form = SQLFORM(Pending, formstyle="divs", submit_button='Subscribe'),
if form.process().accepted:
session.pending = form.vars
redirect(URL('e_pay', form.vars.pay_with, ))
form_one = SQLFORM(Subscription_one, formstyle="divs", submit_button='Subscribe')
if form_one.process().accepted:
session.pending_one = form_one.vars
redirect(URL('e_pay', form_one.vars.pay_with, ))
#db.py
one_month = timedelta(days=365/12)
Subscription_one = db.define_table('subscription_one',
Field('user_id', 'reference auth_user'),
Field('Subscription_type','text', default = 'One Month', represent = lambda value, row: DIV(str(value),_style="color:#38D9D6; text-align: center;")),#Only modified by Admin
Field('Amount','double', default= 3.49, represent = lambda value, row: DIV('$' + str(value) + '/month', _style='text-align: center; color: red; font-size: 30px;')),#Only modified by Admin
Field('pay_with',requires=IS_IN_SET((['paypal','stripe',])),default='None'),
Field('confirmed', 'boolean', default=False),
Field('start_date', 'date', default=request.now),
Field('renew_date', 'date', default=request.now+one_month),)
three_month = timedelta(days=365/4)
Subscription_three = db.define_table('subscription_three',
Field('user_id', 'reference auth_user'),
Field('Subscription_type','text', default = 'Three Months', represent = lambda value, row: DIV(str(value),_style="color:#38D9D6; text-align: center;")),#Only modified by Admin
Field('Amount','double', default= 3.29, represent = lambda value, row: DIV('$' + str(value) + '/month', _style='text-align: center; color: red; font-size: 30px;')),#Only modified by Adminn
Field('pay_with',requires=IS_IN_SET((['paypal','stripe',])),default='None'),
Field('confirmed', 'boolean', default=False),
Field('start_date', 'date', default=request.now),
Field('renew_date', 'date', default=request.now+three_month),)
The problem is that the user when selecting an option, 'paypal' and decides against it and selects 'stripe', the options are still 'active' and not deselected.So on clicking submit, both might be posted.
I also need to align the buttons to the center or left but _select='align-items:center' is not working.