Non-FictionFirst 30 DaysPayment Integration

Stripe Payment Intent API Guide eBook

Implement Stripe Payment Intents for secure card p

by Gavin Vada

  • English
  • 136 pages
  • 2026
  • SamEnrico

Implement Stripe Payment Intents for secure card payments. Handle 3D Secure and payment confirmation flows.

Formats

Free sample

Chapter 1: The $47,000 Mistake--–- It was 3:47 AM on a Tuesday when my phone started screaming. Not ringing – screaming. The dedicated Slack channel for payment failures was lighting up with red ERROR blocks faster than I could scroll. Forty-seven thousand dollars in orders had been stuck in a permanent gray zone for the past six hours. Customers had clicked “Pay,” seen a spinner, then nothing.

Some had tried three or four times. Their cards showed pending authorizations. Our database showed “processing.” Stripe showed a status I had never seen before: requires_action.I had no idea what it meant.That was my first encounter with the Payment Intents API, and it cost my company $47,000 in lost revenue, refund fees, and customer support hours. The worst part? The fix took twelve lines of code.

Twelve lines that I could have written in thirty minutes if I had understood what I am about to teach you in this chapter.This book exists because that mistake keeps happening. Every week, on Stack Overflow, in Stripe's community forums, and inside engineering teams at startups and Fortune 500s alike, developers make the same incorrect assumption: that accepting payments is just a POST request to a charges endpoint. It was true in 2015. It is catastrophically false today.The old way of thinking goes like this: customer enters card details, your server sends them to Stripe, Stripe returns “success” or “declined,” and you move on with your life. This mental model assumes that banks are simple yes/no machines.

They are not. Banks are asynchronous, opinionated, and increasingly paranoid – for good reason. Fraud costs the global economy more than $32 billion annually, and regulators have finally forced banks to do something about it.That something is called Strong Customer Authentication, or SCA. And SCA is the reason the old Charge API is dying.The Regulatory Earthquake You Cannot Ignore In September 2019, the European Union’s Revised Directive on Payment Services – known as PSD2 – fully came into force. Buried inside its hundreds of pages was a requirement that changed online payments forever: any electronic transaction above €30, or any transaction flagged as high-risk, must be authenticated using at least two of three possible factors.

Something you know (a password or PIN). Something you have (a phone or hardware token). Something you are (fingerprint or facial recognition).This is not a suggestion. Banks that fail to enforce SCA face fines of up to €10 million or 2% of global annual revenue. As a result, every major European bank now actively blocks transactions that do not meet SCA requirements.

But here is the trap that caught me at 3:47 AM: banks do not always say “no” immediately. Sometimes they say “maybe – ask the customer first.”The Charge API has no vocabulary for “maybe.” It only understands binary outcomes. When a bank responds with “authentication required,” the Charge API throws a generic authentication_required error and gives up. Your customer sees a decline message. The transaction dies.

The sale dies with it.Payment Intents were built to fix this exact problem. Instead of treating a payment as a single instantaneous action, Payment Intents model payments as a conversation that can last minutes, hours, or – in extreme cases – days. The customer starts the conversation. The bank might ask a follow-up question. The customer answers.

The conversation continues until everyone agrees on the outcome.This is not a minor technical detail. This is a fundamental shift in how you must think about online payments.The Five States That Will Save Your Weekend Every Payment Intent exists in exactly one of five states at any given moment. Your job as a developer is to write code that gracefully moves the Intent from its initial state to a terminal state – either succeeded or canceled. Here is what each state means in plain English, along with the exact code you need to recognize it.State 1: requires_payment_method This is the newborn state. You have created a Payment Intent, but you have not yet told Stripe how the customer intends to pay.

No card has been attached. No digital wallet has been selected. The Intent is waiting for you to give it a payment method.You will encounter this state immediately after creating an Intent on your backend. In practice, you rarely need to check for it explicitly because your frontend will attach a payment method as soon as the customer submits the checkout form. However, you must handle the edge case where a customer abandons the checkout process.

Intents left in requires_payment_method for more than one hour should be canceled to avoid cluttering your dashboard.State 2: requires_confirmation Now the Intent knows how the customer wants to pay, but no one has said “charge them.” This state exists because sometimes you need to perform business logic between the customer submitting their card and the money moving. For example, you might need to check inventory, apply a coupon, or run a custom fraud rule.In automatic confirmation mode – which I recommend for 95% of integrations – this state is invisible. Your frontend calls confirm Card Payment, and Stripe immediately moves the Intent to the next state. In manual confirmation mode, you must explicitly tell Stripe to proceed. We will cover manual confirmation in Appendix A, but for now, assume you are using automatic confirmation unless you have a specific reason not to.State 3: requires_action This is the state that destroyed my company’s revenue.

requires_action means the bank has accepted the payment details but wants proof that the customer is who they claim to be. The customer must complete a 3D Secure challenge – typically entering a one-time password sent via SMS, approving the transaction in their banking app, or providing a fingerprint.Crucially, requires_action does not mean the payment has failed. It means the payment is paused, waiting for the customer to do something. If you ignore this state, the Intent will eventually time out and transition to canceled. If you handle it correctly, the customer completes the challenge, and the Intent proceeds to success.Modern Stripe SDKs handle requires_action automatically for standard browser environments.

The confirm Card Payment function detects when an Intent enters this state, presents the 3DS challenge in an iframe, and resolves the promise once the customer completes authentication. The redirect flows for mobile webviews require more manual handling, which we will cover in Chapter 6.State 4: requires_capture Money has been authorized but not yet transferred. The customer’s available credit or bank balance has been reduced by the transaction amount, but the funds are still sitting in their account, not yours. You have seven days to decide whether to capture the payment (move the money to your account) or cancel it (release the hold).This state only appears when you explicitly set capture_method: 'manual' when creating the Intent. Most businesses use automatic capture, where the Intent moves directly from requires_action or requires_confirmation to succeeded.

However, manual capture is essential for use cases like hotel reservations (authorize the card at booking, capture at check-in), pre-orders (authorize immediately, capture when the product ships), or rental deposits (authorize a hold, capture only if damage occurs).State 5: succeeded The terminal happy state. The payment…

This is the end of the free sample. Get the eBook to keep going. Buy now

About this book

Implement Stripe Payment Intents for secure card payments. Handle 3D Secure and payment confirmation flows.

Details

Author
Gavin Vada
Publisher
SamEnrico
Language
English
Genre
Non-Fiction, First 30 Days, Payment Integration
Released
2026-06-01
Pages (approx.)
136
Available as
eBook, Audiobook

Read better in the ZLOADR app

Your eBooks on your phone or tablet. Sign in with your SamEnrico account and start reading.

More by Gavin Vada

See all

You may also like

See all