1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-05 10:02:47 -05:00

stripe charge hooks and fixes to pp refunds

This commit is contained in:
Kyle Spearrin
2019-02-01 23:04:51 -05:00
parent 1bf1d83b26
commit 4ade9a229b
2 changed files with 133 additions and 14 deletions

View File

@ -73,7 +73,8 @@ namespace Bit.Billing.Controllers
Type = sale.GetCreditFromCustom() ? TransactionType.Credit : TransactionType.Charge,
Gateway = GatewayType.PayPal,
GatewayId = sale.Id,
PaymentMethodType = PaymentMethodType.PayPal
PaymentMethodType = PaymentMethodType.PayPal,
Details = sale.Id
});
}
}
@ -86,6 +87,20 @@ namespace Bit.Billing.Controllers
GatewayType.PayPal, refund.Id);
if(refundTransaction == null)
{
var saleTransaction = await _transactionRepository.GetByGatewayIdAsync(
GatewayType.PayPal, refund.SaleId);
if(saleTransaction == null)
{
return new BadRequestResult();
}
saleTransaction.RefundedAmount = refund.TotalRefundedAmount.ValueAmount;
if(saleTransaction.RefundedAmount == saleTransaction.Amount)
{
saleTransaction.Refunded = true;
}
await _transactionRepository.ReplaceAsync(saleTransaction);
var ids = refund.GetIdsFromCustom();
if(ids.Item1.HasValue || ids.Item2.HasValue)
{
@ -98,18 +113,10 @@ namespace Bit.Billing.Controllers
Type = TransactionType.Refund,
Gateway = GatewayType.PayPal,
GatewayId = refund.Id,
PaymentMethodType = PaymentMethodType.PayPal
PaymentMethodType = PaymentMethodType.PayPal,
Details = refund.Id
});
}
var saleTransaction = await _transactionRepository.GetByGatewayIdAsync(
GatewayType.PayPal, refund.SaleId);
if(saleTransaction != null)
{
saleTransaction.Refunded = true;
saleTransaction.RefundedAmount = refund.TotalRefundedAmount.ValueAmount;
await _transactionRepository.ReplaceAsync(saleTransaction);
}
}
}