forked from organicmaps/organicmaps
Added validation auth error
This commit is contained in:
parent
66ae3bc52e
commit
0498a5b2d1
9 changed files with 20 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -4,5 +4,6 @@ public enum ValidationStatus
|
|||
{
|
||||
VERIFIED,
|
||||
NOT_VERIFIED,
|
||||
SERVER_ERROR
|
||||
SERVER_ERROR,
|
||||
AUTH_ERROR
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ typedef NS_ENUM(NSUInteger, MWMPurchaseValidationResult) {
|
|||
MWMPurchaseValidationResultValid,
|
||||
MWMPurchaseValidationResultNotValid,
|
||||
MWMPurchaseValidationResultError,
|
||||
MWMPurchaseValidationResultAuthError,
|
||||
};
|
||||
|
||||
typedef void (^ValidatePurchaseCallback)(MWMPurchaseValidationResult validationResult);
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
case Purchase::ValidationCode::ServerError: {
|
||||
[self validationComplete:MWMPurchaseValidationResultError];
|
||||
break;
|
||||
case Purchase::ValidationCode::AuthError:
|
||||
[self validationComplete:MWMPurchaseValidationResultAuthError];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
})
|
||||
|
|
|
@ -22,6 +22,8 @@ final class PendingTransactionsHandler: IPendingTransactionsHandler {
|
|||
fallthrough
|
||||
case .error:
|
||||
completion(.error)
|
||||
case .authError:
|
||||
break // TODO(@beloal)
|
||||
}
|
||||
}
|
||||
break
|
||||
|
|
|
@ -83,6 +83,7 @@
|
|||
[self invalidReceipt];
|
||||
break;
|
||||
case Purchase::ValidationCode::ServerError:
|
||||
case Purchase::ValidationCode::AuthError:
|
||||
[self serverError];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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(); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue