Search code examples
stripe-paymentspayment-processing

Stripe Payment Intent manual confirmation for testing


I have a setup where the backend would create a Stripe Source, and pass the redirect url to the frontend for the user to be sent to to input the payment details and submit the payment. In the test environment there was also a url returned here where you could basically confirm an order with just a click of a button, and then handle the webhook.

Now I am trying to migrate to the Payment Intents and there is no redirect url anymore. There is the client_secret that I can pass to the frontend and they can do all the confirmation, but for testing is there a way to somehow similarly to sources access this page?

Thank you

enter image description here


Solution

  • In general for iDEAL, it's recommended to use webhooks to be notified of the payment along with automatic confirmation, since for example the customer's browser could close or their device might run out of battery etc, after authenticating the payment and before you can notify your backend to re-confirm the PaymentIntent [0].

    If you do want to use manual confirmation, you should follow the steps here : https://stripe.com/docs/payments/ideal/accept-a-payment but create the PaymentIntent with confirmation_method=manual [1] instead.

    stripe.confirmIdealPayment will automatically redirect the customer to that page to "authorize" or "fail" the payment.

    If you want to handle the redirect manually instead of using stripe.confirmIdealPayment, I'd recommend taking a look at. : https://stripe.com/docs/payments/ideal/accept-a-payment#web-handle-redirect

    After the customer completes the payment on their bank’s website or mobile application, they will be redirected back to your website, and you can make an API call using the query parameters to confirm the payment.

    For automated testing, you would want to save the response from Stripe the first time you test this flow manually (i.e. clicking "Authorized test payment" or "Fail test payment") via the test payment page, then simulate that subsequently.

    If you want to get to the test authorization page as easily as possible for testing purposes, you can include the below parameters when creating your PaymentIntent. The response should contain the next_action.redirect_to_url.url parameter and opening that link in your browser will show the Stripe test authentication page.

    cURL example

    curl https://api.stripe.com/v1/payment_intents \
      -u sk_test_...: \
      -d amount=2000 \
      -d currency=eur \
      -d confirm=true \
      -d payment_method_types[]=ideal \
      -d payment_method_data[type]=ideal \
      -d payment_method_data[ideal][bank]=ing \
      -d return_url="http://localhost/return"