#holykent
1 messages · Page 1 of 1 (latest)
If the customer has no PMs of the type you specify, you'd expect an empty list in a successful response
in what situatiosn could this fail?
public async Task<IReadOnlyList<PaymentMethodData>> GetCustomerPaymentMethods(string customerId)
{
var options = new PaymentMethodListOptions
{
Customer = customerId,
Type = StripePaymentMethods.Card,
};
var service = new PaymentMethodService();
var paymentMethods = await service.ListAsync(options);
var paymentMethodsData = new List<PaymentMethodData>();
foreach(var paymentMethod in paymentMethods)
{
paymentMethodsData.Add(new PaymentMethodData(paymentMethod.Id, paymentMethod.Card.Brand, paymentMethod.Card.Last4));
}
return paymentMethodsData.ToReadOnlyList();
}
I generally have retries and exception handling for stripe but I cant see that it's needfed here?
I only care about listing their card payment methods
in what situatiosn could this fail?
What do you mean? Are you seeing failures you don't expect that you can share?
No, I'm not. im just asking, is there realistically any way the code above will fail?
is exception handling and retrying really necessary in teh code above?
I doin't really understand what the second half is doing, but the list api call should only fail if the customer ID is invalid
the second half is simply adding some payment method details to a DTO so i can pass it to the frontend
so when the user reaches checkout to pay for the reservation, they can reuse their paymentmethods
isn't this "correct"?