- 48.0.15
- iOS
When i make a subscription, it works, but then it expires with sandbox. When i try renewing, without even popping up the purchase window it marks it as a successful purchase and returns the old (and expired) receipt. Below is the code I am using for purchases and listeners.
Additional details:
This happens using testflight or via a dev build with Sandbox. Haven’t tested without Sandbox as the app has yet to be published on the app store.
The length of results is 1 and the purchase isn’t acknowledged.
I am acknowledging each purchase in the listener using finishTransactionAsync
InAppPurchases.setPurchaseListener(
({ responseCode, results, errorCode }) => {
if (responseCode === InAppPurchases.IAPResponseCode.OK) {
for (const purchase of results) {
if (purchase.productId === productID) {
InAppPurchases.finishTransactionAsync(
purchase,
true
)
let isSubscriptionValid = true;
if(name != "Replenish Credits") {
var originalPurchaseTime = new Date(purchase.originalPurchaseTime);
var expirationDate = new Date(originalPurchaseTime.getTime() + (30 * 24 * 60 * 60 * 1000));
isSubscriptionValid = expirationDate > new Date();
}
if(isSubscriptionValid) {
this.addReceiptAsync(
name != "Replenish Credits" ? "subscription": "onetime",
purchase.transactionReceipt,
setBotData
);
}
}
}
}
}
);
await InAppPurchases.purchaseItemAsync(productID);
Thanks!