Table of contents



Official Content

The StoreManager external object is a component allows you to manage In-App Purchases in your applications.

StoreManagerexternalobject-Location_png image_2018613101838_1_png

Properties

CanMakePurchases property

Allows you to know if the device can make purchases (True) or not (False). For example, it can be used to restrict purchases if the device does not admit them.

Methods

GetProducts method

Given a list of products, returns a collection with detailed information about them. Useful to get the title in the user's local language and the price in the user's local currency.

Return value  StoreProduct
Parameters ProductIdentifications:Collection(VarChar(100))
   

PurchaseProduct method

Sends the purchase request of the given product to the platform's In-App Purchases store.

Note: On Android, the Quantity parameter only accepts the value 1 because every product can be purchased or not purchased.

Return value  StoreProduct
Parameters ProductIdentifier:VarChar(100), [ , Quantity:Numeric(8.0) ]
   

GetPurchases method

Gets a list of information of the user's purchased products.

Return value  PurchasesInformation
Parameters None
   

ConsumeProduct method

Consumes a product for which the user has a purchase and returns the success status.

Return value  Boolean
Parameters ProductIdentifier:VarChar(100)
   

RestorePurchases method

Only available for iOS. Restore the purchases through the device.

Return value  PurchasesInformation
Parameters None
   

Events

PurchaseStateChange event

This event only applies to iOS. When a purchase is made, this event will be called indefinitely if the Handled parameter is set to False until the developer sets it to True. The reason for this behavior is that iOS does not persist the information of a purchase (as Android does) when the product type is consumable. A typical scenario might occur when the app crashes without the response of the store platform after a transaction request. In such case, the purchase can be processed when the app is opened again. It's the responsibility of the developers to persist in their systems the user status in relation to the billings (in replacement of EnableProduct or DisableProduct deprecated methods --- see the previous version of this document for details).

Input Purchase:PurchaseResult, PurchaseState:StorePurchaseState, Handled:Boolean
Output  None
   

Domains

StorePurchaseState domain

Set of state values of a purchase. Only applies for iOS.

Purchased  When the purchase was successful.
Failed When the purchase fails.
Restored When the purchases are restored.
Deferred When the purchase depends on parental control.
   

StorePurchasePlatform domain

Store platforms where the purchase was made.

GooglePlay  Google Play (for Android) as store platform.
iTunes iTunes (for iOS) as store platform.
   

StoreProductType domain

Nature of the purchased product.

Subscription  The purchase is a subscription.
Product The purchase is a product.
   

StorePurchaseStatus domain

Status of a purchase after it has been validated with the platform stores (Google/Apple).

Invalid The purchase is invalid.
Valid The purchase is valid.
Expired Indicate if the purchase of a subscription has been expired.
Canceled  On iOS indicate if the purchase has been canceled by the Apple Store Support Team.
On Android, if the purchase has been canceled by the user, or if the purchase is a subscription canceled by the system (e.g. billing problem)  
Deferred The purchase is waiting for validation of parental control.
   

Structured Data Types

PurchaseResult

  • Success:Boolean
    Indicates if the purchase process was successfully completed.
     
  • PurchaseId:VarChar(100)
    Purchase identifier from the platform store.
     
  • PurchasePlatform:StorePurchasePlatform 
    Store platform where the purchase was made.
     
  • ProductIdentifier:VarChar(100)
    Purchased product identifier.
     
  • TransactionData:VarChar(100)
    Encrypted data of the purchase transaction.
     

PurchaseInformation

Given a platform store, it keeps the information of a collection of purchases.

  • Purchases:Collection( PurchaseResult )
    Collection of purchase result for each product queried.
     
  • Receipt:LongVarChar(2M)
    Receipt information retrived from Apple.
     
  • PurchasePlatform:StorePurchasePlatform
    The store platform where the purchase was made.
     

StoreProduct

  • LocalizedTitle:VarChar(100)
    Product title in the user local language.
     
  • LocalizedDescription:VarChar(100)
    Product description in the user local language.
     
  • LocalizedPriceAsString:VarChar(100)
    String with the product price indicated in the user local currency.
     
  • Identifier:VarChar(100)
    Product identifier.
     
  • Purchased:Boolean
    Indicates if the product has been purchased by the user.
     

Notes

  • The concept of "enable a product" introduced in the PurchaseStateChange event section is only applicable for iOS that manages the purchases on the client-side. Android, on the other hand, centralizes the purchases on the Google Play's servers and it only notices when a product was purchased or not. For example, the "enable" concept allows the developer to implement a gift-mechanism on the device (i.e. under certain conditions, it is possible to enable a product for free). The same scenario on Android can be solved from the Google Play's console using In-app Promotion codes.
  • In order to simulate the "deferred" state in iOS, the developer can add the GXSimulateAskToByInSandbox key into the generated project adopting boolean value.
    A typical scenario is when the app is installed in a children's device and the developer uses Progress.Show() while the purchase is being validated. If the parent takes a long time to validate or reject the request of its child, the progress status will be displayed indefinitely. 

Scope

Generators: Apple, Android

See also

What is an In-App Purchase
How to configure In-App Billing in an Android application
In-App Purchase Sample - Classified Ads
In-App Purchase Sample - My Kitchen

  

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant