ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Mobile specific functions / In-App Purchase functions
  • Overview
  • Principle
  • Specific features for iOS
  • Android specific features
  • Implementation
  • iOS application
  • Android application
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
The mobile systems (Android/iOS) allow their applications to propose content at extra cost, by using the payment system of App Store or Google Play.
This process is used to create for example:
  • applications with extensions at extra cost.
  • applications proposing products at extra cost (e-books, etc.).
  • applications proposing a subscription to content or to services.
This help page describes the mechanisms used in WINDEV Mobile to enable the management of content at extra cost ("In-App" purchase) in your applications.
Principle
The steps for performing an "In-App" purchase in an Android or iOS application are as follows:
  1. The application asks the store for information about the available products. To do so, it gives the identifiers of products to the store. These identifiers have been entered in iTunesConnect for iOS and in the Google Play developer console for Android.
  2. The store returns (in asynchronous way) this information in list format.
  3. The application displays this list to the user.
  4. The user chooses a product to purchase.
  5. The application transmits the request for purchase to the store.
  6. The store sends (in asynchronous way) a response indicating whether the transaction was performed.
  7. The application activates the purchase.
iPhone/iPad

Specific features for iOS

For an In-App purchase performed from an iPhone/iPad application, the following specific features must be taken into account:
  • To check and validate a transaction, you have the ability to use inAppListPurchase. If the product that was purchased is not returned by this function, the purchase can be considered as being invalid.
  • When uninstalling/reinstalling the application, the application may ask to restore the purchase performed beforehand. In this case, the steps 6 and 7 are called back for each non-consumable product and for each subscription already purchased. The consumable products are never restored: they are considered as being consumed as soon as the purchase.
  • The list of products is configured via the interfaces available on iTunes Connect.
  • Validity of subscriptions: The end date of subscriptions is used to define the validity period of a subscription. Beyond this date, the subscription is considered as being ended. inAppListPurchase is used to check the end date of subscriptions.
  • Self-renewable subscriptions: When the subscription expires, the subscription is automatically renewed by the AppStore. We advise you to check the valid subscriptions in the project initialization code via inAppListPurchase.
Remarks:
  • Only the consumable and non-consumable products as well as the subscriptions are supported. The other types of products are not supported.
  • You cannot manage the downloadable content in the products.
  • You have the ability to open the form for configuring the In-App purchases of an application via AppOpenForm.
Android

Android specific features

For an In-App purchase performed from an Android application, the following specific features must be taken into account:
  • All the purchases of "In-App" products performed from an application are stored by the Google Play store and kept even when uninstalling the application or if the uses changes his phone. Which means that the application can ask at any time for the list of purchases performed by the user.
  • A user cannot own more than one occurrence of the same product at a time but the purchased products can be consumed. Once consumed, the product is no longer displayed in the list of purchases and it can be purchased again.
  • The application must be published on Google Play Store to propose the purchase of "In-App" products.
  • Non-consumable purchases:
    The non-consumable products are purchased once only for a given user and application and they provide a permanent service. Once purchased, they are associated with the user without time limit even if the user unsinstalls the application or installs it on another device.
    Example: Access to the "Gold" version of an application.
    • From an application, the user purchases the "Gold version" product that allows him to access the advanced features of the application.
    • When the purchase is validated, the application "activates" the Gold version and allows the user to access the new available features.
    • At each startup, the application checks the purchases performed by the user to allow him to access the features corresponding to his purchases.
  • Consumable purchases:
    The consumable products of an application can be purchased several times by the same user. Once purchased, they produce a temporary effect until they are consumed by the application. After their consumption, the user has the ability to purchase the consumed product again.
    Example: Watching a movie in streaming
    • From an application, the user purchases the "Movie in streaming" product that allows him to watch the movie of his choice during one week from his application.
    • When the purchase is validated, the application asks the user to choose the movie to watch.
    • Before watching a movie, the application retrieves the user purchases to check whether he actually purchased the corresponding product.
    • If the purchase date of the product is less than one week, the user start watching the movie. Otherwise, the product must be consumed before it can be purchased again by the user.
  • The "In-App" purchase functions are not supported in the emulator or in the simulator. Furthermore, the device on which the application is run must be running a recent version of the Google Play application (installed by default on most of the devices).
  • Purchasing a subscription:
    • The subscriptions are used to sell content, services or features in your application with an automatic and recurring invoicing (every week, every month, every quarter, etc.).
    • The subscriptions are automatically renewed according to the interval and to the price defined in the subscription setting via the Google Play developer console.
      Whenever renewing the subscription, Google Play automatically invoices the user account and sends an email to the user.
    • A user can cancel his subscription at any time via the form of the corresponding application in the Google Play Store application (this form can be opened from the application with AppOpenForm). When the user cancels his subscription, he can still access the content of his subscription for the rest of time that was already paid.
    • A user can also renew a subscription, it is automatically extended from the corresponding period.
Remarks:
  • Only the consumable and non-consumable products as well as the subscriptions are supported. The other types of products are not supported.
  • You cannot manage the downloadable content in the products.
  • You have the ability to open the form for configuring the In-App purchases of an application via AppOpenForm.
Implementation
iPhone/iPad

iOS application

To implement the "In-App" purchases in an iOS application:
  1. Develop the iOS application by using the specific WLanguage functions:
    inAppListProductInfoRetrieves, from the store, information about the "In-App" products associated with the application.
    inAppListPurchaseReturns the list of application products purchased by the user and not consumed.
    inAppPurchaseProductSends a request for purchasing an "In-App" product associated with the application.
    inAppRestorePurchasesRestores the purchases of non-consumable products previously performed by the user in an iOS application.
    The inAppProduct variable manages products in an In-App purchase.
  2. Connect to iTunesConnect then to the account of your application. For more details, see Deploying an application via App Store.
  3. Click the "Manage In-App Purchases" button.
  4. Create one or more products ("Create New" button). Only the consumable and non-consumable products are available in the WINDEV Mobile applications. The characteristics of these products (mainly Identifier) are used in the WINDEV Mobile application to identify the products to handle.
  5. Generate your application and deploy it on the store.
Android

Android application

To implement the "In-App" purchases in an Android application:
  1. Save the application in the Google Play developer console.
  2. Develop the Android application by using the specific WLanguage functions:
    inAppConsumeProductUsed to consume, in an application, a product that was previously purchased by the user.
    inAppListProductInfoRetrieves, from the store, information about the "In-App" products associated with the application.
    inAppListPurchaseReturns the list of application products purchased by the user and not consumed.
    inAppPurchaseProductSends a request for purchasing an "In-App" product associated with the application.
    The inAppProduct variable manages products in an In-App purchase.
  3. Generate the application.
  4. Import the application into the Google Play developer console.
  5. Create the "In-App" products in the Google Play developer console.
  6. Test the application. You have the ability to specify the test user accounts in the Google Play developer console.
Minimum version required
  • Version 19
Comments
Click [Add] to post a comment

Last update: 03/09/2023

Send a report | Local help