Joe Sansalone 6 Posted January 18, 2023 Hi, I'm looking to use InApp purchase in an iOS and Android app created with Delphi. According to ChatGPT, the code below will work and also work with for a subscription based purchase. IS THIS CORRECT? uses FMX.InAppPurchase; var InAppPurchase: TInAppPurchase; ProductIdentifier: string; begin InAppPurchase := TInAppPurchase.Create; try // Set up the product identifier for the consumable IAP ProductIdentifier := 'com.yourcompany.yourproduct.consumable'; // <-- if subscription, 'com.yourcompany.yourproduct.subscription'; // Request product information from the App Store InAppPurchase.RequestProductInfo(ProductIdentifier); // Wait for the product information to be returned while not InAppPurchase.ProductInfoReceived do begin Application.ProcessMessages; Sleep(100); end; // Check if the product is valid and available for purchase if InAppPurchase.ProductValid then begin // Show the purchase dialog to the user InAppPurchase.PurchaseProduct(ProductIdentifier); // Wait for the purchase to complete while not InAppPurchase.PurchaseComplete do begin Application.ProcessMessages; Sleep(100); end; // Check if the purchase was successful if InAppPurchase.PurchaseSuccess then begin // Grant the user access to the purchased content // or Add the item to the user inventory or do whatever you want after the purchase end else ShowMessage('Purchase failed'); end else ShowMessage('Product not available'); finally InAppPurchase.Free; end; end; Joe Share this post Link to post
Brian Evans 111 Posted January 18, 2023 Read the help topics and use the events not some Sleep/ProcessMessages messages loop. Using the iOS In-App Purchase Service - RAD Studio (embarcadero.com) Using the Google Play In-app Billing Service - RAD Studio (embarcadero.com) There is also a demo that includes in app purchases: FMX.CapitalIAP Sample - RAD Studio Code Examples (embarcadero.com) 2 Share this post Link to post
Dave Nottage 574 Posted January 18, 2023 3 hours ago, Joe Sansalone said: According to ChatGPT Looks like it still has some learning to do Share this post Link to post
Joe Sansalone 6 Posted January 18, 2023 Thanks for the links. Does the current version Delphi 11.2 support In-App Subscriptions on iOS? Share this post Link to post
Dave Nottage 574 Posted January 18, 2023 4 hours ago, Joe Sansalone said: Does the current version Delphi 11.2 support In-App Subscriptions on iOS? Yes.. it supports Android and iOS Share this post Link to post
Joe Sansalone 6 Posted January 18, 2023 Was In-App Subscriptions (weekly, monthly, yearly) something that was added recently? I don't know why, but I remember Subscriptions not being supported. Just consumables purchases and non-consumable purchases. Share this post Link to post
Eli M. 38 Posted February 1, 2023 On 1/18/2023 at 10:39 AM, Dave Nottage said: Yes.. it supports Android and iOS Dave, is this really the case? The current documentation still says subscriptions are not supported. This guy shows how to add them. Which I am going to try. https://delphitoptips.blogspot.com/2018/03/supporting-in-app-purchase.html?m=1 Share this post Link to post
Dave Nottage 574 Posted February 2, 2023 8 hours ago, Eli M. said: Dave, is this really the case? The current documentation still says subscriptions are not supported. According the code, they're supported on at least Android. Check the FMX.InAppPurchase.Android unit. Not sure about iOS. 8 hours ago, Eli M. said: https://delphitoptips.blogspot.com/2018/03/supporting-in-app-purchase.html?m=1 The current implementation for Android was updated after that article was written. 1 Share this post Link to post
apachx 0 Posted 9 hours ago Hello! Could you please tell me if there have been any changes regarding support for subscriptions in mobile applications created with the latest versions of Delphi? I developed a mobile app for Android, published it on the Play Store, and now I want to add a subscription to this app — so users can pay, for example, $7 per month to use my app. That’s it. I am not selling any other digital content within the app. I am using Delphi 12 Version 29.0.52631.8427. Is it possible to implement such a subscription in my app? Because here: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_the_Google_Play_In-app_Billing_Service, it says: Note: Subscriptions are not currently supported. Share this post Link to post
skyzoframe[hun] 4 Posted 8 hours ago 1 hour ago, apachx said: Note: Subscriptions are not currently supported. Share this post Link to post
apachx 0 Posted 7 hours ago (edited) And what? The same article for RAD Studio Athens: https://docwiki.embarcadero.com/RADStudio/Athens/en/Using_the_Google_Play_In-app_Billing_Service This page was last edited on 28 September 2015, at 14:19. Using the iOS In-App Purchase Service: https://docwiki.embarcadero.com/RADStudio/Athens/en/Using_the_iOS_In-App_Purchase_Service Note: Subscription-based types are not currently supported. This page was last edited on 21 January 2022, at 07:52. Is there any new tutorial about subscriptions? Where can I read more about it? Edited 7 hours ago by apachx Share this post Link to post