diff --git a/android/src/com/mapswithme/maps/Framework.java b/android/src/com/mapswithme/maps/Framework.java index b3b6f8d864..5f6637aa28 100644 --- a/android/src/com/mapswithme/maps/Framework.java +++ b/android/src/com/mapswithme/maps/Framework.java @@ -104,12 +104,14 @@ public class Framework public static final int TOKEN_MAPSME = 3; @Retention(RetentionPolicy.SOURCE) - @IntDef({ PURCHASE_VERIFIED, PURCHASE_NOT_VERIFIED, PURCHASE_VALIDATION_SERVER_ERROR }) + @IntDef({ PURCHASE_VERIFIED, PURCHASE_NOT_VERIFIED, + PURCHASE_VALIDATION_SERVER_ERROR, PURCHASE_VALIDATION_AUTH_ERROR }) public @interface PurchaseValidationCode {} public static final int PURCHASE_VERIFIED = 0; public static final int PURCHASE_NOT_VERIFIED = 1; public static final int PURCHASE_VALIDATION_SERVER_ERROR = 2; + public static final int PURCHASE_VALIDATION_AUTH_ERROR = 3; @SuppressWarnings("unused") public interface MapObjectListener diff --git a/android/src/com/mapswithme/maps/purchase/ValidationStatus.java b/android/src/com/mapswithme/maps/purchase/ValidationStatus.java index 24c1f383a1..4f521b03eb 100644 --- a/android/src/com/mapswithme/maps/purchase/ValidationStatus.java +++ b/android/src/com/mapswithme/maps/purchase/ValidationStatus.java @@ -4,5 +4,6 @@ public enum ValidationStatus { VERIFIED, NOT_VERIFIED, - SERVER_ERROR + SERVER_ERROR, + AUTH_ERROR } diff --git a/iphone/Maps/Core/InappPurchase/IMWMPurchaseValidation.h b/iphone/Maps/Core/InappPurchase/IMWMPurchaseValidation.h index 51904342c3..ad3d58c00a 100644 --- a/iphone/Maps/Core/InappPurchase/IMWMPurchaseValidation.h +++ b/iphone/Maps/Core/InappPurchase/IMWMPurchaseValidation.h @@ -4,6 +4,7 @@ typedef NS_ENUM(NSUInteger, MWMPurchaseValidationResult) { MWMPurchaseValidationResultValid, MWMPurchaseValidationResultNotValid, MWMPurchaseValidationResultError, + MWMPurchaseValidationResultAuthError, }; typedef void (^ValidatePurchaseCallback)(MWMPurchaseValidationResult validationResult); diff --git a/iphone/Maps/Core/InappPurchase/Impl/MWMPurchaseValidation.mm b/iphone/Maps/Core/InappPurchase/Impl/MWMPurchaseValidation.mm index 119eb4f6d8..6efd6c9821 100644 --- a/iphone/Maps/Core/InappPurchase/Impl/MWMPurchaseValidation.mm +++ b/iphone/Maps/Core/InappPurchase/Impl/MWMPurchaseValidation.mm @@ -43,6 +43,9 @@ case Purchase::ValidationCode::ServerError: { [self validationComplete:MWMPurchaseValidationResultError]; break; + case Purchase::ValidationCode::AuthError: + [self validationComplete:MWMPurchaseValidationResultAuthError]; + break; } } diff --git a/iphone/Maps/Core/InappPurchase/Impl/PaidRoutePurchase.swift b/iphone/Maps/Core/InappPurchase/Impl/PaidRoutePurchase.swift index 4e44afbb05..fb78850219 100644 --- a/iphone/Maps/Core/InappPurchase/Impl/PaidRoutePurchase.swift +++ b/iphone/Maps/Core/InappPurchase/Impl/PaidRoutePurchase.swift @@ -81,7 +81,8 @@ final class PaidRoutePurchase: NSObject, IPaidRoutePurchase { self?.storePaymentCompletion?(.error, RoutePurchaseError.validationFailed) case .error: self?.storePaymentCompletion?(.error, RoutePurchaseError.validationError) - + case .authError: + break // TODO(@beloal) } self?.storePaymentCompletion = nil }) diff --git a/iphone/Maps/Core/InappPurchase/Impl/PendingTransactionsHandler.swift b/iphone/Maps/Core/InappPurchase/Impl/PendingTransactionsHandler.swift index c251716a1a..b2d1260672 100644 --- a/iphone/Maps/Core/InappPurchase/Impl/PendingTransactionsHandler.swift +++ b/iphone/Maps/Core/InappPurchase/Impl/PendingTransactionsHandler.swift @@ -22,6 +22,8 @@ final class PendingTransactionsHandler: IPendingTransactionsHandler { fallthrough case .error: completion(.error) + case .authError: + break // TODO(@beloal) } } break diff --git a/iphone/Maps/Core/Subscriptions/MWMPurchaseManager.mm b/iphone/Maps/Core/Subscriptions/MWMPurchaseManager.mm index 43393eed48..9df97ac905 100644 --- a/iphone/Maps/Core/Subscriptions/MWMPurchaseManager.mm +++ b/iphone/Maps/Core/Subscriptions/MWMPurchaseManager.mm @@ -83,6 +83,7 @@ [self invalidReceipt]; break; case Purchase::ValidationCode::ServerError: + case Purchase::ValidationCode::AuthError: [self serverError]; break; } diff --git a/map/purchase.cpp b/map/purchase.cpp index 0668a9e2e1..8fc408026d 100644 --- a/map/purchase.cpp +++ b/map/purchase.cpp @@ -240,6 +240,10 @@ void Purchase::ValidateImpl(std::string const & url, ValidationInfo const & vali { code = ValidationCode::Verified; } + else if (resultCode == 403) + { + code = ValidationCode::AuthError; + } else if (resultCode >= 400 && resultCode < 500) { code = ValidationCode::NotVerified; diff --git a/map/purchase.hpp b/map/purchase.hpp index 84d6ac8b78..95f9ddcd80 100644 --- a/map/purchase.hpp +++ b/map/purchase.hpp @@ -34,6 +34,7 @@ public: Verified, // Purchase is verified. NotVerified, // Purchase is not verified. ServerError, // Server error during validation. + AuthError, // Authentication error during validation. }; struct ValidationInfo @@ -42,7 +43,7 @@ public: std::string m_vendorId; std::string m_receiptData; - // "We do not check serverId here, because it can be empty in some cases." + // We do not check serverId here, because it can be empty in some cases. bool IsValid() const { return !m_vendorId.empty() && !m_receiptData.empty(); } };