Auto-renewing subscription and app receipt

后端 未结 1 913
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 00:09

I want to know if and when the app receipt is automagically refreshed when an IAP auto-renew subscription auto renews. The documentation implies that the app receipt is updated

1条回答
  •  [愿得一人]
    2021-02-06 00:27

    As a side note, the documentation is inconsistent on the types of purchases and their persistence in the receipt -- see my answer to this question.

    The receipt is updated on the server-side when the auto-renew ticks over -- you can confirm this by checking with a call to the server-side validateReceipt method.

    UPDATE: Having seen that you're using RMStore, I mocked something up so that I could look at the behavior.

    It looks to me like the client-side receipt is being updated. My scenario: one month AR subscription (so 5 minute renew in the sandbox). I put some diagnostic code in viewDidLoad:

    RMAppReceipt *receipt = [RMAppReceipt bundleReceipt];
    if (receipt != nil) {
        NSDateFormatter* localDateTime = [[NSDateFormatter alloc] init];
        [localDateTime setTimeZone:[NSTimeZone timeZoneWithName:@"PST"]];
        [localDateTime setDateFormat:@"yyyy.MM.dd HH:mm:ss zzz"];
    
        for (RMAppReceiptIAP* purchase in receipt.inAppPurchases) {
            NSString* cancellationDate = nil;
            if (purchase.cancellationDate) {
                cancellationDate = [localDateTime stringFromDate:purchase.cancellationDate];
            }
            NSLog(@"Transaction: %@: product %@, original purchase date: %@, expiration date: %@, cancellation date: %@",
                  purchase.originalTransactionIdentifier,
                  purchase.productIdentifier,
                  [localDateTime stringFromDate:purchase.originalPurchaseDate],
                  [localDateTime stringFromDate:purchase.subscriptionExpirationDate],
                  cancellationDate);
        }
    

    I also put a breakpoint in RMStore's paymentQueue:updatedTransactions: to see if the queue is updated with subsequent AR purchases.

    I then purchased one month of my test product, verified the transaction and then quit the application.

    On subsequent re-invocations of the application at 5 minute intervals, I then saw the breakpoint in the SKPaymentTransactionObserver method being hit with transactionSate SKPaymentTransactionStatePurchased. The log showed successive additions of the purchases (only last version shown):

    2015-05-27 14:27:32.828 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:02:59 GMT-7, expiration date: 2015.05.27 14:07:58 GMT-7, cancellation date: (null)
    2015-05-27 14:27:33.350 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:06:02 GMT-7, expiration date: 2015.05.27 14:12:58 GMT-7, cancellation date: (null)
    2015-05-27 14:27:33.774 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:11:07 GMT-7, expiration date: 2015.05.27 14:17:58 GMT-7, cancellation date: (null)
    2015-05-27 14:27:34.174 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:16:00 GMT-7, expiration date: 2015.05.27 14:22:58 GMT-7, cancellation date: (null)
    2015-05-27 14:27:34.637 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:21:04 GMT-7, expiration date: 2015.05.27 14:27:58 GMT-7, cancellation date: (null)
    2015-05-27 14:27:35.069 StoreKitSandbox[5803:1054853] Transaction: 1000000156919353: product com.foo.StoreKitSandbox.1_month_autorenew_foo, original purchase date: 2015.05.27 14:26:15 GMT-7, expiration date: 2015.05.27 14:32:58 GMT-7, cancellation date: (null)
    

    Can you repro using this diagnostic approach?

    0 讨论(0)
提交回复
热议问题