0
votes

I'm using .NET and Stripe Checkout to handle payments.

I've recieved a payment, but it says that it is "Incomplete," and that the PaymentIntent requires a payment method.

I'm using Stripe Checkout and I didn't see anywhere that declaring payment method is required. Only that the following code relating to payment method is requied when creating the Session object:

        PaymentMethodTypes = new List<string> {
                "card",
        },

I've tried creating a payment method using the API in the follwing way:

        StripeConfiguration.ApiKey = {MY_STRIPE_API_KEY};

        var options = new PaymentMethodCreateOptions
        {
            Type = "card",
        };
        var service = new PaymentMethodService();
        var response = service.Create(options);

And attaching the response to the Customer object using:

        StripeConfiguration.ApiKey = {MY_STRIPE_API_KEY};

        var options = new PaymentMethodAttachOptions
        {
            Customer = customerId
        };
        var service = new PaymentMethodService();
        service.Attach(
          CreatePaymentMethod(),
          options
        );

But when I create the payment method, it says that I'm missing the parameter Card containing the customer's card details, which I don't have. I thought that was something the redirection to Stripe Checkout took care of.

1

1 Answers

1
votes

When using Stripe Checkout, you don't need to create a PaymentMethod or Customer beforehand. Checkout will do all that for you automatically.

In your code you're creating a PaymentMethod but without any payment details (e.g. a card number). So when you attach it to a customer the request fails since the PaymentMethod is missing details and would be useless as it can't be charged.

Since you're using Checkout, you should just follow this guide: https://stripe.com/docs/checkout/integration-builder