Skip to main content

Fetching Purchases

When you want to get user's purchase history, you can fetch them via getPurchases and getPurchasesHistory methods of the SDK. All of the previous purchases made for consumable, non-consumable and subcription product types made by user will be return as a result. Even if the purchases which are made by user before the implementing the Appmate SDK will also be return.

Fetching All Purchases#

With calling getPurchasesHistory method of the SDK you can get all of the purchases list made by user. The list returned by this method might be contains purchases which are already consumed or just purchased but not consumed consumable product's purchases. Also might be contains expired/ongoing subscription product's purchases or entitlement granted non-consumable product's purchases. In summary, you get all the purchases made by the user without any filtering.

note

If you did any purchase within our Sandbox Testing process with your test user id, those purchases will be return. You can check the sandbox boolean flag parameter of PurchaseItem object.

Request#

Parameter NameType
listenerReceivedDataListener<List<PurchaseInfo>, GenericError>

Response#

Parameter NameType
onSucceededList<PurchaseInfo>
onFailedGenericError
PurchaseClient.instance.getPurchasesHistory(    object : ReceivedDataListener<List<PurchaseInfo>, GenericError> {        override fun onSucceeded(data: List<PurchaseInfo>) {        }
        override fun onError(error: GenericError) {        }    })

Fetching Current Purchases#

With calling getPurchases method of the SDK you can get the list of purchases which comes with specific filtering rules from the user's purchases. These filtering rules are;

  • Purchased but not consumed purchases
  • Ongoing subscription purchases
note

Purchases which are made before or without Appmate SDK implementation still will be return if they match these filtering rules.

important

When subsscription purchase is made via Google Play or AppGallery Sandbox processes, there might be a grace period defined for purchased product. If you cancelled this subscription from Google Play or AppGallery or unsubscribe within related sdk method, purchase will be still returning if there is a grace period defined before. Subscription purchase will be active until the time set for the grace period ends.

Request#

Parameter NameType
listenerReceivedDataListener<List<PurchaseInfo>, GenericError>

Response#

Parameter NameType
onSucceededList<PurchaseInfo>
onFailedGenericError
PurchaseClient.instance.getPurchases(    object : ReceivedDataListener<List<PurchaseInfo>, GenericError> {        override fun onSucceeded(data: List<PurchaseInfo>) {        }
        override fun onError(error: GenericError) {        }    })

Checking If Product is Purchased#

With calling isProductPurchased method of the SDK you can check whether a product is purchased or not. Once you query a product with productId, a boolean response comes back. True means that the product is purchased.

  • Purchased but not consumed purchases
  • Non-consumable purchases
  • Ongoing subscription purchases

Request#

Parameter NameType
productIdString
listenerReceivedDataListener<Boolean, GenericError>

Response#

Parameter NameType
onSucceededBoolean
onFailedGenericError
PurchaseClient.instance.isProductPurchased(productId,    object : ReceivedDataListener<Boolean, GenericError> {       override fun onSucceeded(status: Boolean) {       }       override fun onError(error: GenericError) {       }    })