1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 21:18:13 -05:00

handle appleReceipt already existing on customer

This commit is contained in:
Kyle Spearrin 2019-09-23 10:27:14 -04:00
parent d04d92bb89
commit 5e7ac0a9bc

View File

@ -1297,7 +1297,20 @@ namespace Bit.Core.Services
if(appleReceiptStatus != null) if(appleReceiptStatus != null)
{ {
stripeCustomerMetadata.Add("appleReceipt", appleReceiptStatus.GetOriginalTransactionId()); var originalTransactionId = appleReceiptStatus.GetOriginalTransactionId();
if(stripeCustomerMetadata.ContainsKey("appleReceipt"))
{
if(originalTransactionId != stripeCustomerMetadata["appleReceipt"])
{
var nowSec = Utilities.CoreHelpers.ToEpocSeconds(DateTime.UtcNow);
stripeCustomerMetadata.Add($"appleReceipt_{nowSec}", stripeCustomerMetadata["appleReceipt"]);
}
stripeCustomerMetadata["appleReceipt"] = originalTransactionId;
}
else
{
stripeCustomerMetadata.Add("appleReceipt", originalTransactionId);
}
await _appleIapService.SaveReceiptAsync(appleReceiptStatus, subscriber.Id); await _appleIapService.SaveReceiptAsync(appleReceiptStatus, subscriber.Id);
} }