Annual auto renewal subscription wrong year

Hi, I'm developing my first app with in-app purchase and I'm having this problem:

  • a tester in testFlight is buy the auto renewal annual subscription
  • the purchase process ends correctly
  • the expiration date of the receipt has the actual year and not the next one!

What I'm wrong? Whay the expiration date isn't 2025 instead of 2024 as aspected?

This is the code that verify the receipt:

func verifySubscription() -> Bool {
        guard let receiptData = fetchReceipt() else { return false }
        do {
            let receipt = try InAppReceipt.receipt(from: receiptData)
            let purchases = receipt.purchases
            for purchase in purchases {
                if purchase.productIdentifier == productID {
                    if let expirationDate = purchase.subscriptionExpirationDate { UserDefaults.standard.set(expirationDate.formattedStringWithTimeZone(withFormat: "yyyy-MM-dd HH:mm:ss"), forKey: K.userDefault.subscriptionExpirationDate)
                        return expirationDate > Date()
                    }
                }
            }
        } catch {
        }
        return false
    }

Thanks a lot in advance.

Hello! In testing environment, subscriptions renew faster:

Auto-renewable subscriptions behave differently in the sandbox environment and the production environment. In the sandbox environment, subscription renewals happen at an accelerated rate, and auto-renewable subscriptions renew up to 12 times after the initial purchase. This enables you to test how your app handles a subscription renewal, a subscription lapse, and a subscription history that includes gaps.

Testing an auto-renewable subscription

Also see Manage Sandbox Apple ID settings

Annual auto renewal subscription wrong year
 
 
Q