1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-27 22:34:54 -05:00

throw apple iap exceptions

This commit is contained in:
Kyle Spearrin 2019-09-20 00:01:35 -04:00
parent ff5a0ff0ce
commit 784c86893f

View File

@ -377,7 +377,14 @@ namespace Bit.Core.Services
{
await UpdatePaymentMethodAsync(user, paymentMethodType, paymentToken, true);
}
catch { }
catch(Exception e)
{
var message = e.Message.ToLowerInvariant();
if(message.Contains("apple") || message.Contains("in-app"))
{
throw e;
}
}
}
try
{
@ -534,7 +541,7 @@ namespace Bit.Core.Services
appleReceipt.Item1);
if(verifiedAppleReceipt == null)
{
throw new GatewayException("Failed to get Apple IAP receipt data.");
throw new GatewayException("Failed to get Apple in-app purchase receipt data.");
}
subInvoiceMetadata.Add("appleReceipt", verifiedAppleReceipt.GetOriginalTransactionId());
var lastTransactionId = verifiedAppleReceipt.GetLastTransactionId();
@ -1264,7 +1271,7 @@ namespace Bit.Core.Services
appleReceiptStatus = await _appleIapService.GetVerifiedReceiptStatusAsync(paymentToken);
if(appleReceiptStatus == null)
{
throw new GatewayException("Cannot verify apple in-app purchase.");
throw new GatewayException("Cannot verify Apple in-app purchase.");
}
await VerifyAppleReceiptNotInUseAsync(appleReceiptStatus.GetOriginalTransactionId(), subscriber);
}
@ -1556,7 +1563,7 @@ namespace Bit.Core.Services
var existingUser = await _userRepository.GetByIdAsync(existingReceipt.Item2.Value);
if(existingUser != null)
{
throw new GatewayException("Apple receipt already in use.");
throw new GatewayException("Apple receipt already in use by another user.");
}
}
}