Question

After successful purchase the purchase method falls into the error as if entitlement is not activated

  • 9 July 2023
  • 2 replies
  • 36 views

Badge +2

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 ((( 


2 replies

Badge +2

Update… I found out the problem - it is within my products names localisation, so its all my fault 😓 

Userlevel 4
Badge +6

Hey @Maria Mezhova ,

Glad to hear that you found the issue! I hope it didn’t cause too much headache. Congrats on launching your app!

Reply