Closed tangerinegit closed 3 years ago
Hey @tangerinegit, the problem is caused, becaused you are trying to consume a subscription. Subscriptions are non-consumable. Only product purchases can be consumed. So if you are working with subscriptions only, you should remove the consume call. If you have both subscriptions and products that need to be consumed, you need to have a check and only call consume for the in-app products and not the subscriptions. That's why in the readme i'm checking the product ID to have .consume
before I make a call to the consume method:
purchase.on(purchase.transactionUpdatedEvent, (transaction: Transaction) => {
if (transaction.transactionState === TransactionState.Purchased && transaction.productIdentifier.indexOf(".consume") >= 0) {
purchase.consumePurchase(transaction.transactionReceipt)
.then((responseCode) => console.log(responseCode)) // If responseCode === 0 the purchase has been successfully consumed
.catch((e) => console.log(e));
}
});
But you can change this to whatever works in your case.
Thank you @PeterStaev
Hello,
I am testing on a physical device deploying from VS Code directly. Not sure if this could be the cause for this issue. The product I am exposing to the customer is a subscription. Here is my code:
Everything works well, except that the purchase.consumePurchase returns the Invalid sku type error. The transaction receipt is a string like llbggebdncolcmklgdebdeij.AO-J1OyYvj_OU8HJJ0e8tYtSeXRl8kKH6tOgaaaaaQNecXwRS3gTuX98VIvbKmvyPWbH0L9Mz-kJpC88G5tZIfnfd8c-axb3lIhKwqBAU9REkIDuOmL1Ao8.
I can see the subscription being purchased in my Google Play account.
I am not sure what I am doing wrong. Did I miss anything?
Thanks.