1. Make a purchase
When Products and Entitlements are set, you can start making purchases with thepurchase() method (Swift) / purchaseWithResult: (Objective-C) on iOS, and purchase() on Android and the cross-platform SDKs.
1.1. Define a specific offer (Android only)
Google Play Billing Library allows you to sell a subscription with different offers. You can get information about available offers fromQProduct.storeDetails. Use one of the following options to provide the chosen offer for the purchase.
removeOffer method of purchase options builder:
2. Handle a purchase result
The purchase method returns a result object on every platform. Inspect its status flags -isSuccess / isCanceled / isPending (or IsSuccess / IsCanceled / IsPending on Unity) - and, when successful, look up the relevant entitlement on result.entitlements. See the per-platform examples above.
Entitlement IDs are the keys to the entitlements map. The values are objects of the Qonversion.Entitlement class.
3. Update purchases (Android only)
Upgrading, downgrading, or changing a subscription on Google Play Store requires setting additional options through thePurchaseOptions builder. See Google Play Documentation for more details.
| Name | Description |
|---|---|
ChargeFullPrice | The new plan takes effect immediately, and the user is charged full price of new plan and is given a full billing cycle of subscription, plus remaining prorated time from the old plan. |
ChargeProratedPrice | The new plan takes effect immediately, and the billing cycle remains the same. |
WithTimeProration | The new plan takes effect immediately, and the remaining time will be prorated and credited to the user. |
Deferred | The new purchase takes effect immediately, the new plan will take effect when the old item expires. |
WithoutProration | The new plan takes effect immediately, and the new price will be charged on next recurrence time. |
WithTimeProration.
4. Multi-quantity purchases (iOS only)
When buying in-app products, you have the option to choose how many items you want to purchase. On Android, you can adjust the quantity directly in the purchase pop-up. However, on iOS, you’ll need to set the quantity beforehand. You can do it while building purchase options as follows:5. Check user entitlements
Use thecheckEntitlements() SDK method in case you want to check users’ entitlements separately from a purchase. Learn more here.
6. Restore purchases
When users, for example, upgrade to a new phone, they need to restore purchases so they can keep access to your premium features. Call therestore() method to restore purchases:
7. Consumable in-app purchases
How to handle consumable in-app purchases in your application. Since consumable in-app purchases do not make sense to tie to a specific entitlement, when making a purchase, you only need to look at the purchase outcome (success/error). If there is an error, do not grant bonuses for the consumable purchase; if the purchase is successful, then grant bonuses. Let’s go through the scenario step by step:- The customer initiates the consumable in-app purchase.
- You call the Qonversion purchase method.
-
You receive a response after the purchase is made.
- Is the response successful? Grant the user bonuses.
- Was there an error? No bonuses should be granted.
Displaying Products Subscription Status