{$bot_url = '[`https://app.shop-script.com/s/%s/`]'} {$mini_app_mode = $channel.params.mini_app_mode|default:''}

{sprintf('[`Set up a mini-app online store within the %s messaging app. Your store seamlessly integrates with %s via a custom bot or a public channel and supports an in-mini-app checkout.`]', '[`Telegram`]', '[`Telegram`]')}

{sprintf('[`%s mini-app setup guide ›`]', '[`Telegram`]')}

{if !empty($channel.id)} {else} {/if}
[`Enabled`]
{foreach $form_fields as $name => $control_html}
{$control_html}
{/foreach}

{sprintf('[`Your %s channel`]','[`Telegram`]')}

{sprintf('[`Use Shop-Script bot for posting products’ BUY buttons to your public %s channel so that your subscribers can buy & check out right within the messenger.`]', '[`Telegram`]')}

[`It’s free! There are no platform commissions for selling online via Shop-Script bot.`]

{sprintf('[`Your %s channel`]','[`Telegram`]')}

[`Optional.`] [`If you have a public Telegram channel, enter its @username here to allow the main Shop-Script bot to post BUY buttons to this channel.`]

{* link to Shop-Script master Telegram bot *}
[`Shop-Script bot`]
https://t.me/WebasystShopScript_bot

[`Use this bot to publish posts with BUY buttons leading directly to your mini-app shopping experience.`]

{sprintf('[`To start posting, make sure %s is added as an admin to your %s public channel.`]', '@WebasystShopScript_bot', '[`Telegram`]')} {sprintf('[`%s mini-app setup guide ›`]', '[`Telegram`]')}

{sprintf('[`Your %s custom bot`]','[`Telegram`]')}

{sprintf_wp( 'An advanced option with a custom bot and your branding. In this mode, you will need to create your own %s bot using %s and link your store to that bot as a mini-app.', '[`MAX`]', 'href="https://t.me/BotFather" target="_blank"', '@BotFather' )}

[`If your custom bot token is connected, Shop-Script bot will automatically redirect all BUY buttons to your custom bot mini-app.`]

{if shopLicensing::isPremium()}{$_c = 0.75}{else}{$_c = 1.5}{/if} {sprintf_wp( '%s%% commission for orders processed via a custom bot. How it works ›', $_c|wa_format_number:2, sprintf( 'href="%s" target="_blank"', '[`https://www.shop-script.com/pricing/`]' ) )}

[`Your custom bot token`]
@{$channel.params.bot_username|default:''|escape} {$bot_state = ''} {if !empty($channel.params.bot_token)} {if empty($channel.params.bot_username)} {$bot_state = ' state-error-hint'} {else} {$bot_state = ' state-success-hint'} {/if } {/if}

{sprintf_wp( 'Create your custom Telegram bot and obtain its token using the @BotFather bot.', 'href="https://t.me/BotFather" target="_blank"' )}

{* custom bot mode mini-app URL *}
[`Mini-app URL`]
{if !$is_waid}

{sprintf('[`For the mini-app to work, enable Webasyst ID and services in the Settings app.`]', 'href="'|cat:$wa_backend_url|cat:'webasyst/settings/"')}

{elseif empty($channel.wa_channel_id)} [`Save this channel to get a link for your bot’s mini-app.`] {else} {sprintf($bot_url, $channel.wa_channel_id|default:''|escape)}

[`Save this URL to Telegram › @BotFather › your bot › Mini-app › URL.`]
[`The URL will never change unless the channel is deleted.`]

{/if}
[`Payment`]
{sprintf_wp( '%s mini-app checkout payment is based on Webasyst Pay.', '[`Telegram`]', 'href="'|cat:$wa_app_url|cat:'?action=settings#/payment/" class="nowrap"' )}
{if !empty($channel.id)}
{/if}
{capture assign="_app_preview"}

[`This is a preview of how the mini-app will look within the messaging app. The shopping functionality is disabled in the preview mode.`]

{/capture}