Getting started

How to accept credit card payments: the developer's route

Most guides to accepting card payments are a list of providers with affiliate links. This one is the build: what to sign up for, which integration keeps you out of most of PCI, the first test charge, the webhook you can't skip, and the checklist before real money. With the PSP material from chapter 4 and the production checklist from chapter 9.

Prices are Stripe's US standard pricing and the steps are from Stripe's docs, both checked on 14 November 2026. Your acquirer decides which SAQ you file.

To accept credit card payments online you need four things: an account with a payment provider that can settle card money to your bank, a way to collect card details that never lets them touch your server, a webhook that tells your system when a payment really succeeded, and a short list of checks before you switch to live keys. Here's the route, in order.

1. Choose a PSP or a merchant account

You can sign up with a payment service provider (Stripe, PayPal, Square, Adyen and others) that bundles the gateway, the processing and the merchant account behind one API, or contract a merchant account from an acquiring bank plus a separate gateway. Gateway vs processor explains who does what.

For a small business, start with a PSP. You're live in days, not after weeks of underwriting, and the price is a published flat rate: Stripe's US list price is 2.9% + 30 cents per successful domestic card payment, plus 1.5% for international cards and 1% when currency is converted, with "no setup fees, monthly fees, or hidden fees" (Stripe, checked 14 November 2026). A $50 order costs 50 x 0.029 + 0.30 = $1.75. Stripe's page also lists 0.5% extra for manually entered cards, which matters if you key in phone orders.

A merchant account on interchange-plus pricing usually costs less per transaction once volume is high, and more in setup, monthly fees and integration work. Interchange-plus vs flat rate has the crossover arithmetic, and payment processing fees breaks a fee down.

Selling in person too? Pick a provider that does both, so one dashboard and one payout cover the shop and the website (Stripe vs Square).

2. Pick how the card gets typed: hosted or embedded

This is the decision that sets your PCI workload, so make it on purpose.

  • Hosted checkout (Stripe Checkout's hosted page, a Payment Link, PayPal's buttons): the customer types the card on the provider's page. Least code, and the least PCI.
  • Embedded fields (Stripe's Payment Element, embedded Checkout): the provider's iframe sits on your page. Your layout, slightly more PCI.
  • Your own form posting card numbers to your server: don't. That's SAQ D, the full standard.

With either of the first two, card data never reaches your server, and you're normally eligible for SAQ A, the shortest self-assessment questionnaire. Since the January 2025 revision, an embedded form also means confirming your page isn't susceptible to script attacks; a redirect to a hosted page doesn't need that (PCI DSS scope, SAQ A vs SAQ D). Stripe Checkout vs Elements compares the options side by side. The short version: start hosted, and embed when you can name what hosted can't do.

3. Make the first test charge

Sign up, stay in test mode, and copy the test secret key (sk_test_...) into an environment variable. Create a Checkout Session, open its URL, and pay with Stripe's test card 4242 4242 4242 4242, any future expiry and any CVC. Then try the cards that decline and the ones that trigger 3D Secure (Stripe test cards), because those paths are where real customers get stuck.

4. Fulfil from a webhook, not the success page

The success page is where you show a receipt, not where you decide the customer paid. Stripe's fulfilment guide is blunt about it: a customer can pay and lose their connection before the page loads, so you need a webhook for checkout.session.completed, and for delayed methods like bank debits, checkout.session.async_payment_succeeded too. Your fulfilment function may run more than once, even concurrently, for the same session, so it has to fulfil exactly once; and it should retrieve the session and check payment_status first (Stripe).

The whole server side, Flask:

import os

import stripe
from flask import Flask, abort, redirect, request

stripe.api_key = os.environ["STRIPE_SECRET_KEY"]  # sk_test_ until launch day
WEBHOOK_SECRET = os.environ["STRIPE_WEBHOOK_SECRET"]
app = Flask(__name__)


@app.post("/checkout")
def checkout():
    try:
        session = stripe.checkout.Session.create(
            mode="payment",
            line_items=[{"price": "price_123", "quantity": 1}],
            success_url="https://example.com/thanks?session_id={CHECKOUT_SESSION_ID}",
            cancel_url="https://example.com/cart",
        )
    except stripe.StripeError:
        abort(502)
    return redirect(session.url, code=303)


@app.post("/stripe/webhook")
def stripe_webhook():
    try:
        event = stripe.Webhook.construct_event(
            request.get_data(),  # raw bytes, not request.json
            request.headers.get("Stripe-Signature", ""),
            WEBHOOK_SECRET,
        )
    except (ValueError, stripe.SignatureVerificationError):
        abort(400)
    if event.type in ("checkout.session.completed",
                      "checkout.session.async_payment_succeeded"):
        fulfil(event.data.object.id)
    return "", 200


def fulfil(session_id):
    session = stripe.checkout.Session.retrieve(session_id)
    if session.payment_status == "unpaid":
        return  # a delayed method: async_payment_succeeded comes later
    # Unique constraint on session_id: a second call is a no-op.
    mark_order_paid_once(session_id)

Stripe Checkout waits up to 10 seconds for your webhook endpoint to respond before it redirects the customer to the success page (Stripe), so keep the handler fast, and queue anything slow. Stripe webhooks covers retries and duplicates in depth.

5. Go live

From Stripe's go-live checklist (Stripe):

  • Recreate test objects in live mode. Products, prices and coupons made in test mode don't exist in live mode.
  • Register a live webhook endpoint. It's separate from the test one, with its own signing secret. Check it handles delayed, duplicate and out-of-order events.
  • Pin your API version and handle every error type, including the ones that "should never" happen.
  • Roll your keys in case a test-era key leaked into a log or a laptop, and keep live keys out of code.

Then make a few small live charges on your own card, watch each one arrive through the webhook and into your database, and refund them. Test mode can't tell you how a real issuer behaves. The chapter 9 checklist below is the longer version.

When a direct processor beats a PSP, and how to size the crossover for your own volume. From chapter 4.

Choosing Between Direct Integration and PSPs

Use Direct Integration When:

  • Processing enough volume that the rate difference pays for the team (see below)
  • Need maximum control over payment flow
  • Have dedicated payments team
  • Require custom processing logic
  • Operating in restricted industries

Use PSPs When:

  • Getting started with payments
  • Want to launch quickly
  • Need global payment methods
  • Don't want compliance headaches
  • Value developer experience
  • Processing too little for the rate difference to pay for a payments team

To size the crossover for yourself, get an interchange-plus quote from an acquirer, apply it to last year's transactions, and compare the saving with what your current PSP charged. If the difference doesn't comfortably cover the engineers, compliance work, and vendor management that direct integration takes, stay on the PSP.

The full checklist before live keys, from HTTPS to who owns dispute evidence. From chapter 9.

  • [ ] HTTPS enabled on all endpoints
  • [ ] API keys in environment variables (not code)
  • [ ] Webhook signature verification implemented
  • [ ] Idempotency keys for all payments
  • [ ] Error handling for all Stripe error types
  • [ ] Rate limiting implemented
  • [ ] Audit logging enabled
  • [ ] Monitoring and alerting configured
  • [ ] PCI SAQ-A compliance verified
  • [ ] Test mode disabled / Live keys configured
  • [ ] Separate live-mode webhook endpoint with its own signing secret
  • [ ] Restricted API keys for services that only need part of the API
  • [ ] Radar rules reviewed, with a 3DS rule ahead of any block rule
  • [ ] Stripe Tax registrations added for every jurisdiction you collect in
  • [ ] Statement descriptor set, so customers recognize the charge instead of disputing it
  • [ ] Test clock run through a trial conversion, a recovered retry, and a failed one
  • [ ] Someone owns dispute evidence, with a deadline reminder

Questions

How do I accept credit card payments as a small business?

Sign up with a payment service provider such as Stripe, PayPal or Square, use its hosted checkout or embedded payment fields so card data never touches your server, confirm payments with a webhook, and run a few small live charges before launch. You can be live in days, with no setup or monthly fee on Stripe's standard pricing.

How much does it cost to accept credit cards online?

On Stripe's US standard pricing, 2.9% + 30 cents per successful domestic card payment, plus 1.5% for international cards and 1% for currency conversion. A $50 order costs $1.75. A merchant account on interchange-plus can be cheaper at high volume but adds setup and monthly costs.

Do I need a merchant account to accept credit cards?

Not a separate one. A payment service provider like Stripe or Square gives you processing and the merchant account in one signup. A dedicated merchant account from an acquiring bank makes sense at higher volume, when lower per-transaction rates pay for the extra setup and integration.

What is the easiest way to accept card payments on a website?

A hosted checkout page or a payment link from your provider. The customer types the card on the provider's page, you write the least code, and you're normally eligible for SAQ A, the shortest PCI questionnaire.

How do I know a card payment succeeded?

From a verified webhook, not the success page. A customer can pay and lose their connection before the success page loads. On Stripe Checkout, handle checkout.session.completed, retrieve the session, check payment_status, and fulfil the order exactly once.

What the book adds

What chapters 4, 9 and 17 add

  • A card payment traced hop by hop, from click to deposit
  • Which layer a failed payment died at, from the error you got
  • Payment Intents, 3D Secure and saved cards on Stripe
  • Following a PSP's fee down to interchange
  • PCI scope, SAQ by SAQ

30-day money-back · Instant PDF and EPUB

All 42 chapters