Yesterday I have published my first app on the Appstore and all my clients faced the same problem. When they made a subscription for trial or even purchase - the operation ended up with success. They received the receipt from Apple about it or money were taken from their account (in case of in-app purchase) but then they fall into this error: "Purchase succeeded but program is not active". From my code this means that entitlement is not active. here is the code:
Purchases.shared.purchase(package: package) { (transaction, customerInfo, error, userCancelled) in
if let error = error {
completion(.failure(error))
print("error - failed to complete the purchase")
} else {
if customerInfo?.entitlements[program]?.isActive == true {
completion(.success(true))
} else {
print ("Purchase succeeded but program is not active")
let error = NSError(domain: "com.example.purchase", code: 0, userInfo: [NSLocalizedDescriptionKey: "Purchase succeeded but program is not active"])
completion(.failure(error))
}
}
}
I have checked all this clients in the Revenue Cat dashboard and I can see that all the entitlements for product that they have purchased or subscribed are active, but they still can’t access products that they have purchased. Here is how I check the subscription:
public func checkCustomerStatus(program: String, completion: @escaping (Bool) ->()) {
Purchases.shared.getCustomerInfo { customer, error in
if let error = error {
print (error.localizedDescription)
} else {
if customer?.entitlements[program]?.isActive == true {
completion(true)
} else {
completion(false)
}
}
}
}
This method should check for the particular program status and if the entitlement is active - it grants access to that content. During sandbox testing it all worked fine everywhere - on a simulator, on a physical device, in Test Flight. But in production something went absolutely wrong (((
I also have a method to show the entitlement status for each of my products and they all return “Not active”:
// method fetching subscription status for each plan to show it in Settings VC
public func getSubscriptionStatus(program: String, completion: @escaping (Bool, UIColor, String) -> ()) {
Purchases.shared.getCustomerInfo {customerInfo, error in
if let error = error {
print(error.localizedDescription)
} else {
if customerInfo?.entitlements[program]?.isActive == true {
let formatter = DateFormatter()
formatter.dateStyle = .medium
let currentLanguage = LanguageManager.shared.currentLanguage
if currentLanguage.rawValue == "ru" {
formatter.locale = Locale(identifier: "ru_RU")
} else {
formatter.locale = Locale(identifier: "en_US")
}
if let date = customerInfo?.expirationDate(forEntitlement: program) {
let subscriptionPeriod = formatter.string(from: date)
let color = UIColor.systemGreen
let activeUntil = String(format: "until %@".localized(), subscriptionPeriod)
completion(true, color, activeUntil)
} else {
let purchased = "purchased".localized()
let color = UIColor.systemGreen
completion(true, color, purchased)
}
} else {
let message = String(format: "not active".localized(), program)
let color = UIColor.systemYellow
completion(false, color, message)
}
}
}
}
I do all the same with my account, I tried to restore purchases, to delete and reinstall the app - no help, I see the active entitlements in the RevenueCat dashboard, but in the app they are not active.
Please, help me to solve this problem ASAP as my app is already on sale and some of the users may purchase my products that won’t be accessed afterwards (((