Build a card payment,
one piece at a time.
Start with a customer and a store. Add each part when a real problem calls for it. By the end, the full flow makes sense.
Each step adds one part to the system. Follow the path across the diagram, then read why that part exists.
From first sketch to full flow.
This is a teaching model of a typical online card purchase. The exact path can vary by provider and region.
Follow the shopper, store, provider, network, and issuer.
See where a checkout SDK, database, webhooks, and Kafka can fit. Jump to the stack →
The arrows show the handoffs. Once added, secure checkout sends card details to the provider.
Where tools like Kafka fit.
This is an example store-side stack. A real store may choose different tools or use fewer services.
The provider and banks handle the card route. The issuer makes the approval decision.
Stripe Payment Element · Node.js · PostgreSQL · optional Kafka
Store API + PostgreSQL
The server creates an order and a payment request. PostgreSQL keeps the order amount and payment state. A unique request key makes retries safer.
Hosted card form
The shopper enters card details in a provider-controlled form. The store receives a payment reference, not raw card details in its order record.
Provider → banks
The provider sends the authorization request through the acquirer and card network. The issuer approves or declines it. Kafka is not needed for this decision.
Webhook handler + PostgreSQL
The provider sends a server-to-server update. The store verifies it, handles repeats safely, and updates the order record. This can happen after the shopper closes the page.
Outbox → Kafka → workers
Once the store records a successful payment, it can publish an event for shipping, email, or analytics. An outbox helps keep the database change and event in sync. Kafka carries these events to other services.
So, should Kafka appear in the guide? Yes, as an optional way for the store’s services to share events after payment state changes. A small store can begin with a database and webhook handler.
Approved does not mean paid.
Three different moments are often called “the payment.” They do different jobs.
Authorization
The issuer says yes or no. A yes usually places a hold for the amount. Money has not reached the store.
Decision, usually in secondsCapture & clearing
The approved charge is captured, sometimes automatically. Transaction details are sent through the card system so both banks can record it.
The charge is submittedSettlement
Funds move between the banks. The acquirer then makes the merchant’s money available, after any fees.
Funds move laterDebit and credit follow the same broad route here. A debit card uses account funds; a credit card uses available credit. The shopper may see a pending charge before it is final.
A small glossary.
Standard payment terms, translated into plain English.
Issuer
The shopper’s card bank. It decides whether to approve the payment.
Acquirer
The merchant’s bank or acquiring partner. It helps the store accept card payments.
Card network
The network, such as Visa or Mastercard, that routes messages between the two sides.
Payment provider
The service the store connects to for checkout and payment processing. Its exact role varies.
3-D Secure
An extra way for the issuer to check the shopper’s identity when needed.
Webhook
A server-to-server update that tells the store when a payment changes state.
Idempotency key
A unique label that helps the provider recognize a repeated request.
Outbox
A database table that holds events to send after the order record changes.
Kafka
A tool that can pass events to other store services. It is optional in this example.