To develop payment collection and processing, you build four things in order: a compliant account structure, a tokenized checkout that captures funds, a server-side integration that authorizes and captures those funds, and a reconciliation-and-payout loop that proves the money arrived. The single biggest condition is this: you almost never move money yourself. Licensed processors, acquiring banks, and card networks do that, and your job is to integrate with them correctly, handle their webhooks, and keep your own ledger accurate.

That framing matters because most failed payment projects don't fail on code. They fail because someone wired a checkout button directly to a bank transfer, or treated an authorization as a completed sale, or discovered after launch that their pricing model triggers extra compliance obligations. This guide walks through the build in the order that keeps those failures from happening, with the mechanisms, checks, and limits that matter at each stage.

I'll use "processor" loosely to mean whichever combination of payment service provider (PSP), payment gateway, acquiring bank, and merchant of record you assemble. The exact boundaries between those roles vary by provider and region, so it's worth pinning down with your processor what each party is contractually responsible for before you write the first line of integration code.

Start With the Money Model, Not the Code

Before choosing a provider, write down what you're actually collecting. The answers determine almost everything downstream.

Ask: Is this a one-time charge, a subscription, a usage-based metered bill, an invoice paid later, or a marketplace split where one payment fans out to multiple sellers? Is the payer a consumer or a business? Do you need to accept cards only, or also bank debits, wallets, and local methods? Which countries will payers and payees be in? What's the typical and maximum transaction size?

Each answer changes your architecture. Subscriptions need stored credentials and a dunning process for failed renewals. Marketplaces need separate onboarding and payout flows for each seller, which usually means a platform agreement rather than a plain merchant account. High-value business invoices may be better served by bank transfer with reconciliation than by card, because card fees scale with amount while bank rails often don't.

You also need a ledger design from day one. At minimum, track for every transaction: a unique internal ID, the processor's ID, the amount and currency, the fee, the net, the status, the payer reference, and timestamps for each state change. When a processor's dashboard and your database disagree—and eventually they will—this ledger is how you find out why. Decide early whether you store money amounts as integers in the currency's minor unit (cents, for example) rather than floating-point numbers; the latter accumulates rounding errors that surface as off-by-a-cent reconciliation failures.

This is the unglamorous stage that decides whether you can launch at all, so handle it before integration work.

You'll typically need a registered business entity, a business bank account, and a merchant account or platform account with a processor. Processors run know-your-customer and anti-money-laundering checks, so expect to supply ownership details, expected volumes, and a description of what you sell. Applying takes days to weeks depending on risk category, and some business types—certain financial services, gambling-adjacent products, high-chargeback categories—are restricted or require special approval.

Card network rules set the floor for what you must do: store card data only in tokenized form if you touch it at all, use PCI-compliant components, and honor chargeback processes. The lightest compliance path is to let the processor's hosted fields or hosted checkout collect card details so the sensitive data never reaches your servers; this keeps your PCI scope small. The heaviest path—storing raw card numbers—brings audit obligations most small teams should avoid entirely.

Tax is separate from payment processing and is its own trap. Sales tax, value-added tax, and goods-and-services tax obligations depend on where your customer is, what you sell, and whether you've crossed registration thresholds. Many processors offer tax calculation add-ons, but the calculation is only as good as the product tax codes you configure, and the remittance is still your responsibility unless you've explicitly outsourced it. If you're selling across borders, get local advice on registration thresholds before you assume your processor handles it.

A specific edge case: if you take payment before delivering goods, some jurisdictions treat customer funds as held on trust or subject to refund rules, and marketplace models can make you the merchant of record even when a seller fulfills. These distinctions are legal questions, not technical ones, and they should be settled before your first live transaction.

Choose Your Integration Model and Provider

There are three broad integration models, and picking the right one early saves a rebuild later.

Hosted checkout redirects the payer to a processor-hosted page. It's the fastest to ship, minimizes PCI scope, and supports local payment methods with little extra work. The trade-off is less control over the visual experience and sometimes a redirect that feels disjointed on mobile.

Embedded components render processor-hosted fields inside your own page. You keep your design, the card data still never touches your server, and you get a more seamless flow. This is the common choice for consumer apps that care about conversion.

Direct API integration lets your server call the processor's API to create and manage payments, with the client collecting tokenized details. It offers the most control and is necessary for complex flows like marketplaces, but it demands more engineering and a stronger compliance posture.

For most first launches, embedded components with server-side payment creation is the sweet spot. Choose a provider based on: supported countries and currencies, supported payment methods, fee structure (percentage plus fixed fee per transaction, and any per-payout or currency-conversion charges), payout timing to your bank account, quality and reliability of webhooks and sandbox testing, dispute-handling tooling, and whether the provider can act as merchant of record if you'd rather offload tax and compliance.

Be skeptical of fee comparisons that ignore fixed per-transaction costs. A 2% rate looks cheaper than 2.5% until you notice a 30-cent fixed fee on a $5 charge: that's 6% on the small ticket versus under 1% on a $100 charge. Model your actual transaction mix, including the small ones, before deciding.

Build the Checkout and Collection Flow

With a provider chosen, build the collection path in this order. The steps below assume an embedded-component integration with server-side payment creation, which is the most common pattern; adjust for hosted or direct models as needed.

Prerequisites: a sandbox account with test credentials, a backend with a database and HTTPS endpoints, and a defined set of payment methods to accept at launch.

1: Create a payment intent on your server. When the payer is ready to pay, your backend calls the processor to create a payment object with the amount, currency, and a reference to your internal order. The processor returns a client secret or equivalent token. Never trust an amount sent from the browser; the server decides the price. 2: Render the payment form on the client. Use the processor's embedded fields, passing the client secret. The fields collect card or bank details and hand back a tokenized result. 3: Confirm the payment. The client confirms against the processor, which attempts authorization. Handle the three outcomes: success, a decline that needs a different payment method, and a redirect to an authentication step (many regions require stronger customer authentication for card payments; the processor's flow handles the redirect if you've configured it). 4: Verify on the server, not the browser. The client-side success message means nothing until your server confirms the payment status via webhook or a direct retrieve call. Only then mark the order paid and release goods or access. 5: Record everything in your ledger. Write the processor ID, amount, fee, status, and timestamp in the same database transaction that marks the order paid, so a crash can't leave one updated without the other.

Success check: run a test payment in the sandbox, then query the payment by its ID and compare every field against your ledger. Then simulate a decline, an authentication redirect, and a webhook delivered twice. If your system handles all four without duplicating an order or losing a payment, the collection path is sound enough to move on. A common failure symptom is "paid in the processor dashboard, unpaid in our app"—almost always a webhook that arrives before your order row exists, or a signature verification that's rejecting valid events.

Handle Webhooks, States, and Idempotency Reliably

Webhooks are how the processor tells you the truth after the fact, and they're where most production incidents originate.

States come in two families. Authorization holds funds but doesn't move them; capture converts the hold into a charge. Some providers capture automatically at confirmation (a "sale"), others let you authorize now and capture later—useful when you ship after payment. Your order model should have distinct states for authorized, captured, settled, refunded, partially refunded, and disputed, and your business logic should only release goods on captured or settled, never on authorized alone. Authorizations also expire; if you don't capture within the window (often a few days, varying by processor and card network), the hold releases and you have to re-authorize.

Webhook handling needs three habits. First, verify the signature so you know the event came from the processor. Second, make processing idempotent: store the event ID and skip any you've already handled, because delivery is at-least-once and retries are normal. Third, respond fast and process asynchronously if work is slow, or you'll get retried into duplicate work. The correct order is usually: verify, deduplicate, persist the raw event, then act.

A worked example of why idempotency matters: a payment-succeeded event arrives, your handler marks the order paid and sends a receipt. The processor doesn't get your acknowledgement in time and retries. Without deduplication, the customer gets two receipts and, if you also decrement inventory on the event, you've oversold by one. With deduplication keyed on the event ID, the retry is a no-op.

Manage Refunds, Disputes, and Chargebacks

Refunds are your own decision and are usually straightforward: call the processor's refund endpoint against the original payment, track the refund as its own ledger entry linked to the parent payment, and make partial refunds additive so the total never exceeds the captured amount. Refund fees vary—some processors return the original fee, many don't—so model this into your unit economics.

Chargebacks are different. A cardholder disputes a charge with their bank, the bank pulls the funds, and you get a window to submit evidence. The mechanism to understand: chargebacks have hard deadlines, and missing one forfeits the dispute by default. Build a queue that surfaces every dispute with its deadline, and prepare evidence packages in advance—delivery confirmation, login records, terms acceptance, communication history. A rise in chargebacks can also push you into a monitoring program with higher fees or a reserve requirement, so track your chargeback ratio as a first-class metric.

Fraud screening belongs here too. Most processors offer basic fraud tools; for higher-risk categories you may need rules (velocity limits, amount thresholds, geographic mismatches) or third-party scoring. The trade-off is blunt: tighter rules block more fraud and also block more legitimate customers, and the cost of a false decline is often higher than the fraud it prevents for small merchants. Measure declined-then-retried-with-another-method rates before tightening anything.

Reconcile, Settle, and Pay Out

Collection is only half the job; proving the money landed is the other half.

Settlement is when the processor batches captured transactions and pays the net amount to your bank account, typically on a delay of a day or more and often with a rolling reserve for new or higher-risk merchants. Payouts may be per-day batches, per-transaction, or scheduled. Your reconciliation should match, for each settlement batch: the gross captured amount, the fees, refunds, chargebacks, adjustments, and the net deposited.

Do this programmatically. Pull the processor's settlement or balance-transaction reports, compare each line to your ledger, and flag unmatched items into an exception queue with a reason code. The success check is simple: the sum of your ledger's net amounts for a period equals the sum of bank deposits for that period, within the settlement lag you've configured. If they diverge, the exception queue tells you where.

Fees deserve their own line in the ledger rather than being netted silently, because netting hides the true cost per transaction and makes pricing decisions guesswork. Similarly, if you operate a marketplace, payouts to sellers need their own ledger entries with the seller ID, and you'll want to reconcile each seller's balance independently—otherwise one seller's refund can quietly distort another's payout.

Scale and Harden the System

Once live, the concerns shift from "does it work" to "does it keep working and stay honest."

Multi-currency adds conversion: the payer pays in one currency, settlement may be in another, and the conversion rate and fee are their own line items. Store the original amount and currency, the settlement amount and currency, and the rate used, or you'll never explain a discrepancy.

Retries and dunning matter for subscriptions: a failed renewal should retry on a schedule that respects the card network's rules, notify the customer, and eventually expire the subscription. Aggressive retry without customer contact drives disputes.

Observability should include payment success rate by method and country, authorization decline codes, webhook failure rate and processing latency, refund and chargeback ratios, and settlement exception counts. These are the numbers that tell you whether the system is healthy before revenue visibly drops.

Idempotency keys on every write call to the processor prevent duplicate charges when your server retries after a timeout—a scenario that happens routinely under load.

A stop condition worth naming: if your business model changes materially—new country, new product category, marketplace splits, stored-value balances, or lending-like features—the compliance picture changes with it, and that's the point to bring in a payments lawyer or compliance specialist rather than extending your existing integration by guesswork. Similarly, if chargebacks or fraud losses climb past your processor's thresholds, get professional help on the dispute program before the account is restricted.

A Realistic Sequence and Timeline

For a small team building a first integration with a hosted or embedded provider, the sequence is roughly: money model and ledger design (a few days), entity and merchant account application (one to three weeks, sometimes longer), sandbox integration of checkout and webhooks (one to two weeks), reconciliation against sandbox settlement reports (a few days), then a limited live launch with a small volume cap, followed by widening.

The common overrun is not the coding; it's the account approval and the tax and compliance questions. Start the application early, in parallel with the integration, and treat the sandbox-to-live cutover as its own project with its own checks—live keys, real bank account, real settlement report, and a manual reconciliation of the first live batch before you trust the automated one.

If you'd rather not own tax and compliance, a merchant-of-record arrangement folds much of that into the provider's service at a higher headline fee. That's a legitimate trade-off, not a shortcut, and it's worth pricing honestly against the staff time and risk you'd otherwise carry. Either way, the technical build—tokenized collection, server-verified state, idempotent webhooks, and a real ledger reconciled to bank deposits—is essentially the same, and it's the part that determines whether your payment system is trustworthy when something goes wrong.