iosswiftsubscriptionauto-renewable

The receipt date does not match to the sandbox duration


My app has auto renewable subscription. I tried to test the correct workflow of the subscription. According to WWDC 2018: enter image description here

I created a new subscription with one week duration. I created a new sandbox user, and tried to activate my new subscription. Here is the code:

guard let httpResponce = responce as? HTTPURLResponse,
    let contentType = httpResponce.allHeaderFields["Date"] as? String,
    let expirationDate = self.parcedReceipt?.inAppPurchaseReceipt?.subscriptionExpirationDate,
    let serverDate = self.parseDateAndTime(getResDate: contentType) else {
        result(false, ReceiptError.unexpectedError.localizedDescription)
        return
}
self.saveDateAndTime(dateForSave: serverDate)
self.ls.pmsg("serverTime:\(serverDate), receiptDate:\(expirationDate)")

I verify date and time with server. The result is the same - I always get receiptDate like: current time + one hour:

XXX.swift validateTimeWithServer(result:) serverTime:2018-07-11 13:18:16 +0000, receiptDate:2018-07-11 14:18:16 +0000

But my subscription is only one week.

enter image description here

Why is this happened? Is it possible that date of the receipt is one hour but in reality the AppStore renew it after 3 min?


Solution

  • This is because of introductory price. If the subscription has an introductory price the subscription period will be wrong. In my case I deleted an introductory price and the duration for a sandbox user started to be 3 min.