GUIDE INTEGRATION

Payment gateway integration for fintech apps

A practical guide to selecting, implementing, and operating payment gateways in fintech products, covering payment architecture, security, reconciliation, and launch readiness.

Start with the movement of money, not the checkout screen

Successful payment gateway integration for fintech apps connects more than a payment form to an API. It must coordinate authorization, authentication, settlement, accounting, and customer communication without creating duplicate charges or misleading balances. For fintech teams, these requirements become especially important when payments fund wallets, repay loans, support investments, or move through multi-party marketplaces.

The central architectural question is: What does a successful gateway response allow your application to do? An authorized card payment does not necessarily mean captured funds, settled cash, or money that is safe to withdraw.

This guide explains how to select a provider, build a reliable integration, and establish the operational controls needed before launch.

Define your payment model and regulatory boundaries

Document who pays, who receives the money, which entity contracts with the payment provider, and when funds become available.

A gateway typically provides payment acceptance interfaces and routes transactions. A payment service provider may bundle gateway, processing, acquiring, fraud tools, and merchant onboarding. Neither label guarantees support for your fintech use case.

Map the complete funds flow

Create a diagram covering:

  • Funding source: Cards, bank accounts, or supported local payment methods.
  • Payment purpose: Subscription billing, wallet funding, loan repayment, or another approved activity.
  • Recipient: Your business, a connected merchant, or another customer.
  • Custody and settlement: Which parties hold funds, and where settlement lands.
  • Reversals: Who absorbs refunds, disputes, returns, and negative balances.

Wallet funding and financial-services transactions may face restrictions that ordinary retail purchases do not. Obtain explicit provider approval rather than assuming a standard merchant account is sufficient.

If your product holds customer balances, transmits money, or distributes funds to third parties, involve legal and compliance specialists early. A gateway integration does not itself satisfy licensing, safeguarding, KYC, or AML obligations.

Choose a gateway using operational criteria

Evaluate vendors against your actual funds flow, not just their checkout demos. Stripe, Adyen, Checkout.com, Braintree, and regional providers are relevant candidates, but supported businesses, countries, and capabilities differ.

Use this scorecard during procurement and technical discovery:

CriterionEvidence to requestImportant trade-off
Business-model eligibilityWritten approval for the specific fintech activityAttractive APIs are irrelevant if underwriting rejects the model
Geographic coverageMerchant entities, payment methods, currencies, settlement destinationsCustomer acceptance coverage is not merchant onboarding coverage
Payment lifecycleAuthorization, capture, cancellation, partial refunds, authenticationSimpler integrations can limit control over funds availability
Reliability controlsIdempotency behavior, webhook retries, status retrievalYour application still needs recovery logic
ReportingTransaction, fee, dispute, payout, and settlement exportsDashboard visibility is not automated reconciliation
Token portabilityMigration process and restrictionsProvider-managed tokens reduce exposure but increase switching friction
Commercial termsProcessing fees, FX, disputes, reserves, payout chargesHeadline transaction pricing omits significant costs
SupportEscalation channels and incident responsibilitiesPremium support may materially affect total cost

Validate important capabilities in a sandbox, then confirm production eligibility with the provider. Some regional methods and financial-service use cases require additional approval.

Prefer one provider unless redundancy has a clear purpose

A single provider reduces certification work, reconciliation formats, and payment-state complexity.

Multiple providers can improve regional coverage and reduce concentration risk. However, they introduce token portability issues, inconsistent authentication behavior, and more operational overhead.

Automatic failover is unsafe when the first attempt has an unknown outcome. If a request times out after reaching a gateway, sending the same charge to another provider may debit the customer twice. Resolve the original attempt before considering another route.

Design a payment architecture that survives asynchronous events

A practical architecture separates the client experience, gateway communication, payment state, and financial records.

Client and backend responsibilities

Use provider-hosted checkout or hosted payment fields where appropriate. These approaches keep raw card details out of your application servers and generally reduce PCI scope.

The client should receive only narrowly scoped, provider-approved session credentials. Secret API keys belong on the backend in a managed secret store, such as AWS Secrets Manager, Google Secret Manager, or HashiCorp Vault.

On the backend:

  • Derive the amount and currency from trusted business records.
  • Verify ownership of the account or payable obligation.
  • Create a durable internal payment identifier.
  • Associate provider objects with that identifier.
  • Enforce capture, refund, and funds-release policies server-side.

Never trust client-supplied payment amounts or treat a browser success redirect as proof of payment.

Model state instead of storing a success flag

Useful internal states might include created, requires_action, processing, authorized, captured, failed, and canceled. Track refunds and disputes separately because they occur after successful collection.

Provider terminology varies. Preserve the original provider status alongside your normalized state, and define allowed transitions explicitly.

A customer-facing timeout is not necessarily a payment failure. Represent uncertainty so support teams and recovery jobs can investigate without triggering another charge.

Keep the ledger separate from gateway state

Fintech balances should come from a controlled ledger, not from adding up successful API responses.

Use double-entry accounting principles and distinguish pending funds, available funds, processor receivables, fees, and settlement cash. Make entries immutable, with corrections represented by compensating entries.

A captured payment may establish a processor receivable without establishing cash in your bank account. The precise accounting treatment depends on your business model, contracts, and accounting policy.

Implement the integration step by step

1. Define payment contracts and invariants

Write down rules before coding:

  • Each business obligation can have multiple attempts but only the intended successful collection.
  • Every external payment maps to an internal payment and customer.
  • Each financial event creates ledger effects at most once.
  • Refunds cannot exceed the eligible captured amount.
  • Funds availability follows a documented risk policy.

Represent money using currency-aware integers or decimal types, never floating-point arithmetic. Check each API’s currency-unit conventions; not every currency uses two decimal places.

2. Build the provider adapter

Create a narrow backend interface for operations such as creating a payment, retrieving status, capturing, canceling, and refunding.

Use official SDKs where available, pin versions, and configure connection and request timeouts. Backend frameworks such as Spring Boot, ASP.NET Core, FastAPI, or NestJS can support this design.

Do not abstract away capabilities you genuinely need. An adapter that forces every provider into “charge” and “refund” methods may lose authentication, asynchronous processing, or partial-capture semantics.

3. Make write operations idempotent

Persist an operation identifier before calling the provider. Reuse it for retries of the same logical operation, not for a new payment attempt with changed parameters.

Store the intended payload, operation status, and provider identifier when available. Use database constraints to prevent concurrent workers from creating duplicate operations.

Provider idempotency rules differ, including retention windows and handling of failed requests. Review the official Stripe idempotent request documentation as one concrete example.

A timeout should trigger status recovery or a provider-supported retry using the same key—not an unqualified new charge.

4. Implement authentication and customer recovery

Support flows that require additional customer action, including 3-D Secure where applicable. Prefer provider components that handle these flows rather than recreating authentication screens.

Plan for customers who close the app during authentication, lose connectivity, or return through a deep link after the session expires.

Retrieve the authoritative payment status when the customer returns. Explain whether the payment succeeded, failed, or remains pending, and prevent accidental resubmission.

For recurring or off-session payments, capture the required consent and correctly identify the transaction type. Authentication exemptions and approvals are not guaranteed.

5. Build a durable webhook inbox

Verify webhook signatures against the unmodified request body using the provider’s documented procedure. Then durably store the event before acknowledging successful receipt.

Process events asynchronously through a queue such as Amazon SQS, Google Pub/Sub, or RabbitMQ.

Your consumer should:

  • Deduplicate using provider and event identifiers.
  • Handle duplicate notifications with different event identifiers safely.
  • Tolerate out-of-order delivery.
  • Apply state transitions and ledger effects transactionally where possible.
  • Send repeatedly failing events to a dead-letter queue.
  • Support controlled replay and audit logging.

Do not assume one webhook equals one unique financial action. Providers can emit several events concerning the same transaction.

6. Close database and messaging gaps

Use an inbox pattern for incoming events and an outbox pattern when database updates must reliably trigger downstream work.

For example, commit a payment-state update and an outbox record in one database transaction. A separate publisher sends the outbox message to the queue.

This avoids losing a ledger-posting task because the database committed just before the queue connection failed. Consumers still need idempotency because delivery may occur more than once.

7. Reconcile transactions, settlements, and bank deposits

Run reconciliation independently of webhook processing.

Match internal payments against provider transaction records, then reconcile settlement batches and fees against bank deposits. Include refunds, disputes, reserves, currency conversion, and timing differences.

Classify exceptions by owner and resolution path. A missing webhook requires a different response from an unexpected fee or an unmatched bank deposit.

Maintain an auditable exception workflow rather than relying on spreadsheet edits that bypass accounting controls.

8. Launch with controlled exposure

Begin with approved use cases, limited volume, and conservative funds-release rules. Expand only after verifying transaction outcomes, settlement reports, and support workflows.

Use feature flags to disable payment creation independently of webhook ingestion, refunds, and reconciliation. Stopping new traffic must not stop processing money already in flight.

Secure the integration and verify PCI scope

Tokenization reduces exposure but does not automatically eliminate PCI obligations. Scope depends on how your payment page, scripts, infrastructure, and provider integration handle account data.

Use the PCI Security Standards Council document library to review applicable requirements, and confirm your validation approach with your acquirer or qualified assessor.

Operational controls should include:

  • No sensitive authentication data in storage: Never retain card verification codes after authorization, including in logs.
  • Secret isolation: Separate sandbox and production credentials; restrict access and rotate keys.
  • Least privilege: Limit refund, payout, and reporting access by role.
  • Safe observability: Redact personal information, credentials, and payment tokens as appropriate.
  • Webhook defenses: Validate signatures, handle replay risks, and restrict accepted payload formats.
  • Administrative controls: Require stronger authorization for high-risk actions and preserve audit trails.

Provider fraud tools can support risk decisions, but they do not replace application-level controls for account takeover, withdrawal abuse, or suspicious funding behavior.

Test failure modes before optimizing conversion

Sandbox success is necessary but insufficient. Provider test environments may not reproduce real underwriting, network behavior, settlement delays, or issuer decisions.

Create automated integration tests for:

  • Successful payments and issuer declines.
  • Authentication success, failure, and abandonment.
  • API timeouts before and after possible provider acceptance.
  • Duplicate and out-of-order webhooks.
  • Worker crashes between state changes and message publication.
  • Partial refunds and concurrent refund requests.
  • Settlement discrepancies and dispute events.
  • Customer retries from multiple devices.

Use provider-specific test fixtures; the official Adyen testing documentation illustrates the breadth of scenarios available.

Track payment outcomes separately from infrastructure errors. An issuer decline is not the same as a backend outage.

Useful operational metrics include webhook processing delay, unresolved payment age, duplicate-operation prevention, reconciliation exceptions, and settlement variance. Avoid placing sensitive payment details in metric labels.

Common mistakes that create financial exposure

Crediting withdrawable balances immediately after authorization. Authorization can expire or fail to become captured funds. Set availability rules according to the payment rail, settlement behavior, and fraud exposure.

Retrying every error automatically. Retry transient failures carefully; do not repeatedly resubmit definitive declines. Unknown outcomes require investigation or idempotent recovery.

Treating webhooks as perfectly ordered. A delayed event must not move a completed payment backward or create another ledger entry.

Leaving refunds outside the core architecture. Refunds need authorization controls, idempotency, asynchronous status handling, and reconciliation just like payments.

Ignoring chargebacks after settlement. Settlement does not make card payments irreversible. Model dispute liabilities and recovery procedures.

Choosing on transaction fees alone. Include engineering effort, reconciliation operations, reserves, fraud losses, dispute costs, and customer support in the business case.

For adjacent implementation guidance, browse more Integration topics.

Frequently asked questions

Which payment gateway is best for a fintech app?

Choose the provider that explicitly supports your business model, merchant geography, payment methods, and funds flow. Compare reporting, authentication, token migration, commercial terms, and support—not just SDK quality. A technically strong provider may still be unsuitable for wallet funding or another restricted financial activity.

Does hosted checkout remove PCI DSS obligations?

No. Hosted checkout can significantly reduce the systems exposed to card data, but merchants retain applicable responsibilities. Eligibility for a particular assessment depends on the exact implementation and current requirements. Confirm scope with your acquirer or assessor rather than relying on a vendor’s general marketing claim.

How should an app handle a payment API timeout?

Mark the attempt as unresolved, preserve its operation identifier, and retrieve the provider’s status or retry according to its idempotency contract. Continue accepting webhook updates. Do not create a replacement charge or switch providers until you establish whether the original attempt succeeded.

When should a fintech app make incoming funds available?

Only after the payment reaches the state required by your documented availability policy. That may differ from authorization, capture, or settlement, depending on the rail and use case. Consider return rights, disputes, fraud signals, reserves, and withdrawal risk. Communicate pending and available balances separately.

Have a question about this topic?

Ask the community and get answers from practitioners.

Start a discussion