Skip to content
Advertisement

Java Stripe : How to Complete an “Incomplete” Payment

I’m using PaymentIntent to make a payment. I specify the customer that has all the billing info, but the payment is specified as “Incomplete”, I checked this STRIPE API Payment Intent incomplete payment that says I need an integration using Stripe.js where I can fill my card info.

Is there any way I let the payment access the customer info, or at least accept the credit card info?

Here’s my code:

@PostMapping ("/create-payment-intent")
public CreatePaymentResponse createSub () throws StripeException {
    Stripe.apiKey = API_SECRET_KEY;

    PaymentIntentCreateParams params = new PaymentIntentCreateParams.Builder()
            .setCurrency("eur")
            .setAmount(20 * 100L)
            .setCustomer("cus_Layhq7Kj0U6xem")
            .setReceiptEmail("mailTest@gmail.com")
            .build();

    PaymentIntent paymentIntent = PaymentIntent.create(params);
    return  new CreatePaymentResponse(paymentIntent.getClientSecret());
}

Advertisement

Answer

If you have the payment method saved on the customer, adding following to PaymentIntentCreateParams should be able to charge customer’s saved payment method (provided no additional action such as 3DS authentication is required):

If there’s no saved payment method, then the card details can only be collected via Payment Element at frontend using StripeJS: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements

If you do not wish to integrate frontend, you can use the pre-built checkout page instead of integrating with Payment Intent directly: https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=checkout

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement