Skip to content

Purchase or Subscribe

Mansour edited this page Aug 3, 2021 · 1 revision



I. Purchase a product:

productId -> This is the product id that you have defined inside of the developer's panel.
type -> Call Subscribe method with Payment.Type.subscription enum. default value is Payment.Type.inApp.
onStart -> Called while purchase-flowith w have been started.
onComplete -> Called when purchase-flow was acomplished.
payload -> This can be an empty string or anything else that you wish, but it's a good practice to actually pass in some data to help you to verify the purchase.
dynamicPriceToken -> This is a token that the developer can apply to any player to change the price of the product, for more info about this please read the site documentation

Okay, so now you can easily call Purchase function in Payment class.

Using async :

var result = await payment.Purchase("PRODUCT_ID");
Debug.Log($"{result.message}, {result.stackTrace}");
if (result.status == Status.Success)
{
    var purchase = result.data;
    Debug.Log(purchase.ToString());
}

Using start and complete callbacks with payload data :

_ = payment.Purchase("PRODUCT_ID", Payment.Type.inApp, OnPuschaseStart, OnPuschaseComplete, "PAYLOAD");



II. Subscribe a product:

For subscribe absolutely sush purchase method, justyou have set type to Payment.Type.subscription enum.
Using async :

var result = await payment.Purchase("PRODUCT_ID", Payment.Type.subscription);
Debug.Log($"{result.message}, {result.stackTrace}");
if (result.status == Status.Success)
{
    var purchase = result.data;
    Debug.Log(purchase.ToString());
}

Using start and complete callbacks with payload data :

_ = payment.Purchase("PRODUCT_ID", Payment.Type.subscription, OnSubscribeStart, OnSubscribeComplete, "PAYLOAD");





Last Step: Consumption

Clone this wiki locally