#holykent

1 messages · Page 1 of 1 (latest)

swift thornBOT
signal wolf
#

If the customer has no PMs of the type you specify, you'd expect an empty list in a successful response

sudden wedge
#

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

signal wolf
#

in what situatiosn could this fail?
What do you mean? Are you seeing failures you don't expect that you can share?

sudden wedge
#

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?

swift thornBOT
signal wolf
#

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

sudden wedge
#

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"?

signal wolf
#

Ok if that's what that structure does, then sure this makes sense

#

and that DTO list would be empty if the API call returned empty

sudden wedge
#

yes ok, gotcha. well i check that the customerId is available before calling this method so nothing should go wrong here then i think

#

it's noit a big deal if transient errors occur as nothing important is happening really