Closed sabiland closed 1 year ago
Hi @sabiland, thanks for asking. Yes, it's production ready and I have been using it since I released it. Failed transaction will throw an error from StoreKit framework. Restoring purchases works differently in store kit 2 and Mercato supports it as well. With store kit 2 you can only track non-consumable + subscriptions iaps, Mercato only support subscriptions, but I will add support for non-consumable.
Thx for quick reply. About non-consumable, can I make non-consumable purchase with Mercato? I have already checked about restoring purchases with StoreKit 2, will do it manually for now probably.
And where is Mercato.purchase completion block? Success, etc.? Maybe I don’t yet understand how StoreKit2 and/or Mercato works. EDIT: I saw the StoreKit 2 is handling error messages via popups right?
Ok I think I have managed to refactor first of my apps to StoreKit 2 with the help of Mercato.
Sounds good!
@tikhop Will you allow another question, where are string messages defined for your errors?
I get this for example if I simulate IAP and then cancel it. I know Apple does not allow those kind of messages for the user.
The operation couldn’t be completed. (Mercato.MercatoError error 2.)
public enum MercatoError: Error
{
case storeKit(error: StoreKitError)
case purchase(error: Product.PurchaseError)
case purchaseCanceledByUser
case userCancelledRefundProcess
case purchaseIsPending
case failedVerification
case genericError
}
@sabiland the message comes from the system.
Yes, but it adds extra info e.g. (Mercato.MercatoError error 0.)
. Apple would not allow this kind of message.
So I fixed this by checking for "(" character and remove everything behind.
func cleanPossibleStoreKitAndExtraAddedMessage(input: String) -> String
{
// NOTE: Input can be like this ---> "The operation couldn’t be completed. (Mercato.MercatoError error 0.)"
let splitted = Array(input.components(separatedBy: "("))
return (splitted.first ?? input).fullTrim()
}
In the examples I do not see anywhere switch cases for failed purchasings (as in SwiftyStoreKit, etc.) ?
How about restoring purchases? How to check if IAP was already purchased before? Reinstalling the app, etc.