最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

unity game engine - Issue with IAP (Telegram Stars) on Android - Stack Overflow

programmeradmin8浏览0评论

I have a game in development for Telegram, using Unity3D, and I want to integrate IAP (Telegram Stars) into the game,

The flow is as following:

  • user click on in-game item
  • the game call Telegram API createInvoiceLink to get the invoice link
  • the game call Javascript window.Telegram.WebApp.openInvoice with above link
  • a Telegram prompt will appear for user to confirm (<- issue with Android here)
  • wait for a callback
  • in game, display popup based on the status

The above flow worked on Telegram Desktop, but on Telegram Android, there is no prompt, instead "Share" menu is opened.

Have anyone encountered this issue? do you have a solution?

Here is my javascript code:

OpenTelegramInvoice : function(params) {
    if (!window.Telegram || !window.Telegram.WebApp) {
        window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceFailed', 'Cannot find Telegram');
        return;
    }
    var link = UTF8ToString(params);
    window.Telegram.WebApp.openInvoice(link, (status) => {
        if (status == "paid") {
            window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceSuccess');
        } else {
            window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceFailed', status);
        }
    });
}

this is a screenshot from my smartphone

I have a game in development for Telegram, using Unity3D, and I want to integrate IAP (Telegram Stars) into the game,

The flow is as following:

  • user click on in-game item
  • the game call Telegram API createInvoiceLink to get the invoice link
  • the game call Javascript window.Telegram.WebApp.openInvoice with above link
  • a Telegram prompt will appear for user to confirm (<- issue with Android here)
  • wait for a callback
  • in game, display popup based on the status

The above flow worked on Telegram Desktop, but on Telegram Android, there is no prompt, instead "Share" menu is opened.

Have anyone encountered this issue? do you have a solution?

Here is my javascript code:

OpenTelegramInvoice : function(params) {
    if (!window.Telegram || !window.Telegram.WebApp) {
        window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceFailed', 'Cannot find Telegram');
        return;
    }
    var link = UTF8ToString(params);
    window.Telegram.WebApp.openInvoice(link, (status) => {
        if (status == "paid") {
            window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceSuccess');
        } else {
            window.GameInstance.SendMessage('APIOperator', 'OnTelegramInvoiceFailed', status);
        }
    });
}

this is a screenshot from my smartphone

Share Improve this question asked Mar 13 at 4:06 Tom KazanskyTom Kazansky 114 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

I got it solved somehow,
I think the issue is from Telegram's side, it's how the "game" (created with /newgame) behaves,
Instead of using "game", I publish my game as "mini-app" (created with /newapp) then the issue went away (I can process IAP with both PC and Android Telegram)

Hey so sorry to barge in, but I am currently trying to do the exact same thing as you, unity iap, with telegram stars. Kind like durger king.

Would you please give a few pointers

发布评论

评论列表(0)

  1. 暂无评论