ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Mobile specific functions / In-App Purchase functions
  • Special cases
  • Application in the background: Specific case from Android 10
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Sends:
  • a request for purchasing an "In-App" product associated with the application.
  • a request for purchasing a subscription.
Note: The purchase request is asynchronous. A "Callback" procedure is run when receiving the response to the purchase request.
Example
MonProduit is inAppProduct = tabProduit[nIndex]
inAppPurchaseProduct(MonProduit, ValideAchatProduit)
PROCEDURE ValideAchatProduit(bSuccès is boolean, Produit is inAppProduct, Reçu)

IF NOT bSuccès THEN
	ToastDisplay(ErrorInfo())
	RETURN
ELSE
	// Cas Android
	IF InAndroidMode() THEN
		// Consommation du produit (optionnel)
		inAppConsumeProduct(Produit, Reçu, ConsommationProduit)
	END
	// Cas iOS
	IF IniOSMode() THEN
		// Activation du produit dans l'application
		ActiveProduit(Produit)
		// Mémorisation de l'achat dans les préférences de l'application
		SaveParameter(Produit.Identifier, 1)
	END
END
Syntax
iPhone/iPad

iOS: Send a purchase request Hide the details

<Result> = inAppPurchaseProduct(<Product to purchase> , <Quantity> , <WLanguage procedure>)
<Result>: Boolean
  • True if the purchase request was performed,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Product to purchase>: inAppProduct variable
Name of the inAppProduct variable corresponding to:
  • the product to purchase.
  • the subscription to purchase or to renew.
<Quantity>: Integer
Quantity to purchase.
  • For a subscription, this parameter must correspond to 1.
  • If the value of this parameter is equal to 0, <Result> is set to False and the procedure is not called.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") executed when the purchase request response is received. For more details on this procedure, see Parameters of the procedure used by inAppPurchaseProduct.
Android

Android: Send a purchase request Hide the details

<Result> = inAppPurchaseProduct(<Product to purchase> , <WLanguage procedure>)
<Result>: Boolean
  • True if the purchase request was performed,
  • False otherwise. To get more details on the error, use ErrorInfo.
<Product to purchase>: inAppProduct variable
Name of the inAppProduct variable corresponding to:
  • the product to purchase.
  • the subscription to purchase or to renew.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure ("callback") executed when the purchase request response is received. For more details on this procedure, see Parameters of the procedure used by inAppPurchaseProduct.
Remarks

Special cases

  • If the purchase is valid, the application must supply the purchase content to the user.
  • iPhone/iPad If the purchase was performed, the application must store this information. This information can be stored in the preferences by SaveParameter.
  • If inAppPurchaseProduct is used to purchase a subscription that is already active for the user, this subscription is automatically extended for the corresponding period.
  • Android You cannot purchase a product that was already purchased by the user. The product must be consumed (with inAppConsumeProduct) before it can be purchased again.
    inAppListPurchase is used to retrieve the products purchased by the user and not consumed yet.
  • Android You cannot specify the quantity of products to purchase. You must create products corresponding to the desired quantity in the Google Play developer console. Then, the application must manage the use of the purchased quantities.
  • Android You cannot perform several requests for purchase at the same time. You must wait for the response to a request before performing a new request.
  • Android inAppPurchaseProduct has no effect if it is run from the Android simulator or emulator.
Android

Application in the background: Specific case from Android 10

Starting with Android 10, it is no longer possible to open a window when the application is in the background.
inAppPurchaseProduct can open a window. If this function is used while the application is in the background, a fatal error will occur.
Tips:
  • It is possible to determine if the application is in the background using InBackgroundMode.
  • If an application needs to interact with the user while it is in the background, the solution is to display a notification (via the Notification type). The application will be brought back to the foreground when the notification is clicked, if the ActivateApplication property is set to True. You can also open a window from the procedure passed to the ActionClick property.
Component: wd300android.aar
Minimum version required
  • Version 19
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help