Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Help please on “GetInAppPurchaseAvailable ( 0 )” not recognizing previously purchased products

Author
Message
SpinieBop
9
Years of Service
User Offline
Joined: 10th Oct 2014
Location: Australia
Posted: 24th Mar 2017 00:43
I am using Tier 1 version V2017.01.09
I am having a problem with reinstating a previously purchased IAP product when my app starts. The call to GetInAppPurchaseAvailable ( 0 ) does not return 1. The IAP product has perversely been purchased via Google Play and the purchase process worked fine
1) Should there be a time delay between calling InAppPurchaseSetup ( )and GetInAppPurchaseAvailable ( 0 ) ?
2) Do I need to call InAppPurchaseActivate ( 0 ) before calling GetInAppPurchaseAvailable ( 0 ) ?
3) Do I need to write out to a file when the user originally purchases the IAP product and reference that file every time the app starts?

Any suggestion would be greatly appreciated .

When my app first starts up I check to see if the user has already purchased the IAP product, I am using the correct setup details for my IAP product in the Google play developers console.

InAppPurchaseSetTitle ( "your app title" )
InAppPurchaseSetKeys ( "key1", "" )
InAppPurchaseAddProductID ( "productID1", 0 )
// initial set up
InAppPurchaseSetup ( )

When I call GetInAppPurchaseAvailable ( 0 ) straight after calling InAppPurchaseSetup ( ) it does not return 1, if I try to purchase the IAP product again using the purchase routine below, it states I have already purchased the IAP product and return 1 when GetInAppPurchaseAvailable ( 0 ) is called within the PurchaseRoutine:

if GetInAppPurchaseAvailable ( 0 ) = 1
// user owns productID1
endif



PurchaseRoutine:
do
// buy first product when pointer is pressed
if GetPointerPressed ( ) = 1
BuyProduct ( 0 )
endif
sync ( )
loop

function BuyProduct ( ID as integer )
// start activation
InAppPurchaseActivate ( ID )
// wait until it is done
do
// check if it has finished
if GetInAppPurchaseState ( ) = 1
exit
endif
sync ( )
loop
if GetInAppPurchaseAvailable ( ID ) = 1
// provide the content
endif
return

Kevin
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Apr 2017 14:51
Quote: "1) Should there be a time delay between calling InAppPurchaseSetup ( )and GetInAppPurchaseAvailable ( 0 ) ?"

Yes, purchases are checked in the background and may take a little time to be restored. On iOS you must call InAppPurchaseRestore to restore purchases.

Quote: "2) Do I need to call InAppPurchaseActivate ( 0 ) before calling GetInAppPurchaseAvailable ( 0 ) ?"

On the first purchase, yes, after that, no.

Quote: "3) Do I need to write out to a file when the user originally purchases the IAP product and reference that file every time the app starts?"

That would be one way of handling it.

Login to post a reply

Server time is: 2024-04-19 08:24:20
Your offset time is: 2024-04-19 08:24:20