benjaminmayo / merchantkit

A modern In-App Purchases management framework for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consumables get state purchaseUnavailable

peterwarbo opened this issue · comments

I have used MerchantKit with success with non-consumable products but I'm trying to implement consumable products in my app and the state I get is purchaseUnavailable for those products.

Not sure what I'm doing wrong.

Using MerchantKit 0.14.0.

Setup code:

func setup() {
        
        let configuration: Merchant.Configuration = {
            switch Config.environment {
            case .development:
                return .usefulForTestingAsPurchasedStateResetsOnApplicationLaunch
            case .staging, .production:
                return .default
            }
        }()
        
        merchant = Merchant(configuration: configuration, delegate: self, consumableHandler: self)
        merchant.canGenerateLogs = {
            switch Config.environment {
            case .development:
                return true
            case .staging, .production:
                return false
            }
        }()
                
        merchant.register(IAPStore.products)
        merchant.setup()
        
        productInterfaceController = ProductInterfaceController(products: Set(IAPStore.products), with: merchant)
        productInterfaceController.delegate = self
        productInterfaceController.fetchDataIfNecessary()
        productInterfaceController.automaticallyRefetchIfNetworkAvailabilityChanges = true
        
        update(products: Set(IAPStore.products))
    }

Here's a log showing that the non-consumable product (a.x.y) shows up but not the consumable ones.

[Tasks] Started available purchases task for products: ["a.x.y", "b.x.y", "c.x.y", "d.x.y"]
[Tasks] Finished available purchases task: success(MerchantKit.PurchaseSet(storage: ["a.x.y": [Purchase 'a.x.y', price: [Price 12,00 kr]]]))

It was a configuration error on my side.