Consumable In App Purchases on Android
Andrew at MidWest Coast Media
andrew at midwestcoastmedia.com
Tue Aug 8 13:56:16 EDT 2023
If I’m consuming instantly, this is the code working in my Android/iOS project with comment lines explaining the values being passed in the Android build (note that the product ID values are more specific for Android than iOS):
if tPlatform = "android" then
put "com.midwestcoastmedia.dj3pm." into tProductIDbase
else if tPlatform = "iPhone" then
put EMPTY into tProductIDbase
end if
put tProductIDbase & pWhichProduct into tProductID
mobileStoreEnablePurchaseUpdates
## mobileStoreSetProductType "com.midwestcoastmedia.dj3pm.tip01", "inapp"
mobileStoreSetProductType tProductID, "inapp"
## mobileStoreMakePurchase "com.midwestcoastmedia.dj3pm.tip01", "1", "Thanks for the buck!"
mobileStoreMakePurchase tProductID, "1", tMessage
## mobileStoreConsumePurchase "com.midwestcoastmedia.dj3pm.tip01"
mobileStoreConsumePurchase tProductID
put the result into tCatch
BUT you’ll also need to implement the on purchaseStateUpdate handler to completely execute the purchase cycle. The lesson is sometimes hard to follow when Android changes their branding/naming but https://lessons.livecode.com/m/4069/l/184481-how-do-i-implement-in-app-purchases-in-livecode-google-play-store <https://lessons.livecode.com/m/4069/l/184481-how-do-i-implement-in-app-purchases-in-livecode-google-play-store> has a good example of this.
—Andrew Bell
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Subject: Re: Consumable In App Purchases on Android
> Message-ID:
> <BYAPR12MB2709417D61C6292A2ABAB3D8B90DA at BYAPR12MB2709.namprd12.prod.outlook.com>
>
> Content-Type: text/plain; charset="Windows-1252"
>
> Panos,
>
> Thank you for the reply. Unfortunately, this isn?t working for me? maybe I?m doing something wrong? Product ID is ?1001?. I was able to purchase that product no problem. If I attempt to purchase it again, I get ?alreadyEntitled?.
>
> In a button I put:
>
> on mouseUp
> mobileStoreConsumePurchase 1001
> answer the result
> end mouseUp
>
> The result is empty (I assume that is success). Then, I attempt to purchase 1001 and again I get ?alreadyEntitled?.
>
> I then tried (just guessing at what I need to do as the docs are very vague on how to use it):
>
> on mouseUp
> mobileStoreEnablePurchaseUpdates
> mobileStoreSetProductType 1001,"inapp"
> mobileStoreConsumePurchase 1001
> answer the result
> end mouseUp
>
> Again, result is empty and an attempt to purchase 1001 again, gets ?alreadyEntitled?.
>
> What am I doing wrong?
>
> -Dan
>
>
>
> From: use-livecode <use-livecode-bounces at lists.runrev.com> on behalf of panagiotis m via use-livecode <use-livecode at lists.runrev.com>
> Date: Tuesday, August 8, 2023 at 9:21 AM
> To: How to use LiveCode <use-livecode at lists.runrev.com>
> Cc: panagiotis m <merakosp at gmail.com>
> Subject: Re: Consumable In App Purchases on Android
> Hello Dan,
>
> I think Google no longer differentiates between consumables and
> non-consumables when setting up the in-app product - they are both marked
> as "In-App Products?. However, in LiveCode, you have to call
> mobileStoreConsumePurchase pProductID to be able to buy the product again -
> otherwise you get a "alreadyEntitled" status.
>
> If you do this, and still get "alreadyEntitled", then you have to ensure
> that the pProductID param passed to mobileStoreConsumePurchase indeed
> matches exactly the product id of the product you set up in the google dev
> console.
>
> Hope this helps.
>
> Kind regards,
> Panos
>
> On Tue, 8 Aug 2023 at 01:57, Dan Friedman via use-livecode <
> use-livecode at lists.runrev.com> wrote:
>
>> Does anyone have any experience with consumable in-app purchases on
>> Android? I can?t seem to figure out how to (1) create a consumable
>> product, and (2) how to consume it. mobileStoreConsumePurchase pProductID
>> doesn?t seem to function right? I get back a result that is ?true?, but
>> attempting to purchase the same product, returns ?alreadyEntitled?.
>>
>> The ?How do I implement in-app purchases in LiveCode - Google Play Store??
>> lesson says: click "In-App Products? and click ?Add new product?. From
>> there, follow the instructions to create the type of in-app purchase you
>> wish to use.
>>
>> In Google Play Console > Monitize > In-App Products > Create Product,
>> there isn?t a place to select the type of in-app purchase.
>>
>> Any insight or instructions you may have would be greatly appreciated!!
>>
>> -Dan
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
More information about the use-livecode
mailing list