Skip to content

Get Purchases or Subscriptions

Mansour edited this page Mar 7, 2022 · 2 revisions

Get Player Purchases :


You can query player's purchased products by using GetPurchases function in Payment class:

type -> Select product type. default value is Payment.Type.inApp.

Using async :

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

Using callback :

_ = payment.GetPurchases(Payment.Type.inApp, OnReceiveOwnedProducts);
void OnReceiveOwnedProducts(OwnedProductsResult result)
{
    Debug.Log($"{result.message}, {result.stackTrace}");
    if (result.status == Status.Success)
    {
        foreach (var purchase in result.data)
        {
            Debug.Log(purchase.ToString());
        }
    }
}



Get Player Subscriptions :


You can query player's subscribed products by using GetPurchases function in Payment class:

type -> Select product type. You have to set Payment.Type.subscription for get player subscription items.

Using async :

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

Using callback :

_ = payment.GetPurchases(Payment.Type.subscription, OnReceiveOwnedProducts);
void OnReceiveOwnedProducts(OwnedProductsResult result)
{
    Debug.Log($"{result.message}, {result.stackTrace}");
    if (result.status == Status.Success)
    {
        foreach (var purchase in result.data)
        {
            Debug.Log(purchase.ToString());
        }
    }
}





Fifth Step: Purchase or Subscribe

Clone this wiki locally