TheGameCreators / AGK-Studio

3 stars 1 forks source link

In-app purchases (IAP) fail when not including a subscription item #1020

Closed neiltking closed 2 years ago

neiltking commented 2 years ago

I am currently adding an IAP to my new game and ran into an issue. After much debugging I have written a small test based on one of the included examples. This uses a TGC test product and broadcasts the app to the AGK player running on an Android phone. If the script contains both the single purchase test item and the subscription test item it goes through to the Google Play purchase screen fine. BUT if it only contains the single purchase test item it shows the error: "Cannot start purchase until setup is finished, please try again in a minute". It does not matter how long you wait, it always displays that error.

Here is the test code:

InAppPurchaseAddProductID( "agk_test", 0 )
// Uncommenting the next line makes the purchase work
// InAppPurchaseAddProductID( "test_sub", 2 )

InAppPurchaseSetup()

AddVirtualButton( 1, 384, 150, 350 )
SetVirtualButtonSize( 1, 400, 100 )
SetVirtualButtonText( 1, "Start Purchase" )

do
    Print( "FPS: " + str(ScreenFPS()) )
    Print( GetInAppPurchaseToken(0) )

    Print( "Item: " + GetInAppPurchaseDescription(0) + ", " + GetInAppPurchaseLocalPrice(0) + ", State: " + str(GetInAppPurchaseAvailable2(0)) )

    if ( GetVirtualButtonReleased(1) ) then InAppPurchaseActivate(0) // purchase item

    Sync()
loop

This script fails with the error unless you uncomment the line "InAppPurchaseAddProductID( "test_sub", 2 )" (the test subscription item) which should not be necessary.

AppGameKit Studio: V2022.09.26 - Windows 10 AGK Player: Build Sep 26 2022 - Android 10

PaulSJ commented 2 years ago

Fixed for next version. For now calling InAppPurchaseAddProductID() with a subscription product will fix it, even if the subscription product doesn't exist.