ti.storekit icon indicating copy to clipboard operation
ti.storekit copied to clipboard

Solution: Fetching latest Subscription Data & Expiration (locally on device)

Open ULSashido opened this issue 1 year ago • 3 comments

const latestReceipt = _.max(Storekit.receiptProperties.purchases, function(purchase) {
    return purchase.transactionIdentifier;
});
Ti.API.info("Storekit Latest ReceiptProperties: " + JSON.stringify(latestReceipt));
const isOngoing = moment().isBefore(moment(latestReceipt.subscriptionExpirationDate));
Ti.API.info("Subscription: " + latestReceipt.productIdentifier + " is Ongoing?:" + isOngoing);
Ti.App.Properties.setBool('Purchased-' + latestReceipt.productIdentifier, isOngoing);

You may want to modify some of your code (especially if it's Subscriptions only (without 1 time IAP) but ongoing subscriptions; Notably the markProductAsPurchased in the example.

ULSashido avatar Apr 06 '23 13:04 ULSashido

How do you activate the subscription again after it has expired? After checking all the expired receipts if I call purchaseProduct I end up in the transactionState listener case TRANSACTION_STATE_PURCHASED with all the expired receipts. I cannot reprocess the payment to restart the new subscription.

For example I purchase monthly subscription and after two months I cancel. Once the period is over how do I restart a new subscription?

ottopic avatar Jun 06 '23 21:06 ottopic

From What I remember, you click the purchase button again. And the subscription starts anew.

I'm guessing you're seeing something else

yozef avatar Jun 07 '23 03:06 yozef

What I imagined, but I do not receive any receipt with a valid expiration date.

ottopic avatar Jun 07 '23 06:06 ottopic