public DonationDTO GetDonationByProcessorPaymentId(string processorPaymentId) { var d = _mpDonationService.GetDonationByProcessorPaymentId(processorPaymentId); if (d == null) { return (null); } var donation = new DonationDTO { Amount = d.donationAmt, Id = d.donationId + "", BatchId = d.batchId }; return (donation); }
public void SetDonationSource(DonationDTO donation, StripeCharge charge) { if (donation.Source.SourceType == PaymentType.Cash) { donation.Source.Name = "cash"; } else if (charge != null && charge.Source != null) { donation.Source.AccountNumberLast4 = charge.Source.AccountNumberLast4; if (donation.Source.SourceType != PaymentType.CreditCard || charge.Source.Brand == null) { return; } switch (charge.Source.Brand) { case CardBrand.AmericanExpress: donation.Source.CardType = CreditCardType.AmericanExpress; break; case CardBrand.Discover: donation.Source.CardType = CreditCardType.Discover; break; case CardBrand.MasterCard: donation.Source.CardType = CreditCardType.MasterCard; break; case CardBrand.Visa: donation.Source.CardType = CreditCardType.Visa; break; default: donation.Source.CardType = null; break; } } }
private void ConfirmRefundCorrect(DonationDTO donation) { // Refund amount should already be negative (when the original donation was reversed), but negative-ify it just in case if (donation.Status != DonationStatus.Refunded || donation.Amount <= 0) { return; } donation.Amount *= -1; donation.Distributions.All(dist => { dist.Amount *= -1; return (true); }); }
private StripeCharge GetStripeCharge(DonationDTO donation) { if (string.IsNullOrWhiteSpace(donation.Source.PaymentProcessorId)) { return null; } // If it is a positive amount, it means it's a Charge, otherwise it's a Refund if (donation.Amount >= 0) { return _paymentService.GetCharge(donation.Source.PaymentProcessorId); } var refund = _paymentService.GetRefund(donation.Source.PaymentProcessorId); if (refund != null && refund.Charge != null) { return refund.Charge; } return null; }