InApps C++
Data Structures | Public Types | Public Member Functions | Static Public Member Functions
ludei::inapps::InAppService Class Referenceabstract

Data Structures

struct  Error
 

Public Types

typedef std::function< void(const std::vector< InAppProduct > &products, const InAppService::Error &error)> FetchCallback
 
typedef std::function< void(const InAppService::Error &error)> RestoreCallback
 
typedef std::function< void(const InAppPurchase &purchase, const InAppService::Error &error)> PurchaseCallback
 
typedef std::function< void(int32_t consumed, const InAppService::Error &error)> ConsumeCallback
 
typedef std::function< void(const InAppService::Error &error)> ValidationCompletion
 
typedef std::function< void(const string &receipt, const string &productId, const ValidationCompletion &completion)> ValidationHandler
 

Public Member Functions

virtual void addPurchaseObserver (InAppPurchaseObserver *observer)=0
 
virtual void removePurchaseObserver (InAppPurchaseObserver *observer)=0
 
virtual void start ()=0
 
virtual void fetchProducts (const std::vector< string > &productIds, const FetchCallback &callback)=0
 
virtual std::vector< InAppProductgetProducts () const =0
 
virtual void mapProductIds (const std::map< string, string > &productsMap)=0
 
virtual bool productForId (const string &productId, InAppProduct *product) const =0
 
virtual bool isPurchased (const string &productId) const =0
 
virtual int32_t stockOfProduct (const string &productId)=0
 
virtual void restorePurchases (const RestoreCallback &callback)=0
 
virtual bool canPurchase () const =0
 
virtual void purchase (const string &productId, int32_t quantity, const PurchaseCallback &callback)=0
 
void purchase (const string &productId, const PurchaseCallback &callback)
 
virtual void consume (const string &productId, int32_t quantity, const ConsumeCallback &callback)=0
 
virtual void finishPurchase (const string &transactionId)=0
 
virtual void setValidationHandler (const ValidationHandler &handler)=0
 
virtual void setLudeiServerValidationHandler ()=0
 

Static Public Member Functions

static InAppServicecreate (InAppProvider provider=InAppProvider::AUTO)
 
static InAppServicecreate (const char *className)
 

Detailed Description

The InApp service.

Member Typedef Documentation

typedef std::function<void(int32_t consumed, const InAppService::Error & error)> ludei::inapps::InAppService::ConsumeCallback

The consume callback.

Parameters
consumedThe quantity of product consumed.
errorThe error description if the process fails.
typedef std::function<void(const std::vector<InAppProduct> & products, const InAppService::Error & error)> ludei::inapps::InAppService::FetchCallback

The fetch callback.

Parameters
productsThe fetched products.
errorThe error description if the process fails.
typedef std::function<void(const InAppPurchase & purchase, const InAppService::Error & error)> ludei::inapps::InAppService::PurchaseCallback

The purchase callback.

Parameters
purchaseThe purchase information.
errorThe error description if the process fails.
typedef std::function<void(const InAppService::Error & error)> ludei::inapps::InAppService::RestoreCallback

The restore callback.

Parameters
errorThe error description if the process fails.
typedef std::function<void(const InAppService::Error & error)> ludei::inapps::InAppService::ValidationCompletion

Defines the validation completion.

Parameters
receiptThe receipt.
productIdThe id of the product.
completionCompletion.
typedef std::function<void(const string & receipt, const string & productId, const ValidationCompletion & completion)> ludei::inapps::InAppService::ValidationHandler

Defines the validation handler.

Parameters
receiptThe receipt.
productIdThe id of the product.
completionCompletion.

Member Function Documentation

virtual void ludei::inapps::InAppService::addPurchaseObserver ( InAppPurchaseObserver observer)
pure virtual

Adds an Inapp observer to the process.

Parameters
observerAn InApp observer.
virtual bool ludei::inapps::InAppService::canPurchase ( ) const
pure virtual

Resturs YES if the service is available

Returns
True if the service is available and False otherwise.
virtual void ludei::inapps::InAppService::consume ( const string &  productId,
int32_t  quantity,
const ConsumeCallback callback 
)
pure virtual

Consumes a consumable item.

Parameters
productIdThe id of the product.
quantityThe quantity.
callbackThe ConsumeCallback.
static InAppService* ludei::inapps::InAppService::create ( InAppProvider  provider = InAppProvider::AUTO)
static

Creates a new InAppService

Parameters
providerThe InApp Provider that will be used or AUTO to automatically select the one linked within the binary
Returns
The InAppService with the selected provider or NULL if the provider is not available
static InAppService* ludei::inapps::InAppService::create ( const char *  className)
static

Creates a new InAppService

Parameters
classNameThe className of the provider
Returns
The InAppService with the selected provider or NULL if the provider is not available
virtual void ludei::inapps::InAppService::fetchProducts ( const std::vector< string > &  productIds,
const FetchCallback callback 
)
pure virtual

Requests information about products from the remote Store. Products are cached in a local DB (

See also
getProducts)
Parameters
productIdsThe ids of all the fetched products.
callbackThe FetchCallback.
virtual void ludei::inapps::InAppService::finishPurchase ( const string &  transactionId)
pure virtual

Removes a finished purchase transaction from the queue.

Parameters
transactionIdTransaction id.
virtual std::vector<InAppProduct> ludei::inapps::InAppService::getProducts ( ) const
pure virtual

Returns the cached products.

Returns
The products.
virtual bool ludei::inapps::InAppService::isPurchased ( const string &  productId) const
pure virtual

Check if a product has been previously purchased.

Parameters
productIdthe id of the product.
Returns
True if the product has been purchased and false otherswise.
virtual void ludei::inapps::InAppService::mapProductIds ( const std::map< string, string > &  productsMap)
pure virtual

Asociates an alias to each productId.

Parameters
productsMapThe map containing the aliases as keys and the real productId as values.
virtual bool ludei::inapps::InAppService::productForId ( const string &  productId,
InAppProduct product 
) const
pure virtual

Gets a product given its id.

Parameters
productIdThe id of the product.
productThe product returned by reference
Returns
True if the products exits.
virtual void ludei::inapps::InAppService::purchase ( const string &  productId,
int32_t  quantity,
const PurchaseCallback callback 
)
pure virtual

Purchases a quantity of a specific product.

Parameters
productIdThe id of the product.
quantityThe quantity.
callbackThe PurchaseCallback
void ludei::inapps::InAppService::purchase ( const string &  productId,
const PurchaseCallback callback 
)
inline

Purchases a product.

Parameters
productIdThe id of the product.
callbackThe PurchaseCallback.
virtual void ludei::inapps::InAppService::removePurchaseObserver ( InAppPurchaseObserver observer)
pure virtual

Removes an Inapp observer from the process.

Parameters
observerAn InApp observer.
virtual void ludei::inapps::InAppService::restorePurchases ( const RestoreCallback callback)
pure virtual

Restores already completed transactions and purchases.

Parameters
callbackThe RestoreCallback.
virtual void ludei::inapps::InAppService::setLudeiServerValidationHandler ( )
pure virtual

Use Ludei's server to validate purchases. To enable validation using Ludei's server you first need to create an account in Ludei's Cloud server and create a project with you bundleId.

virtual void ludei::inapps::InAppService::setValidationHandler ( const ValidationHandler handler)
pure virtual

Sets a custom purchase validation handler. Purchases are always validated to TRUE by default. Set a custom validation handler to use you own custom server to validate purchases.

Parameters
handlerThe validation handler.
virtual void ludei::inapps::InAppService::start ( )
pure virtual

Starts the service. You should call this method when your InAppPurchaseObservers are already registered.

virtual int32_t ludei::inapps::InAppService::stockOfProduct ( const string &  productId)
pure virtual

Returns the stock of a product given its id.

Parameters
productIdThe id of the product to check.
Returns
The stock of the given product.

The documentation for this class was generated from the following file: