Question

Sandbox Purchases get hung and don't properly execute completion

  • 8 July 2023
  • 1 reply
  • 47 views

Badge

I am currently trying to handle purchases using RevenueCat. Everything seems to work fine, except my completion handler does not execute properly. I am currently running iOS16 -- the last of my logs look like this: 

 

2023-07-07 21:46:29.274573-0400 main[1521:253544] [purchases] INFO: 💰 Finishing transaction 'x' for product 'x'

2023-07-07 21:46:29.274658-0400 main[1521:254084] [network] DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue

2023-07-07 21:46:59.258445-0400 main[1521:254760] [tcp] tcp_output [C6.1.1.1:3] flags=[R.] seq=4201476122, ack=584019737, win=2047 state=CLOSED rcv_nxt=584019737, snd_una=4201476045

As you can see, the transaction does not completely finish and thus I cannot properly set the user’s state to subscriptionActive = true. 
The purchase however, will successfully show up on my dashboard. 

Does anyone know a way around this? I’ve tried the documentation and have updated my code to try and use StoreKit1, which it looks like RC does by default now. The code in the bottom is what I have set up -- the button will continually be disabled and the done log will not finish. 

 

               Button(action: {

                    isProcessing = true

                    print("Button pressed")

                    Purchases.shared.purchase(package: selectedPackage!) { transaction, customerInfo, error, userCancelled in

                        // Handle transaction result

                        if customerInfo?.entitlements["Premium"]?.isActive == true {

                            print("Successful Purchase")

                            sessionManager.isSubscriptionActive = true

                        }

                        if let error = error {

                               print("Purchase failed with error: \(error)")

                        }

                        isProcessing = false

                        print("DONE")

                    }

                }) {

                    Text("Purchase")

                        .foregroundColor(.white)

                        .padding()

                        .background(Color.blue)

                        .cornerRadius(10)

                }

                .disabled(isProcessing)


1 reply

Badge

Edit: I’ve solved this by rolling back my RevenueCat version to 4.16.0, and setting my Purchases.configure to use StoreKit2IfAvailable. Not sure which fixed the issue. 

Reply