async def process_shipping(shipping_query: types.ShippingQuery) -> None: shipping_options = [ types.ShippingOption( id, _(title), prices=[ types.LabeledPrice(_(label), to_telegram_price(price)) for label, price in prices ], ) for id, title, prices in settings.SHIPPING_OPTIONS ] await bot.answer_shipping_query(shipping_query.id, ok=True, shipping_options=shipping_options)
async def shipping(shipping_query: types.ShippingQuery): await bot.answer_shipping_query(shipping_query.id, ok=True, shipping_options=[ types.ShippingOption(id='instant', title='VIP доставка').add(types.LabeledPrice('VIP', 100000)), types.ShippingOption(id='pickup', title='Стандартная доставка').add(types.LabeledPrice('classic', 30000))], error_message='Произошла ошибка')
from aiogram import types def get_prices(name, amount): prices = [types.LabeledPrice(label=name, amount=amount)] return prices POST_REG_SHIPPING = types.ShippingOption( id="post_reg", title="Почтой", prices=[ types.LabeledPrice("Обычная коробка", 10), types.LabeledPrice("Почтой обычной", 1000_00) ]) POST_FAST_SHIPPING = types.ShippingOption( id="post_fast", title="Почтой FAST", prices=[ types.LabeledPrice("Прочная коробка", 1000_00), types.LabeledPrice("Почтой срочной", 3000_00) ]) PICKUP_SHIPPING = types.ShippingOption( id="pickup", title="Самовывоз", prices=[types.LabeledPrice("Самовывоз", -100_00)])
BOT_TOKEN = config.telegram_token PAYMENTS_PROVIDER_TOKEN = '123456789:TEST:1234567890abcdef1234567890abcdef' loop = asyncio.get_event_loop() bot = Bot(BOT_TOKEN) dp = Dispatcher(bot, loop=loop) # Setup prices prices = [ types.LabeledPrice(label='Working Time Machine', amount=5750), types.LabeledPrice(label='Gift wrapping', amount=500) ] # Setup shipping options shipping_options = [ types.ShippingOption(id='instant', title='WorldWide Teleporter').add( types.LabeledPrice('Teleporter', 1000)), types.ShippingOption(id='pickup', title='Local pickup').add( types.LabeledPrice('Pickup', 300)) ] @dp.message_handler(commands=['start']) async def cmd_start(message: types.Message): await bot.send_message( message.chat.id, "Hello, I'm the demo merchant bot." " I can sell you a Time Machine." " Use /buy to order one, /terms for Terms and Conditions") @dp.message_handler(commands=['terms']) async def cmd_terms(message: types.Message):
LabeledPrice( label="Delivery", amount=5 ) ], start_parameter="buy_eth_invoice", photo_url="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/ETHEREUM-YOUTUBE-PROFILE-PIC.png/150px-ETHEREUM-YOUTUBE-PROFILE-PIC.png", photo_size=600, need_shipping_address=True, is_flexible=True ) POST_REGULAR_SHIPPING = types.ShippingOption( id="reg_post", title="Ukr mail", prices=[ LabeledPrice("standard package", 2), LabeledPrice("ukr mail delivery", 15), ] ) POST_EXTRA_SHIPPING = types.ShippingOption( id="extra_post", title="Meest express", prices=[ LabeledPrice("ultra package", 10), LabeledPrice("meest delivery", 25), ] ) PICKUP_SHIPPING = types.ShippingOption( id="pickup_shipping", title="Pickup",
from utils import TestStates import keyboards as kb from config import TOKEN, PAY_TOKEN loop = asyncio.get_event_loop() bot = Bot(token=TOKEN) dp = Dispatcher(bot, storage=MemoryStorage(), loop=loop) dp.middleware.setup(LoggingMiddleware()) PRICES = [ types.LabeledPrice(label='Machine time', amount=4200000), types.LabeledPrice(label='holiday packaging', amount=30000) ] TELEPORT_SHIPPING_OPTION = types.ShippingOption( id='teleporter', title='Wold teleport').add(types.LabeledPrice('teleport', 1000000)) RUSSIAN_POST_SHIPPING_OPTION = types.ShippingOption( id='ru_post', title='Russian post').add( types.LabeledPrice('Wooden box with shock absorbing suspension inside', 100000)).add( types.LabeledPrice( 'Urgent departure (5-10 days)', 500000)) PICKUP_SHIPPING_OPTION = types.ShippingOption(id='pickup', title='pickup').add( types.LabeledPrice('pickup in Moskow', 50000)) @dp.message_handler(commands=['start']) async def process_start_command(message: types.Message):
LabeledPrice(label="Apple MacBook Pro 13 Touch Bar 202", amount=17_00_00), LabeledPrice(label="Доставка", amount=10_00), LabeledPrice(label="Скидка", amount=-30_00), LabeledPrice(label="НДС", amount=30_00), ], need_shipping_address=True, start_parameter="create_invoice_macbook_pro_13", photo_url= "https://content2.onliner.by/catalog/device/main@2/8b2f2c3c18c6102c0537aaf5cea17561.jpeg", photo_size=600, is_flexible=True) POST_REGULAR_SHIPPING = types.ShippingOption( id='post_reg', title='Почтой', prices=[ types.LabeledPrice('Обычная коробка', 0), types.LabeledPrice('Почтой обычной', 10_00), ]) POST_FAST_SHIPPING = types.ShippingOption( id='post_fast', title='Почтой (vip)', prices=[ types.LabeledPrice('Супер прочная коробка', 10_00), types.LabeledPrice('Почтой срочной - DHL (3 дня)', 30_00), ]) PICKUP_SHIPPING = types.ShippingOption( id='pickup', title='Самовывоз', prices=[types.LabeledPrice('Самовывоз из магазина', -10_00)])
prices=[ LabeledPrice(label="Tesla Model X", amount=35_000_00), LabeledPrice(label="Доставка", amount=15_000_00), LabeledPrice(label="Скидка", amount=5_000_00), LabeledPrice(label="НДС", amount=1_000_00), ], start_parameter="create_invoice_tesla_model_x", photo_url= "https://tesla-cdn.thron.com/delivery/public/image/tesla/efbb6471-e1b8-4533-b41a-6df9d50c0a42/bvlatuR/std/0x0/performance-hero@2", photo_size=600, need_shipping_address=True, is_flexible=True) POST_REGULAR_SHIPPING = types.ShippingOption( id="post_reg", title="Почтой", prices=[ types.LabeledPrice("Обычная коробка", 0), types.LabeledPrice("Почтой обычной", 1000_00), ]) POST_FAST_SHIPPING = types.ShippingOption( id="post_fast", title="Почтой (VIP)", prices=[ types.LabeledPrice("Супер прочная коробка", 1000_00), types.LabeledPrice("Почтой срочной - DHL (3 дня)", 15000_00), ]) PICKUP_SHIPPING = types.ShippingOption( id="pickup", title="Самовывоз",
level=logging.INFO) loop = asyncio.get_event_loop() bot = Bot(BOT_TOKEN, parse_mode=types.ParseMode.MARKDOWN) dp = Dispatcher(bot, loop=loop) # Setup prices PRICES = [ types.LabeledPrice(label='Настоящая Машина Времени', amount=4200000), types.LabeledPrice(label='Подарочная упаковка', amount=30000) ] # Setup shipping options TELEPORTER_SHIPPING_OPTION = types.ShippingOption( id='teleporter', title='Всемирный* телепорт').add(types.LabeledPrice('Телепорт', 1000000)) RUSSIAN_POST_SHIPPING_OPTION = types.ShippingOption(id='ru_post', title='Почтой России') RUSSIAN_POST_SHIPPING_OPTION.add( types.LabeledPrice('Деревянный ящик с амортизирующей подвеской внутри', 100000)) RUSSIAN_POST_SHIPPING_OPTION.add( types.LabeledPrice('Срочное отправление (5-10 дней)', 500000)) PICKUP_SHIPPING_OPTION = types.ShippingOption(id='pickup', title='Самовывоз') PICKUP_SHIPPING_OPTION.add(types.LabeledPrice('Самовывоз в Москве', 50000)) @dp.message_handler(commands=['start'])