Skip to content

Instantly share code, notes, and snippets.

@kostyakoz
Created March 20, 2017 16:31
Show Gist options
  • Save kostyakoz/2c8e8ab6662b57ed0b5d260305a7cf05 to your computer and use it in GitHub Desktop.
Save kostyakoz/2c8e8ab6662b57ed0b5d260305a7cf05 to your computer and use it in GitHub Desktop.
def choose_payment_method_keyboard(uid, premium_type, lang):
"""Клавиатура для выбора способа оплаты.
:param premium_type: срок оплаты подписки
"""
data = {
'receiver': 410013085383235,
'successURL': 'https://telegram.me/pstrbot',
'formcomment': 'PosterBot',
'short-dest': 'PosterBot Premium ({n} {m})'.format(
n=config.PREMIUM_TYPES[premium_type]['months'],
m=config.PREMIUM_TYPES[premium_type]['word'][lang]),
'label': '{uid}-{pt}'.format(uid=uid, pt=premium_type),
'quickpay-form': 'shop',
'targets': 'PosterBot Premium (ID {uid})'.format(uid=uid),
'sum': config.PREMIUM_TYPES[premium_type]['sum']['ru'],
'comment': 'PosterBot Premium',
'need-fio': 'false',
'need-email': 'false',
'need-phone': 'false',
'need-address': 'false',
'paymentType': 'AC'
}
key = types.InlineKeyboardMarkup(row_width=1)
pay_ac = requests.post('https://money.yandex.ru/quickpay/confirm.xml',
data=data).url
data.update({'paymentType': 'PC'})
pay_pc = requests.post('https://money.yandex.ru/quickpay/confirm.xml',
data=data).url
data.update({'paymentType': 'MC'})
pay_mc = requests.post('https://money.yandex.ru/quickpay/confirm.xml',
data=data).url
if lang == 'ru':
key.add(
types.InlineKeyboardButton(text='Visa / MasterCard', url=pay_ac),
types.InlineKeyboardButton(text='Яндекс.Деньги', url=pay_pc),
types.InlineKeyboardButton(text='МТС / Билайн / Tele2',
url=pay_mc),
types.InlineKeyboardButton(text='PayPal',
callback_data='settings_pay_pp_{p}'.format(p=premium_type)),
types.InlineKeyboardButton(text='QIWI / WebMoney',
callback_data='settings_pay_other_{p}'.format(
p=premium_type)))
else:
key.add(
types.InlineKeyboardButton(text='PayPal',
callback_data='settings_pay_pp_{p}'.format(p=premium_type)),
types.InlineKeyboardButton(text='Visa / MasterCard', url=pay_ac),
types.InlineKeyboardButton(text='Yandex.Money', url=pay_pc),
types.InlineKeyboardButton(text='QIWI / WebMoney',
callback_data='settings_pay_other_{p}'.format(
p=premium_type)),
types.InlineKeyboardButton(text='MTS / Beeline / Tele2',
url=pay_mc))
key.add(types.InlineKeyboardButton(text='↩',
callback_data='settings_premium'))
return key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment