public void RecordFailedEvent(StripeEvent stripeEvent, StripeEventResponseDTO stripeEventResponse) { try { _donationService.CreatePaymentProcessorEventError(stripeEvent, stripeEventResponse); } catch (Exception e) { _logger.Error("Error writing event to failure log", e); } }
public StripeEventResponseDTO ProcessStripeEvent(StripeEvent stripeEvent) { StripeEventResponseDTO response = null; try { switch (stripeEvent.Type) { case "charge.succeeded": ChargeSucceeded(stripeEvent.Created, ParseStripeEvent <StripeCharge>(stripeEvent.Data)); break; case "charge.failed": ChargeFailed(stripeEvent.Created, ParseStripeEvent <StripeCharge>(stripeEvent.Data)); break; case "transfer.paid": response = TransferPaid(stripeEvent.Created, ParseStripeEvent <StripeTransfer>(stripeEvent.Data)); break; case "invoice.payment_succeeded": InvoicePaymentSucceeded(stripeEvent.Created, ParseStripeEvent <StripeInvoice>(stripeEvent.Data)); break; case "invoice.payment_failed": InvoicePaymentFailed(stripeEvent.Created, ParseStripeEvent <StripeInvoice>(stripeEvent.Data)); break; default: _logger.Debug("Ignoring event " + stripeEvent.Type); break; } if (response?.Exception != null) { RecordFailedEvent(stripeEvent, response); } } catch (Exception e) { response = new StripeEventResponseDTO { Exception = new ApplicationException("Problem processing Stripe event", e) }; RecordFailedEvent(stripeEvent, response); throw; } return(response); }
public void CreatePaymentProcessorEventError(StripeEvent stripeEvent, StripeEventResponseDTO stripeEventResponse) { _mpDonationRepository.CreatePaymentProcessorEventError(stripeEvent.Created, stripeEvent.Id, stripeEvent.Type, JsonConvert.SerializeObject(stripeEvent, Formatting.Indented), JsonConvert.SerializeObject(stripeEventResponse, Formatting.Indented)); }