ProductView failed to trigger purcahse flow.

Hi,

My app has an IAP and the view that let user to purchase is simply a ProductView. The purchase flow should be handled by the ProductView itself. I have tested the app with xcode storekit configuration, xcode run with sandbox account and also TestFlight environment as well. The purchase is triggered and the app feature is unlocked after purchase. However, I keep getting app review team feedback with the following problem:

Bug description: the purchase button is greyed out after we tapped on it, however, there's no purchase flow popped up

I have tried multiple things. Building with xcode cloud, removing the storekit configuration from the build scheme. But none can get the app review team to get through the problem.

The IAP is not available in certain region. In that case, the app will show a message. However, the app review attached an screenshot which shows the product view.

The view that allow users to purchase

                if let product = store.products.first(where: { $0.id == "com.xxx.xxxxxxx" }) {
                    // If the product is available, show the ProductView
                    ProductView(id: product.id)
                        .productViewStyle(.compact)
                } else {
                    // If the product is not available, show a message
                    Text("In-app purchase is not available in your region.")
                }

The store class

    @Published private(set) var products: [Product] = []
...
    init() {
        //To handle the parental approval flow
        getUpdateTransaction()
        
    }
    
    func getUpdateTransaction() {
        updates = Task {
            for await update in StoreKit.Transaction.updates {
                if let transaction = try? update.payloadValue {
                    await fetchActiveTransactions()
                    await transaction.finish()
                }
            }
        }
    }

Does anyone what can go wrong with ProductView? As this is part of the StoreKit API, I don't know what can go wrong. At least the purchase flow should be covered by it.

Also, is sandbox and TestFlight a good way to test IAP?

Thanks!

Hi,

Some good news! I finally decided to try another route to get around this. The app review team finally approved my app. I still don't know what happened to the ProductView. The handling for transaction could go wrong but the purchase flow should be triggered correctly.

Simply replace the product view with some custom code

                     if store.activeTransactions.isEmpty {
                         ForEach(store.products, id: \.id) { product in
                             Button {
                                 Task {
                                     try await store.purchase(product)
                                 }
                             } label: {
                                 VStack {
                                     Text(verbatim: product.displayName)
                                         .font(.headline)
                                     Text(verbatim: product.displayPrice)
                                 }
                             }
                             .buttonStyle(.borderedProminent)
                         }

And in the Store class

    func purchase(_ product: Product) async throws {
        let result = try await product.purchase()
        switch result {
        case .success(let verificationResult):
            if let transaction = try? verificationResult.payloadValue {
                activeTransactions.insert(transaction)
                await transaction.finish()
            }
        case .userCancelled:
            break
        case .pending:  
            break
        @unknown default:
            break
        }
    }
ProductView failed to trigger purcahse flow.
 
 
Q