-
Notifications
You must be signed in to change notification settings - Fork 5
Get Purchases or Subscriptions
Mansour edited this page Mar 7, 2022
·
2 revisions
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());
}
}
}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

