By the time a CTO reaches me, the conversation has usually moved beyond adding a checkout button. Payment gateway integration connects an application to the services that collect payment details, request authorization, and report transaction results, while the architecture determines the PCI DSS 4.0 boundary, tokenisation model, webhook reconciliation, and provider economics.
The real choice sits among provider integration, payment orchestration, and custom infrastructure. Stripe, Adyen, Braintree, Authorize.Net, or Razorpay may enter the shortlist, yet the decision also has to cover Apple Pay, Google Pay, 3D Secure 2, settlement latency, chargeback handling, and multi-currency support. Our work on the Spruce platform reinforced how quickly payments become intertwined with pricing, bookings, and operational workflows.
A gateway that processes a successful test payment has passed the smallest part of the evaluation. The real test covers retries, refunds, disputes, delayed webhooks, reconciliation, and provider change.
What payment gateway integration includes
A complete payment gateway integration covers customer-facing payment collection, server-side payment creation, authentication, payment-state updates, refunds, disputes, and financial reporting. It also establishes how your product connects orders and invoices to external financial events.
Several organizations and systems can participate in a card transaction:
- Merchant: The business accepting the payment.
- Payment gateway: The service that securely collects payment information and submits a transaction for processing.
- Payment processor: The system that routes transaction messages among the merchant, card network, and banks.
- Acquirer: The merchant-side financial institution or acquiring partner that receives approved card transactions.
- Issuer: The customer’s bank or card issuer.
- Card network: The network that carries authorization and settlement messages.
- Payment facilitator, or PayFac: A platform that enables sub-merchants to accept payments under a broader payment arrangement.
- Payment service provider: A provider that may package gateway, processing, merchant-account, fraud, and reporting capabilities behind one technical and commercial relationship.
Provider products frequently combine several of these functions. Your architecture still needs to record the boundaries because they affect settlement files, contractual responsibility, incident escalation, and reconciliation.
A typical application flow begins when the customer selects a payment method. A provider-hosted field, mobile SDK, or checkout page collects the payment details and exchanges sensitive card information for a token.
Tokenisation, often spelled “tokenization” in U.S. documentation, replaces the account number with a provider-controlled identifier. Your backend uses that token to create or confirm the payment, while subsequent webhooks report authorization, capture, refund, dispute, and payout changes.
That sequence creates several distinct records:
- The application’s order or invoice
- The provider’s payment object
- One or more authorization and capture records
- Refund and dispute records
- A balance transaction or fee record
- A payout or settlement record
- An accounting entry in the finance system
These records cannot safely collapse into one transaction with one permanent status. A payment can be authorized, partially captured, partially refunded, disputed, reversed, or included in a later payout.
The integration therefore needs a payment state model. That model translates provider-specific events into statuses the rest of your product understands.
For example, an ecommerce order may move from awaiting payment to paid only after the backend verifies the relevant provider event. A browser redirect offers weak evidence because the user can close the page, lose connectivity, or reload during processing.
The payment scope also has to answer operational questions:
- Who investigates an authorization that appears successful in one system and pending in another?
- Which event allows fulfillment to begin?
- How are partial refunds connected to the original order?
- Where are provider fees recorded?
- How does finance connect a payout to its payments, refunds, and disputes?
- What happens when a verified webhook arrives more than once?
- How does support find a transaction without opening several systems?
- How are chargeback evidence and response deadlines assigned?
- Which alerts indicate degraded payment processing or reconciliation?
A gateway integration reaches into customer support, finance, fraud operations, security, product analytics, and order management. I recommend assigning those owners while the system is still being scoped.
This is especially important for marketplaces and service platforms. Their payment flow may include scheduled capture, delayed payout, cancellation rules, promotional credits, tips, provider compensation, tax handling, and region-dependent pricing.
Spruce offers a concrete example from our delivery history. The U.S. home and property services platform had resident applications and portals for administrators, service providers, and property managers.
Its wider architecture included Braintree alongside bookings, pricing configuration, capacity management, scheduling, and role-based access. Payment decisions had to fit the business rules that created the service price and governed each booking.
Our work covered a system-wide architecture redesign and a pricing configurator that adjusted services and add-ons using market, property size, and floor-plan inputs. The lesson for scoping is direct: “integrate Braintree” describes a provider connection, while the project scope must follow the commercial workflow from price creation through payment records.
That distinction matters.
Choose the right integration model
The integration model determines how much checkout control your team receives, which systems touch card data, and how much payment logic your organization must operate. I advise CTOs to settle this choice before conducting detailed provider comparisons.
Four models cover most payment programs: hosted provider components, direct API integration, payment orchestration, and custom gateway infrastructure. A company may also combine them, such as using hosted fields for card collection and an internal adapter for provider portability.
| Integration model | Checkout control | Typical card-data exposure | Engineering ownership | Operational complexity | Strong fit |
|---|---|---|---|---|---|
| Hosted checkout or provider components | Provider-led to moderately branded | Sensitive collection remains in provider-controlled components | Checkout configuration, backend confirmation, webhook processing | Lower relative burden | Standard payments, faster scope validation, limited payment customization |
| Direct API or SDK integration | High | Depends on collection method and data flow | Payment service, states, retries, refunds, webhooks, monitoring | Moderate to high | Custom product workflows and deeper backend integration |
| Payment orchestration | High across several providers | Depends on orchestration design | Routing rules, normalized states, provider adapters, reconciliation | High | Multiple markets, resilience requirements, provider choice by transaction |
| Custom gateway infrastructure | Very high | Potentially extensive | Security, connectivity, certifications, operations, reporting, incident response | Very high | Payment infrastructure is a core product capability with justified scale and expertise |
This table starts the decision. The final choice still needs a card-data diagram, operating requirements, and current provider evidence.
Hosted checkout and provider components
Hosted checkout sends the customer to a provider-controlled page or presents provider-controlled payment components inside your interface. Embedded fields and provider SDKs can preserve much of the product’s visual language while keeping sensitive card entry within the provider component.
This model often gives a team the cleanest route to reducing card-data exposure. The exact PCI DSS scope depends on implementation details, scripts, hosting, and the applicable assessment path, so the architecture still requires security review.
Hosted components work well when standard payment behavior covers the commercial model. Common examples include one-time purchases, straightforward subscriptions, and service bookings with conventional authorization and capture rules.
The engineering team still owns several important pieces:
- Creating the order and calculating the authoritative amount
- Starting the checkout session from a trusted backend
- Associating the provider payment with the internal order
- Receiving and verifying webhooks
- Preventing duplicate fulfillment
- Processing refunds and cancellations
- Recording provider references for support and finance
- Monitoring production failures
A hosted page cannot repair a weak internal state model. It changes where payment details are collected and how much interface control the product team holds.
Review the customer journey carefully when a redirect is involved. Mobile browser transitions, expired sessions, authentication challenges, and return URLs can affect completion.
I also ask product teams to test branding, language, accessibility, saved methods, mobile keyboards, address collection, authentication, and error recovery. Security and usability both influence whether a customer completes payment.
Direct API integration
A payment gateway API integration gives the application deeper control over payment creation, capture, refunds, subscriptions, and related workflows. The frontend may still use provider-hosted fields or an SDK, while the backend interacts directly with payment APIs.
This model often fits products with custom order states, usage-based billing, delayed capture, split fulfillment, or complex account relationships. The additional control creates more engineering and operational ownership.
A direct integration usually needs a dedicated backend payment module or service. That module should centralize:
- Provider credentials
- Payment creation
- Idempotency keys
- Internal and provider identifiers
- Status mapping
- Capture and cancellation rules
- Refund handling
- Webhook verification
- Event persistence
- Reconciliation references
- Audit logging
- Access control
- Monitoring and alerts
I discourage placing provider calls throughout order, subscription, and mobile application code. Scattered calls make retries difficult to reason about and increase the work involved in changing provider behavior.
Use one internal contract for payment operations when the product’s complexity warrants it. The rest of the application can request an authorization, capture, or refund without embedding provider-specific object names in every domain.
That boundary also improves testing. Engineering can simulate provider timeouts, duplicate events, delayed responses, and malformed payloads without depending entirely on a remote sandbox.
A direct API design needs a clear source of authority for each decision. The order system owns what the customer purchased, while the provider owns external processing events. Your payment service joins those records and applies the business rules.
Keep the boundary explicit.
Payment orchestration
Payment orchestration places a routing and normalization layer between the product and one or more payment providers. The layer may be a commercial orchestration platform, an internally developed abstraction, or a combination of both.
Teams usually consider orchestration when they need several gateways, regional payment methods, routing rules, availability options, or centralized payment analytics. The architecture can also support gradual provider migration.
Multiple gateways create a larger state-management problem. Providers can use different event names, payment lifecycles, refund behavior, identifiers, and settlement reports.
The orchestration layer therefore needs a canonical payment model. A canonical model is the organization’s provider-neutral representation of authorization, capture, refund, dispute, and payout states.
Keep that model precise. A generic “success” status usually loses information needed for fulfillment and finance.
Routing also needs an explicit purpose. Useful routing inputs may include:
- Customer geography
- Transaction currency
- Payment method
- Merchant account
- Product line
- Provider availability
- Authentication requirements
- Contractual constraints
- Risk policy
Each routing rule adds a reconciliation and support consequence. When a customer contacts support, the team needs to know which provider handled the transaction and where its refund or dispute will appear.
Failover requires particular care. Sending the same payment to another provider after an ambiguous timeout can create duplicate charges if the original request eventually succeeds.
A safe failover design distinguishes a confirmed decline from an unknown outcome. It also uses provider-specific idempotency controls, internal attempt identifiers, and follow-up status checks.
Orchestration improves optionality when the team funds the ongoing work. Provider connectors, state normalization, routing rules, monitoring, token portability, and settlement reconciliation remain active product responsibilities.
This recommendation has a limit. A simple one-provider checkout with no portability or routing requirement may gain little from a large abstraction layer.
Custom gateway infrastructure
Custom payment gateway integration can describe a highly tailored provider API integration or infrastructure that connects more directly to processors, acquirers, or banking partners. Clarify which meaning applies before estimating the project.
The second interpretation carries a much wider security, compliance, commercial, and operational footprint. Custom infrastructure becomes relevant when payments are central to the company’s product, margins, market access, or platform model.
The organization needs a durable reason to own those capabilities. That reason should survive an executive review covering:
- Required market and payment-method access
- Expected control over transaction routing
- Required merchant or sub-merchant model
- Fraud and risk responsibilities
- Compliance obligations
- Availability and incident-response requirements
- Settlement and ledger requirements
- Certification and audit needs
- Partner and banking dependencies
- Long-term engineering ownership
The build decision also affects staffing. Payment infrastructure needs security, backend engineering, finance operations, risk, support, compliance, and partner-management capacity.
I advise teams to write the operating model before approving a custom build. Unclear ownership after launch creates a material architectural risk.
The integration and custom-infrastructure paths can coexist. A company may begin with a provider integration, introduce an internal payment service, and add orchestration when market or resilience requirements justify it.
That staged path preserves learning. Real payment data can reveal which currencies, methods, failure patterns, and operational costs deserve deeper investment.
Map card-data flow before choosing a provider
A card-data-flow diagram shows where payment-account data enters, which component collects it, where it is transmitted, and which internal systems can retrieve it. I put this diagram ahead of provider selection because it exposes the compliance consequences of the proposed customer experience.
PCI DSS 4.0 defines security requirements for protecting payment-account data. Your exact scope and validation method depend on the implementation and merchant environment, so a qualified security or compliance reviewer should confirm the final interpretation.
Begin with every payment entry point:
- Desktop web checkout
- Mobile web checkout
- Native iOS application
- Native Android application
- Customer-support tools
- Administrative portals
- Subscription update flows
- Pay-by-link or invoice flows
- Failed-payment recovery
- Refund interfaces
- Any phone or manual-order workflow
Then trace the fields, scripts, SDKs, network calls, logs, analytics tools, and storage systems involved. A broad claim that the provider handles PCI becomes unreliable when card details can enter an internal form, log, replay tool, analytics event, or support ticket.
Tokenisation helps reduce exposure by exchanging sensitive account data for a token. That token still deserves security controls because it may allow payment operations inside the provider environment.
Record the token’s permitted uses. A token may be limited to one payment, attached to a customer, restricted to a merchant account, or unavailable outside the provider that created it.
The card-data review should answer:
| Question | Why the answer matters |
|---|---|
| Which component renders each payment field? | Establishes whether the merchant environment directly handles account data |
| Which domain receives the submitted values? | Reveals the real collection path |
| Can internal servers view or log raw payment details? | Affects security exposure and PCI scope |
| Which scripts can affect the payment page? | Identifies client-side security dependencies |
| Where are tokens stored? | Defines access-control and retention requirements |
| Can the token move to another provider? | Affects migration options |
| How are support agents prevented from collecting card details? | Reduces informal data-handling paths |
| Which systems receive payment metadata? | Identifies privacy, logging, and access requirements |
| How are credentials and webhook secrets stored? | Defines secrets-management controls |
| Who approves changes to the payment page? | Connects deployment governance to compliance |
Card security also involves the broader application environment. Access controls, deployment approvals, vulnerability management, monitoring, and incident response matter even when hosted components reduce direct handling of card data.
Strong Customer Authentication is a European regulatory concept associated with PSD2. A U.S.-based product may still encounter SCA when serving relevant European transactions or markets, so international plans should enter the architecture review early.
3D Secure 2 supports cardholder authentication flows during online payments. The customer can move through a low-friction result or an issuer challenge, depending on the transaction and authentication decision.
Your application needs to preserve state through that process. The checkout should handle return paths, interrupted sessions, authentication failure, timeout, and completion reported after the customer has left the page.
The data-flow diagram should include administrative actions as well. Refunds, captures, cancellations, payment-method updates, and dispute evidence often occur after the initial checkout.
I recommend assigning owners to the diagram and its assumptions. Security may own the compliance boundary, engineering the technical accuracy, product the customer journey, and finance the settlement path.
Review the diagram whenever the checkout changes. A new analytics script, wallet, support workflow, or mobile SDK can alter the system boundary.
Planning payments inside a larger build?
The gateway is one workstream in the wider application architecture. Our enterprise application development work covers identity, audit, deployment governance, and finance integration alongside it.
See how we scope enterprise builds →Score providers on total operating fit
The best payment gateway for apps is the provider that fits the product’s markets, methods, controls, settlement needs, and operating model. Brand familiarity or a low headline fee answers only part of that evaluation.
I start provider selection with requirements and evidence. Provider names enter the conversation after the team has agreed on what it needs to prove.
Stripe, Adyen, Braintree, Authorize.Net, and Razorpay can all appear in a market scan. Their suitability depends on the product, country coverage, merchant arrangement, payment methods, integration model, contract, and current documentation.
Ask each shortlisted provider for evidence tied to the same requirement set:
- Current API and SDK documentation
- Supported markets and currencies
- Payment-method coverage
- Settlement schedules and reports
- Refund and dispute behavior
- Webhook event documentation
- Idempotency support
- Sandbox behavior
- Production monitoring options
- Token migration or portability process
- Account and merchant structure
- Support and escalation process
- Contractual pricing components
- Security and compliance documentation
- Planned deprecations or versioning policy
The evaluation should use organization-defined priorities. A U.S.-only service marketplace will weight requirements differently from an international subscription platform.
The supplied weighted provider-selection framework is awaiting internal approval, so this draft omits proprietary weights and scores. The criteria below remain useful as a requirements and evidence guide.
Compliance burden carried by provider
Ask which compliance activities the provider’s integration model reduces and which remain with your organization. Phrase the requirement around data flow and responsibility instead of relying on broad compliance language.
Provider evidence should show how card data is collected, tokenized, transmitted, and made available to your systems. It should also identify the integration options that support the proposed scope.
The review should cover:
- Hosted checkout and embedded-field options
- Mobile SDK collection
- Token lifecycle and storage
- Credential management
- Webhook signature verification
- Access controls for provider dashboards
- Audit-log availability
- Security documentation
- Supported authentication flows
- Incident-notification process
Dashboard access deserves attention. A provider portal may allow refunds, exports, payment-method inspection, dispute responses, and account changes.
Use role-based access, strong authentication, and joiner-mover-leaver controls for those accounts. “Joiner-mover-leaver” describes the process for granting, changing, and removing access as people enter, change roles, or leave the organization.
Compliance ownership also extends to change management. A payment-page modification should trigger review when it changes scripts, domains, fields, storage, or data flows.
A provider can supply secure components and documentation. Your company owns the way those components are configured and connected.
Settlement terms and latency
Settlement latency is the time between a payment event and the availability of funds through the relevant payout or settlement process. It affects cash forecasting, merchant obligations, refund capacity, and reconciliation.
Ask providers to document settlement by market, currency, payment method, account type, and risk condition. Avoid assuming that one published schedule applies to every transaction.
Finance should review:
- Payout frequency
- Cutoff times
- Weekend and holiday treatment
- Reserve or hold conditions
- Negative-balance handling
- Refund funding
- Chargeback deductions
- Currency conversion
- Bank-account requirements
- Settlement-report availability
- Payout-level transaction detail
- Correction and adjustment behavior
Engineering needs this information because the system may have to display payout status, create expected settlement records, or investigate missing funds. Strong payment-processing APIs can still leave finance with a manual settlement problem.
Ask how the provider represents balance transactions. A payment amount, processing fee, refund, dispute, adjustment, and payout may appear as connected records instead of one net value.
The system should retain the provider references needed to join those records. Finance should have structured identifiers for matching deposits.
Marketplaces add further complexity. The provider’s merchant structure, connected-account model, payout ownership, and onboarding requirements can shape the full platform design.
I recommend involving treasury or finance leadership before selecting a marketplace provider. The operating consequences can exceed the visible API differences.
Multi-currency and payment-method requirements
Multi-currency support covers more than displaying a currency symbol. It can include presentment currency, customer payment method, provider account configuration, conversion, settlement currency, refunds, and reporting.
Define the requirement with concrete flows:
- The currency shown to the customer
- The currency authorized and captured
- The currency in which fees are recorded
- The currency received in settlement
- The exchange-rate source
- The refund treatment
- The finance reporting currency
- The responsible entity or merchant account
A product may accept several currencies while settling into fewer bank accounts. That can introduce conversion fees, exchange-rate differences, and additional reconciliation fields.
Payment-method requirements should begin with customer behavior and market plans. Cards, Apple Pay, Google Pay, bank transfers, and regional methods have different availability, authentication, refund, dispute, and settlement characteristics.
Treat wallets as payment-method interfaces with underlying funding sources and provider dependencies. Test the complete flow across device, browser, region, and account configuration.
Subscription products need saved-payment-method and recurring-payment behavior. Service marketplaces may need authorization before fulfillment and capture after completion.
The provider review should also ask how methods appear in reports. Finance needs to understand how card, wallet, and bank-based transactions enter the settlement artifacts.
Total cost beyond integration fees
Payment gateway integration cost has two broad parts: the work required to design and operate the integration, and the commercial cost of processing payments. Separate them in the business case.
Implementation work can include architecture, backend development, mobile SDKs, hosted checkout configuration, webhook processing, security review, testing, observability, finance exports, support tools, and production rollout.
Processing economics may include provider fees, interchange fees, assessments, cross-border charges, currency conversion, dispute fees, payout charges, fraud tools, recurring-billing products, and contracted platform services. The actual structure depends on the provider, payment method, merchant agreement, and market.
Use a cost model that accepts company-specific inputs:
| Cost category | Inputs to collect | Owner | Decision impact |
|---|---|---|---|
| Product and engineering | Integration model, channels, payment methods, subscriptions, admin tooling | Product and engineering | Establishes implementation scope |
| Security and compliance | Card-data flow, assessment obligations, testing, access controls | Security and compliance | Influences architecture and ongoing control work |
| Processing | Payment volume, average value, method mix, pricing model | Finance | Estimates variable transaction cost |
| Interchange and network components | Card mix, region, transaction type, contract structure | Finance and procurement | Clarifies total acceptance cost |
| Cross-border and currency | Customer geography, presentment currency, settlement currency | Finance | Reveals conversion and international charges |
| Disputes and refunds | Refund frequency, chargeback handling, evidence workflow | Operations and finance | Adds operational and provider cost |
| Fraud tooling | Rules, screening, review workflow, external services | Risk and product | Affects approval rates and loss controls |
| Settlement operations | Payout reports, reconciliation automation, accounting integration | Finance and engineering | Determines back-office workload |
| Reliability and support | Monitoring, incident response, provider support tier | Engineering and operations | Affects production operating cost |
| Portability | Adapter design, token migration, data export | Architecture and procurement | Affects future switching cost |
Build the model with ranges taken from your shortlisted providers and approved internal estimates. This draft avoids publishing a universal integration price because the brief supplies no approved AppVerticals cost range.
For broader product-budget planning, connect the payment scope to the ecommerce app development cost model. The gateway is one workstream inside the application architecture.
I advise boards and product leaders to compare total cost over the expected operating period. Manual reconciliation, restricted payment-method coverage, contract terms, and migration work can outweigh a small difference in initial effort.
Use your transaction profile. Headline pricing supplies one input.
Build the payment gateway integration
Once the team has selected an integration model and provisional provider, implementation should proceed from domain design to payment collection, event handling, reconciliation, testing, and controlled launch. I prefer a payment service or clearly bounded payment module for mid-market products because it gives the organization one place to enforce idempotency, state transitions, access controls, provider mapping, and audit behavior.
The core workstreams are:
- Define payment use cases and state transitions.
- Establish merchant and provider configuration.
- Map card-data and credential boundaries.
- Design the internal payment contract.
- Implement payment creation and confirmation.
- Add tokenized payment-method handling.
- Receive, verify, and persist webhooks.
- Build capture, cancellation, refund, and dispute workflows.
- Add wallets and authentication flows.
- Connect finance and reconciliation records.
- Test failure paths.
- Prepare production monitoring and incident ownership.
Each step needs an acceptance test. “API connected” provides no evidence that the payment workflow is safe to launch.
Create payments and tokenize data
The backend should create the authoritative payment request using a server-calculated amount, currency, order reference, and customer context. The client application should never have sole authority over the amount submitted for processing.
Use an internal payment identifier and preserve the provider’s identifier separately. This makes the relationship explicit and supports future adapters.
A basic internal record may include:
- Internal payment ID
- Order, invoice, or subscription ID
- Provider and merchant-account ID
- Provider payment ID
- Payment attempt ID
- Amount and currency
- Authorized amount
- Captured amount
- Refunded amount
- Current internal state
- Provider state
- Payment-method type
- Customer reference
- Idempotency key
- Authentication status
- Creation and update timestamps
- Reconciliation status
- Payout or settlement reference
Keep sensitive account data out of this record. Store provider tokens and safe display metadata only when the product requires them and the security design allows it.
A token should have a defined owner and lifecycle. Decide whether it represents one payment attempt, one customer payment method, a subscription mandate, or another provider-specific object.
Saved-payment-method flows need customer consent, update handling, and deletion behavior. The provider’s current documentation and the company’s legal review should define the final implementation.
Use secrets-management infrastructure for API credentials and webhook secrets. Restrict access by environment and service.
Test and production credentials require clear separation. The application should make an accidental cross-environment configuration easy to detect.
Mobile and frontend code should receive only credentials designed for public client use. Privileged server credentials belong behind the backend boundary.
Log the internal and provider references needed for diagnosis. Filter sensitive fields before logs, analytics, crash reports, and support tools receive the data.
Handle webhooks and idempotency
A webhook is an asynchronous message sent by the provider to report an event. Examples include payment completion, failed capture, refund, dispute, or payout updates.
Treat verified webhooks as a key source of payment-state evidence. Browser responses remain useful for customer experience, while the backend confirms the durable state through provider events and status checks.[1][2]
Every webhook endpoint should:
- Receive the raw request in the format required for verification
- Verify the provider signature
- Reject invalid or stale requests according to the provider’s rules
- Store the event ID and relevant metadata
- Detect previously processed events
- Acknowledge valid receipt quickly
- Process the event asynchronously where appropriate
- Map the provider event to an internal transition
- Record the result
- Retry recoverable failures
- Route unresolved exceptions to an operational queue
Providers may deliver the same event more than once. Event processing needs to be idempotent, meaning repeated handling produces the same business result without duplicate fulfillment or financial action.
Idempotency also applies to outbound API requests. An idempotency key allows a retry to refer to the same intended operation when the first response is lost or delayed.
Generate keys around business operations. A payment attempt, capture request, or refund command should have a stable identifier that survives a network retry.
Avoid reusing one key for unrelated operations. The key should identify the specific intent and carry enough context for investigation.
The event handler also needs state-transition rules. A delayed event should never roll a payment backward into an invalid state.
For example, an old authorization update arriving after capture needs evaluation against the current record. Event timestamp, provider sequence information, current state, and allowed transitions can guide the decision.
A practical webhook event matrix looks like this:
| Provider event category | Internal action | Idempotency control | Reconciliation effect | Exception path |
|---|---|---|---|---|
| Authorization | Record approved or declined attempt | Provider event ID and payment attempt ID | Creates expected authorization record | Queue unexpected state or amount |
| Capture | Update captured amount and fulfillment eligibility | Capture operation ID | Creates receivable transaction | Hold fulfillment on mismatch |
| Payment failure | Record reason category and recovery state | Event ID | Clears or updates expected receivable | Route repeated failures to support |
| Refund | Record requested and completed refund states | Refund command ID and provider refund ID | Creates expected debit or adjustment | Queue amount or state mismatch |
| Dispute | Open chargeback case and assign owner | Provider dispute ID | Creates provisional or final adjustment | Escalate deadline and missing evidence |
| Payout | Record payout and included balance references | Provider payout ID | Starts settlement matching | Queue missing or unmatched items |
Webhook reconciliation compares the event stream with API records and settlement artifacts. The event handler alone cannot prove that every expected event arrived.
Use scheduled checks for open or ambiguous transactions. A status poll or provider report can identify missing webhooks and state drift.
Monitoring should cover endpoint failures, verification failures, queue age, processing errors, retry exhaustion, and unusual event-volume changes. Alerts need an accountable owner and a documented response.
Support Apple Pay, Google Pay, and 3D Secure 2
A payment gateway integration in a mobile app adds wallet, SDK, device, and app-store considerations. The payment rail also depends on what the application sells.
For physical goods and services, mobile apps commonly use a gateway or payment service provider and may offer Apple Pay or Google Pay. Digital goods consumed inside the application can fall under Apple App Store or Google Play billing requirements, so teams should verify current official platform rules before implementation.[1]
That distinction belongs in product discovery. A late correction can force changes to pricing, entitlements, server notifications, transaction records, and release planning.
For a broader application-delivery context, use our mobile app development guide alongside this payment scope.
A native provider SDK can manage wallet presentation, token collection, and authentication UI. Evaluate its maintenance status, platform coverage, accessibility, documentation, and compatibility with the application architecture.
Cross-platform applications still need platform-specific testing. React Native can share application code, while Apple Pay and Google Pay behavior remains connected to native configuration, device capabilities, merchant setup, and provider support.
Wallet implementation requires more than placing a button. Confirm:
- Merchant registration and domain or application verification
- Device and account eligibility
- Supported card and region behavior
- Shipping and billing information requirements
- Amount updates
- Cancellation paths
- Authentication results
- Provider token processing
- Refund display
- Analytics and support references
- Accessibility
- Fallback payment methods
3D Secure 2 introduces an authentication state that can affect the checkout journey. The product needs to handle successful authentication, issuer challenge, authentication failure, timeout, and an interrupted return path.
Preserve the internal payment attempt across that flow. Creating a fresh payment every time the application resumes can create duplicates.
Mobile applications should display a pending state when final confirmation remains outstanding. A clear pending experience is safer than reporting failure during an ambiguous provider response.
Push notifications and in-app status refresh can help where processing continues after the customer leaves the payment screen. The backend remains responsible for the authoritative status.
Deep links and return URLs need security review. Validate the destination, session, user, and associated payment attempt before updating the interface.
Test the mobile flow on real devices and relevant operating-system versions. Emulators and provider sandboxes provide useful coverage, while device wallets, app switching, biometric authentication, and network transitions require realistic testing.
Design reconciliation and chargeback operations
Reconciliation confirms that product orders, provider transactions, fees, refunds, disputes, and bank payouts agree. It is the control that turns a working payment flow into an operable financial system.
I ask finance and engineering to design reconciliation together. Finance understands the expected accounting result, while engineering understands the identifiers and event history available for matching.
Start with three layers:
- Transaction reconciliation: Does each internal order or invoice match the correct provider payment, capture, and refund?
- Balance reconciliation: Do provider balance entries explain fees, disputes, adjustments, and amounts eligible for payout?
- Bank reconciliation: Does each payout or settlement record match the deposit received in the bank account?
Each layer needs identifiers. Amount, date, and customer name provide weak matching when partial capture, grouped payouts, refunds, or currency conversion are involved.
Preserve internal order and payment IDs in provider metadata where allowed. Retain the provider’s payment, balance, refund, dispute, and payout references in your internal records.
Webhook events can update operational status quickly. Provider reports, APIs, settlement records, and bank data complete the financial view.
Define tolerances and aging rules. An authorized payment awaiting capture has a different expected lifecycle from a payout that should already have reached the bank.
Exception queues need categories:
- Missing internal order
- Missing provider payment
- Amount mismatch
- Currency mismatch
- Duplicate payment
- Capture mismatch
- Refund mismatch
- Fee mismatch
- Dispute adjustment
- Payout mismatch
- Unknown provider adjustment
- Missing bank deposit
- Unmatched bank deposit
Each category should have an owner, required evidence, and resolution action. A shared spreadsheet without ownership tends to accumulate unresolved exceptions.
The reconciliation checklist below establishes the operating flow:
| Event | Source | Owner | Control | Exception path |
|---|---|---|---|---|
| Authorization | Gateway API and webhook | Payment operations or engineering | Match payment attempt, amount, currency, and status | Review duplicate, unknown, or mismatched attempts |
| Capture | Gateway API, webhook, and order system | Engineering and finance operations | Match captured amount to fulfillment or invoice rule | Hold fulfillment or investigate partial capture |
| Refund | Product record and provider refund event | Customer support and finance | Match refund request, provider reference, amount, and completion status | Queue failed, duplicate, or unmatched refund |
| Chargeback | Provider dispute event and dashboard | Chargeback owner, finance, and support | Assign case, deadline, reason, amount, and evidence | Escalate approaching deadline or missing evidence |
| Payout | Provider payout API or report | Finance operations | Match included balance entries and expected net amount | Queue missing transaction, fee, or adjustment |
| Settlement | Provider report and bank feed | Finance | Match provider payout to bank deposit and accounting entry | Investigate delayed, split, or unmatched deposit |
Chargeback handling begins before a dispute arrives. The product should retain the customer, order, fulfillment, communication, authentication, refund, and policy records that the authorized operations team may need.
The exact evidence depends on the business and dispute reason. Access controls should restrict sensitive data while allowing timely case preparation.
A chargeback workflow needs:
- Provider dispute ID
- Internal payment and order IDs
- Dispute reason
- Amount and currency
- Response deadline
- Assigned owner
- Evidence checklist
- Submission status
- Provider outcome
- Accounting treatment
- Customer-account decision
Track chargeback status separately from the original payment status. The payment may remain captured while the dispute creates a financial adjustment and operational case.
Refunds deserve similar discipline. Record request, approval, provider submission, provider completion, and customer communication as distinct events when the workflow requires them.
Partial refunds and multiple refunds can create subtle balance errors. Validate the refundable amount before submission and use an idempotent refund command.
Reconciliation should run often enough to support the business risk. High-volume or operationally sensitive platforms may need continuous event checks plus scheduled financial matching.
The control design also needs a close process. Finance should know which exceptions can remain open, which block accounting close, and which require engineering escalation.
Provide support teams with a consolidated transaction view. They should be able to see safe payment details, status, refunds, disputes, and relevant references without receiving excessive provider privileges.
That view reduces dashboard hopping and improves incident reports. It also supports provider migration because operational history stays attached to the internal payment record.
Test before production launch
Payment testing should concentrate on state transitions and failure paths. A successful sandbox payment establishes basic connectivity and little else.
Build test cases from the payment lifecycle. Every state-changing operation needs normal, duplicate, delayed, declined, and ambiguous outcomes where those conditions can occur.
The test plan should include:
- Successful authorization and capture
- Authorization decline
- Authentication challenge
- Authentication failure
- Customer cancellation
- Network timeout before response
- Provider timeout after processing
- Duplicate submit
- Duplicate webhook
- Delayed webhook
- Invalid webhook signature
- Out-of-order event
- Partial capture
- Capture failure
- Full refund
- Partial refund
- Duplicate refund request
- Refund failure
- Chargeback event
- Payout event
- Settlement mismatch
- Expired payment method
- Currency mismatch
- Unsupported payment method
- Mobile app interruption
- Browser refresh
- Session expiration
- Credential or configuration error
Use the same internal observability in the sandbox that you expect in production. Logs, metrics, traces, event records, and dashboards should make a failed test diagnosable.
A good test case proves more than the user interface message. It verifies the internal payment record, provider state, order state, emitted events, audit history, and reconciliation effect.
Idempotency tests deserve deliberate concurrency. Submit the same logical operation through network retry, repeated button tap, and queued job retry scenarios.
Webhook tests should deliver the same event repeatedly. They should also deliver valid events in an unexpected order and confirm that state-transition rules protect the record.
Security testing should cover unauthorized refund or capture attempts, exposed credentials, signature verification, sensitive logging, excessive dashboard privileges, and input manipulation.
Mobile testing needs device transitions. Move the app into the background during wallet presentation or authentication, change networks, return through a deep link, and resume after the provider state has changed.
Test accessibility in the payment flow. Screen-reader labels, keyboard navigation, focus order, error messages, wallet controls, and authentication transitions can affect completion.
Validate operational tooling with the same seriousness as checkout. Ask support to find a transaction, issue an approved refund, and explain a pending status using the intended interface.
Ask finance to reconcile test payments, fees, refunds, and payout records. A finance export discovered after launch can reveal missing metadata that requires code changes.
Production readiness should include:
- Approved card-data-flow diagram
- Completed security review
- Environment-separated credentials
- Production webhook endpoint and secret
- Dashboard access controls
- Merchant and bank configuration
- Monitoring dashboards
- Alert thresholds and owners
- Incident runbook
- Refund and dispute procedures
- Reconciliation schedule
- Support training
- Provider escalation contacts
- Rollback or feature-control plan
- Controlled live-transaction validation
Keep production enablement reversible where the architecture allows it. Feature flags, traffic controls, and provider routing configuration can reduce the impact of a launch issue.
Observe the first production transactions closely. Compare product, provider, webhook, and finance records instead of relying on checkout completion alone.
Sandbox-to-production drift can come from credentials, webhook URLs, account capabilities, domain verification, merchant settings, or payment-method enablement. A production checklist should make each difference explicit.[1][2]
Incident ownership needs clarity before launch. Payment incidents can involve engineering, the provider, finance, support, risk, or an external bank.
Define who leads, who communicates, and which actions require approval. A refund spike and a webhook outage may share symptoms while requiring different responses.
Scope a payment integration project
A useful payment-integration scope translates architecture decisions into workstreams, owners, and acceptance tests. It should also identify which decisions remain with the client, provider, security reviewer, and implementation team.
I begin with the commercial model. The system cannot design payments correctly until it understands what is being sold, when the amount becomes final, when fulfillment begins, and when money should move.
Discovery should answer:
- Who is the merchant?
- Who is the customer?
- Are any third-party sellers or service providers involved?
- What countries and currencies are in scope?
- Which payment methods are required?
- Are purchases one-time, recurring, usage-based, or marketplace transactions?
- When is authorization required?
- When does capture occur?
- Can the amount change after authorization?
- What are the cancellation and refund rules?
- How are disputes handled?
- Who receives settlement?
- Which system owns orders, invoices, subscriptions, and accounting?
- Which mobile and web channels accept payments?
- What reporting and support tools are required?
The next scope layer covers architecture. Decide whether the product uses hosted components, direct APIs, orchestration, or custom infrastructure.
Define the payment service boundary and provider adapter. Map token storage, customer references, status transitions, retries, webhooks, and event persistence.
The finance layer should specify settlement reports, fee records, payout matching, accounting exports, and exception queues. Chargeback and refund ownership also belong here.
The security layer should specify card-data flow, credentials, access controls, logging filters, dashboard governance, security review, and applicable PCI DSS work.
The mobile layer should distinguish physical goods and services from digital goods. It should cover wallet setup, native SDKs, app-store billing review, deep links, authentication, and device testing.
The production layer needs observability, runbooks, support procedures, escalation contacts, and rollout controls. These are delivery requirements.
Use this implementation checklist to establish responsibility:
| Workstream | Requirement | Owner | Acceptance test |
|---|---|---|---|
| Security | Approved card-data flow, secrets management, access control, safe logging | Security and engineering | Security review confirms implementation matches documented flow |
| Backend | Internal payment model, provider adapter, payment operations, state rules | Backend engineering | Supported payment lifecycle passes functional and failure tests |
| Mobile | Wallets, SDK integration, authentication return flow, store-rule review | Mobile engineering and product | Real-device flows complete and recover from interruption |
| Webhooks | Signature verification, event storage, idempotency, retries, monitoring | Backend engineering | Duplicate, delayed, invalid, and out-of-order events behave safely |
| Finance | Fee, refund, dispute, payout, and settlement matching | Finance and engineering | Finance can reconcile test lifecycle from order through bank record |
| Production readiness | Credentials, monitoring, alerts, runbooks, support access, controlled launch | Engineering, operations, and support | Readiness review approves production configuration and incident ownership |
A payment gateway integration company should be able to discuss each workstream in operational terms. Ask how it will design the payment state model, test idempotency, reconcile settlements, and limit provider coupling.
Payment gateway integration services should also distinguish client responsibilities. Merchant-account approval, provider contracts, bank configuration, compliance interpretation, and internal finance policies may remain outside the engineering team’s authority.
For enterprise environments, identity, audit, deployment governance, finance integration, and role-based administration often expand the work. Our overview of enterprise application development provides the wider system context.
Scope deliverables should include:
- Payment context and system diagram
- Card-data-flow diagram
- Payment state model
- API and provider-adapter design
- Webhook event matrix
- Data model
- Security and access-control plan
- Reconciliation workflow
- Chargeback operating model
- Test plan
- Production-readiness checklist
- Monitoring and incident plan
- Assumptions and exclusions
- Responsibility matrix
These artifacts make estimates more defensible. They also reduce ambiguity when several internal teams and external providers are involved.
Avoid estimating from the number of checkout screens. A compact interface can sit above substantial backend, finance, security, and operational work.
The Spruce project reinforces this scoping principle. Its Braintree integration sat inside a system with booking, dynamic pricing, capacity, scheduling, and several role-specific applications.[3]
That environment required architecture decisions across the platform. Payment had to coexist with the business rules that generated service prices and bookings.
Follow the money from commercial rule to settlement record. The checkout interface covers one part of that path.
Plan your payment gateway integration
You now have the basis for a defensible payment architecture decision: an integration model, card-data boundary, provider evidence set, state model, webhook design, reconciliation workflow, cost inputs, and production controls.
I would take that packet into one scoping review with product, engineering, security, finance, support, and procurement. Resolve the merchant model, payment methods, settlement ownership, and provider evidence before implementation begins.
The next action is concrete. Assign an owner to each unanswered requirement and prevent provider configuration from moving ahead until the card-data flow and operating model agree.
Book a payment architecture review
Bring your commercial model and we will map the card-data flow, integration model, and reconciliation design before you commit to a provider. You leave the session with a scoped workstream list and an owner against each unresolved decision.
ChatGPT