stripe-paymentspayment-methodstripe-payment-intent

Stripe Payment Method shows payment incomplete "required_payment_method"


Here is my implementation

 const paymentIntent = await stripe.paymentIntents.create({
        amount: body.amount,
        currency: 'gbp',
        customer: customerId,
        automatic_payment_methods: {
            enabled: true,
        },
        application_fee_amount: applicationFeeData,
        receipt_email: `${user.getDataValue('emailId')}`,
        transfer_data: {
            destination: merchant,
        },
        metadata: {
            title: 'title',
            startDate: 'startAt',
            endDate: 'endAt',
            actualAmount: body.actualAmount,
            coupon: couponCode,
        },
        setup_future_usage: 'off_session',
    });

I have passed "automatic_payment_methods" as I am not getting Payment Method Id as it is an instant payment, but it always fails and the dashboard shows me required_payment_method. But according to docs payment_method is an optional parameter. How to proceed without payment_method parameter in paymetnIntent?


Solution

  • A Payment Method object must be provided either during creation or confirmation (with Stripe.js) of the Payment Intent in order to facilitate the payment.

    How you do this will depend on your integration, but the general recommendation is to collect payment information from your customer using the Payment Element which can then be used with the confirmPayment function.

    I'd recommend following the Accept a payment guide which shows you how to build a full payment integration.