jinSasaki / InAppPurchase

A Simple and Lightweight framework for In App Purchase (Store Kit 1)
MIT License
288 stars 30 forks source link

Include the transaction with PaymentState.restored #40

Closed swoolcock closed 3 years ago

swoolcock commented 5 years ago

Helps with #26 but not a complete solution, as the product IDs are not returned in the restore handler. Rather, you would switch on the payment state in the fallback handler.

InAppPurchase.default.addTransactionObserver(fallbackHandler: { result in
    switch result {
    case .success(let state):
        switch state {
        case .purchased(let transaction), .restored(let transaction):
            // update the local cache (UserDefaults, keychain, etc.)
        // ...
        }
    // ...
    }
})

InAppPurchase.default.restore()
jinSasaki commented 3 years ago

Please use after 2.5.0 version! You can get the transaction when restored by PaymentResponse.transaction :)