Class TInAppPurchases
Unit
Declaration
type TInAppPurchases = class(TComponent)
Description
Manage in-app purchases in your game. See https://castle-engine.io/in_app_purchases for detailed instructions how to use this.
Hierarchy
- TObject
- TPersistent
- TComponent
- TInAppPurchases
Overview
Methods
procedure KnownCompletely; virtual; deprecated 'use RefreshedPrices or RefreshedPurchases'; |
|
procedure RefreshedPrices; virtual; |
|
procedure RefreshedPurchases; virtual; |
|
procedure SuccessfullyConsumed(const AProduct: TInAppProduct); virtual; |
|
procedure Owns(const AProduct: TInAppProduct); virtual; |
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure SetAvailableProducts(const Names: array of string); |
|
procedure SetAvailableProducts(const Products: array of TAvailableProduct); |
|
procedure Purchase(const AProduct: TInAppProduct); |
|
procedure Consume(const AProduct: TInAppProduct); |
|
function Product(const ProductName: string): TInAppProduct; |
|
procedure RefreshPurchases; |
|
procedure DebugClearPurchases; |
Properties
property DebugMockupBuying: boolean
read FDebugMockupBuying write FDebugMockupBuying default false; |
|
property OnRefreshedPrices: TNotifyEvent read FOnRefreshedPrices write FOnRefreshedPrices; |
|
property OnRefreshedPurchases: TNotifyEvent read FOnRefreshedPurchases write FOnRefreshedPurchases; |
Description
Methods
procedure RefreshedPrices; virtual; |
|
See OnRefreshedPrices for information when is this called. The default implementation of this method in this class just calls OnRefreshedPrices. |
procedure RefreshedPurchases; virtual; |
|
See OnRefreshedPurchases for information when is this called. The default implementation of this method in this class just calls OnRefreshedPurchases. |
procedure SuccessfullyConsumed(const AProduct: TInAppProduct); virtual; |
|
Called when the product is successfully consumed, in response to the Consume call. In this class, this simply sets |
procedure Owns(const AProduct: TInAppProduct); virtual; |
|
Called when we know the product is owned, in particular when it's successfully bought. If the product is not consumable (which means that it can be owned only once, and it's owned forever once bought): Note that this method may be called multiple times, because there are various situations in which we may "gain knowledge" that user E.g. if you increase some stat (e.g. "gold owned") when user buys a "chest of gold", and "chest of gold" is non-consumable (you can only own it once, and then you just own it forever), then store the fact that you "already increased gold because of the chest ownership" in the user persistent data (see https://castle-engine.io/manual_user_prefs.php). Do not just increase the "gold owned" at every call of this method. If the product is a consumable, which means it has a one-time use (and should disappear afterwards, until user will buy it again), then:
|
constructor Create(AOwner: TComponent); override; |
|
destructor Destroy; override; |
|
procedure SetAvailableProducts(const Names: array of string); |
|
Initialize a list of products for which to query prices from server. The overloaded version with TAvailableProduct allows to provide additional information to the in-app payment system, see TAvailableProduct docs. |
procedure SetAvailableProducts(const Products: array of TAvailableProduct); |
|
procedure Purchase(const AProduct: TInAppProduct); |
|
Initiate a purchase of given item. |
procedure Consume(const AProduct: TInAppProduct); |
|
Initiate a consumption of a consumable item. You should listen on a "successful consumption" (override SuccessfullyConsumed method and/or watch TInAppProduct.SuccessfullyConsumed) until you actually act on the consumption (increase player gold or such). |
function Product(const ProductName: string): TInAppProduct; |
|
Find product with given name. Creates and adds new product, if not found (useful in case you asked for a product before information about it arrived from the net, or before you even called SetAvailableProducts with it). |
procedure RefreshPurchases; |
|
Call to refresh the state of owned (purchased) items from server. This will call Owns on the owned items, and then RefreshedPurchases or OnRefreshedPurchases. This is necessary to be called explicitly on iOS (for AppStore), as it will ask user to login to AppStore. On Android, this is done automatically at app start, and doesn't ask user anything. |
procedure DebugClearPurchases; |
|
For debug purposes, immediately set all TInAppProduct.Owns to |
Properties
property DebugMockupBuying: boolean
read FDebugMockupBuying write FDebugMockupBuying default false; |
|
Purely for debug purposes, mockup buying (pretend that all purchases succeed). |
property OnRefreshedPrices: TNotifyEvent read FOnRefreshedPrices write FOnRefreshedPrices; |
|
Called when the prices (and other shop-related information) are known about the products. The information is stored inside TInAppProduct instances, e.g. query TInAppProduct.Price, TInAppProduct.Title and so on. Get the TInAppProduct instance by Product method. This signals that we queried the shop for the product information like TInAppProduct.Price and TInAppProduct.Title and TInAppProduct.Description. This is automatically done always when launching the application, and sometimes later too. It does not mean that we have queried the ownership status of the products, for this see OnRefreshedPurchases. See also RefreshedPrices method. Instead of assigning this event, you can also override RefreshedPrices method in descendants. |
property OnRefreshedPurchases: TNotifyEvent read FOnRefreshedPurchases write FOnRefreshedPurchases; |
|
Called when the ownership status of all products is known. The information is stored inside TInAppProduct.Owns, you can get the TInAppProduct instance using the Product method. The ownership status is automatically queried when the application starts on Android. On iOS, it must be explicitly invoked using RefreshPurchases (this is a limitation of iOS user-interface around this, so it cannot be hidden / workarounded by us). |
Generated by PasDoc 0.16.0.