@@ -280,7 +280,7 @@ private extension InAppPurchaseStore {
280280}
281281
282282public extension InAppPurchaseStore {
283- enum Errors : String , Error {
283+ enum Errors : Error , LocalizedError {
284284 /// The user canceled the IAP flow
285285 case userCancelled
286286
@@ -320,6 +320,51 @@ public extension InAppPurchaseStore {
320320 /// In-app purchases are not supported for this user
321321 ///
322322 case inAppPurchasesNotSupported
323+
324+ public var errorDescription : String ? {
325+ switch self {
326+ case . userCancelled:
327+ return NSLocalizedString (
328+ " Purchase cancelled by user " ,
329+ comment: " Error message used when the user cancelled an In-app purchase flow " )
330+ case . pending:
331+ return NSLocalizedString (
332+ " Purchase pending " ,
333+ comment: " Error message used when the purchase is pending some user action " )
334+ case . unknownResult:
335+ return NSLocalizedString (
336+ " Unexpected purchase result " ,
337+ comment: " Error message used when a purchase returned something unexpected that we don't know how to handle " )
338+ case . unverifiedTransaction:
339+ return NSLocalizedString (
340+ " The purchase transaction couldn't be verified " ,
341+ comment: " Error message used when a purchase was successful but its transaction was unverified " )
342+ case . transactionMissingAppAccountToken:
343+ return NSLocalizedString (
344+ " Purchase transaction missing account information " ,
345+ comment: " Error message used when the purchase transaction doesn't have the right metadata to associate to a specific site " )
346+ case . appAccountTokenMissingSiteIdentifier:
347+ return NSLocalizedString (
348+ " Purchase transaction can't be associated to a site " ,
349+ comment: " Error message used when the purchase transaction doesn't have the right metadata to associate to a specific site " )
350+ case . transactionProductUnknown:
351+ return NSLocalizedString (
352+ " Purchase transaction received for an unknown product " ,
353+ comment: " Error message used when we received a transaction for an unknown product " )
354+ case . storefrontUnknown:
355+ return NSLocalizedString (
356+ " Couldn't determine App Stoure country " ,
357+ comment: " Error message used when we can't determine the user's App Store country " )
358+ case . missingAppReceipt:
359+ return NSLocalizedString (
360+ " Couldn't retrieve app receipt " ,
361+ comment: " Error message used when we can't read the app receipt " )
362+ case . inAppPurchasesNotSupported:
363+ return NSLocalizedString (
364+ " In-app purchases are not supported for this user yet " ,
365+ comment: " Error message used when In-app purchases are not supported for this user/site " )
366+ }
367+ }
323368 }
324369
325370 enum Constants {
0 commit comments