A user may want to restore purchases for a number of reasons. Perhaps they have re-installed the app, switched to a new phone, or even reset their existing phone.
Only unlockable products can be restored.
Restoring purchases are initialized via the restorePurchases() method, which will then call the onPurchaseRestored signal for each purchase that gets restored, as follows:
Button {
text: "Restore Purchases"
onClicked: {
colorProduct.restorePurchases()
}
}
In the product component, it appears as follows:
onPurchaseRestored: {
// handle product
console.log("Product restored "+ transaction.orderId)
}
As you can see, QML makes it super simple to add in-app purchases and even to restore them if and when the need arises.