2023-10-11 21:57:51 +02:00
|
|
|
|
using Stripe;
|
|
|
|
|
|
|
|
|
|
namespace Bit.Billing.Test.Utilities;
|
|
|
|
|
|
|
|
|
|
public enum StripeEventType
|
|
|
|
|
{
|
|
|
|
|
ChargeSucceeded,
|
|
|
|
|
CustomerSubscriptionUpdated,
|
|
|
|
|
CustomerUpdated,
|
|
|
|
|
InvoiceCreated,
|
2024-06-14 18:26:49 +02:00
|
|
|
|
InvoiceFinalized,
|
2023-10-11 21:57:51 +02:00
|
|
|
|
InvoiceUpcoming,
|
|
|
|
|
PaymentMethodAttached
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class StripeTestEvents
|
|
|
|
|
{
|
|
|
|
|
public static async Task<Event> GetAsync(StripeEventType eventType)
|
|
|
|
|
{
|
|
|
|
|
var fileName = eventType switch
|
|
|
|
|
{
|
|
|
|
|
StripeEventType.ChargeSucceeded => "charge.succeeded.json",
|
|
|
|
|
StripeEventType.CustomerSubscriptionUpdated => "customer.subscription.updated.json",
|
|
|
|
|
StripeEventType.CustomerUpdated => "customer.updated.json",
|
|
|
|
|
StripeEventType.InvoiceCreated => "invoice.created.json",
|
2024-06-14 18:26:49 +02:00
|
|
|
|
StripeEventType.InvoiceFinalized => "invoice.finalized.json",
|
2023-10-11 21:57:51 +02:00
|
|
|
|
StripeEventType.InvoiceUpcoming => "invoice.upcoming.json",
|
|
|
|
|
StripeEventType.PaymentMethodAttached => "payment_method.attached.json"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var resource = await EmbeddedResourceReader.ReadAsync("Events", fileName);
|
|
|
|
|
|
|
|
|
|
return EventUtility.ParseEvent(resource);
|
|
|
|
|
}
|
|
|
|
|
}
|