Restoring expired auto-renewable subscriptions
Asked Answered
P

2

7

Following Apple guides, auto-renewable subscriptions are restorable -> device can send restoreCompletedTransactions to Apple servers and Apple will response with list of all completed transactions.

My question is, does Apple send all completed transactions ever? (only connected with purchasing non-consumable products and auto-renewable subscriptions, ofc)

For example: there is monthly auto-renewable subscription in my app. User installs my app in Jan, 2012. In May, 2012 he disables subscription auto-renewing. After a year, in Jan, 2013, he subscribes again. In March, 2013 he disables subscription auto-renewing again. Finally, in June, 2013 he subscribes again. In July, 2013 he tries to use "Restore purchases" function, what information will Apple send?

What information will Apple send to that device? Will Apple send information about all subscriptions, even those expired subscriptions?

P.S. The sense of a question is to get real experience of working with auto-renewable subscriptions and restoring information about them. Testing in sandbox sometimes returns very strange results.

Edit: Okay, so I have had enough testing to say, that yes, Apple sends all completed transactions ever, including transactions, connected with expired subscription, even if there was another subscription after it.

Pyromagnetic answered 30/7, 2013 at 9:32 Comment(0)
V
1

"Store Kit provides built-in functionality to restore transactions for non-consumable products, auto-renewable subscriptions and free subscriptions. To restore transactions, your application calls the payment queue’s restoreCompletedTransactions method. The payment queue sends a request to the App Store to restore the transactions. In return, the App Store generates a new restore transaction for each transaction that was previously completed. The restore transaction object’s originalTransaction property holds a copy of the original transaction. Your application processes a restore transaction by retrieving the original transaction and using it to unlock the purchased content. After Store Kit restores all the previous transactions, it notifies the payment queue observers by calling their paymentQueueRestoreCompletedTransactionsFinished: method " -- Apple Docs

Villanovan answered 30/7, 2013 at 17:8 Comment(0)
P
1

Well yes, you'll get all the purchase tied to that apple id (including expired ones). You can filter them out in the delegate callback and only send the most recent one to your servers.

- (void)handleRestoredTransaction:(SKPaymentTransaction *)transaction
{

NSLog(@"Somehow a transaction was restored.");

NSDate* receiptPurchaseDate = transaction.transactionDate;
NSDate* currentDate = [NSDate date];

NSTimeInterval daysPassedSincePurchase = [currentDate timeIntervalSinceDate: receiptPurchaseDate] / SECONDS_PER_DAY;

if ([transaction.originalTransaction.payment.productIdentifier isEqualToString: monthlySubscriptionProductIdentifier])
{
    if (daysPassedSincePurchase <= DAYS_PER_MONTH)
    {
        // send the transaction receipt to your servers.
        [self handlePurchasedTransaction: transaction];
    }
}
else if ([transaction.originalTransaction.payment.productIdentifier isEqualToString: yearlySubscriptionProductIdentifier])
{
    if (daysPassedSincePurchase <= DAYS_PER_YEAR)
    {
        [self handlePurchasedTransaction: transaction];
    }
  }
}
Preform answered 3/2, 2015 at 22:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.