Payment Integration API for Custom Software

Payment Integration
December 5, 2026

Payment Integration API for Custom Software

[HERO] Payment Integration API

A payment integration API connects custom software to payment collection, transaction processing, and follow-up operations. It defines how your application securely submits payment requests and receives transaction results.

The decisions below are generic by design. Exact field names, endpoints, and error codes belong to whichever processor or gateway you select, so treat this as the architecture and process, then map it to that provider's current documentation.

The gateway handles payment credentials and supported transaction operations. Your application remains responsible for business rules, orders, and fulfillment. This guide is the API implementation companion to our custom-software payment architecture overview.

What the API Owns vs. What Your Application Owns

The API is the contract between the gateway’s payment domain and your application’s business domain. It establishes which requests your software can make, what responses to expect, and how to manage transaction actions.

The gateway handles payment credential collection and tokenization, transaction submission, and supported actions such as capture, void, and refund. Your application handles order creation, pricing, taxes, entitlement, fulfillment, and business reporting.

Keep these responsibilities distinct. Your server should validate the order and its amount before submitting a payment request; a gateway response should not determine product prices or fulfillment rules.

API responsibilities split

Understand the API Surface Before You Write Code

First map the operations your application needs. A payment gateway API may support a tokenization or hosted-collection step, transaction submission, capture, void, refund, transaction-status lookup, stored-credential references, and recurring billing.

The exact resource model and available operations depend on the current integration specification. Read the current API reference for exact variable names, required fields, authentication details, and supported workflows. Never hard-code assumptions from a blog post.

For broader integration context, review the payment gateway integration guide.

Authenticate and Isolate Credentials

Separate public, client-side configuration from private, server-side transaction credentials. Tokenization keys and publishable identifiers are designed to be public-facing. Transaction credentials are not, and they must never leave your server.

Store private credentials in an access-controlled secrets system, separate test and production values, and restrict access to the services that need them. Rotate them on a defined schedule and immediately after any staff change. Never include transaction credentials in browser code, mobile bundles, source control, or client-visible error messages.

Credential isolation keys

Build the Integration: Step 1 to Step 7

Follow the steps in order. Each one ends with something you can verify before moving on.

Step 1: Request a Test Merchant Account

Request a test merchant account from your processor and collect its test credentials. Confirm which API documentation, test card values, transaction types, and event configuration apply to your integration.

Verify that test credentials and configuration cannot be used by production services. Keep the two environments separate at the configuration level, not just by convention.

Step 2: Configure the Collection Model

Choose a collection model: a hosted payment page, hosted payment fields, or a direct server-side API submission. Confirm where payment data is collected and whether sensitive data can reach your application.

Each option moves the payment-data boundary. A hosted page keeps collection entirely outside your application, payment fields keep it outside your server but inside your page, and direct submission puts the most responsibility on your own systems. Decide deliberately, before writing request code.

Step 3: Build the Server-Side Transaction Request

Have your server load the order and calculate the amount and currency from trusted records. Validate that the order is payable and that the amount matches its current state before building the request payload.

Do not trust totals, discounts, or currency values submitted by the browser. Include the required payment reference and correlation information using only the fields specified in the current API reference.

Step 4: Submit the Transaction and Capture the Response

Send the request from your server using test credentials. Parse the documented response and map it into an internal payment record.

Store the processor's transaction reference, the authorization result, the response result, and the raw response for audit where permitted. Filter or redact sensitive data before storing responses, and never retain prohibited payment data.

Step 5: Model Payment State Explicitly

Use an internal state model rather than a single paid flag. Your model should distinguish at least these conditions: created but unpaid, payment pending, authorized but not captured, captured but not settled, settled, declined, failed, voided, partially refunded, fully refunded, outcome unknown, and awaiting reconciliation.

Name them however your own system prefers. What matters is that each one is a distinct state your code can act on, and that the states are ordered so an out-of-sequence event can be rejected rather than applied.

Map the processor's response results into those states using their published meanings. Keep the original response details available for authorized troubleshooting, but let your internal state drive order and fulfillment workflows.

Step 6: Handle Errors, Timeouts, and Duplicates

Distinguish a transport failure from a payment decline. A timeout means your application may not know whether the gateway received or processed the request; it does not prove that the payment failed.

Create an application-level idempotency key for each business payment and keep it stable across retries. Resolve unknown outcomes using status lookup before retrying. Never retry a capture or refund blindly.

Payment state outcomes

Step 7: Receive and Verify Webhooks

Create an HTTPS webhook endpoint and verify event authenticity using the gateway’s documented signature process. Persist each event identifier, deduplicate repeated deliveries, and queue valid events for background processing.

Respond promptly after safely recording the event. Then reconcile it against the internal order and payment record; do not rely on browser redirects as proof of payment.

Webhook verification dedupe

Query and Reconcile Transaction State

Use status lookup to investigate pending or unknown outcomes and to confirm transaction changes. Maintain an identifier chain linking the internal order to the gateway transaction, batch, settlement, and payout.

Reconciliation compares these records and identifies missing, delayed, or mismatched updates. Close every unknown result through lookup, webhook processing, or operational review. Do not leave it open or silently mark it as declined.

Reconciliation chain

Extend to Stored Credentials and Recurring Billing

Use stored-credential references rather than storing card data in your application. Keep the processor’s reference and the customer’s identity linked in your own records, while following the documented rules for reuse.

Distinguish customer-initiated transactions from merchant-initiated transactions. For recurring charges, define how your application creates and tracks a billing agreement, processes renewal outcomes, and handles cancellations or payment failures. Our payment integration guidance covers how these decisions fit into a wider integration plan.

High-Level Technical Guidance

Four decisions shape the rest of the integration. Settle them before writing request code, because each one is expensive to change once transactions exist.

Decide the Data Boundary

Choose the point at which payment data stops and your application begins. In a hosted or tokenized model, that boundary is the token or stored-credential reference. Everything on your side of it can be logged, copied to a data warehouse, and read by support staff without touching card data.

Write the boundary down. Confirm which services may hold private credentials, which fields may appear in logs, and what must be redacted before a response is stored.

Decide State Ownership

Determine which system is authoritative for each fact. The gateway is authoritative for authorization, capture, settlement, and refund outcomes. Your application is authoritative for what the customer bought, what they are entitled to, and whether the order should proceed. Your database should store both, linked by the gateway transaction reference.

Define the order in which state changes may occur, and reject a transition that arrives out of order. Late events happen in every integration.

Decide Failure Semantics

Agree in advance what happens for each outcome class: approved, hard decline, soft decline, transport failure, duplicate request, and unknown. Unknown is the one most teams skip, and it is the one that produces double charges.

Document who resolves an unknown result and how quickly. A payment left in unknown state is a customer with no confirmation and, often, an order that was never fulfilled or fulfilled twice.

Decide Observability

Record the fields you would need to diagnose a payment without asking the customer for their card. That means the internal order identifier, the gateway transaction reference, the attempt identifier, the timestamp, the response class, and the route or terminal involved where relevant.

For security boundaries and compliance considerations, review PCI security for payment API integrations. Hosted collection or tokenization can limit exposure, but does not remove the need to assess your full implementation. The PCI Security Standards Council publishes the current DSS requirements and SAQ documents that define the assessment itself.

Implementation Checklist

Credentials and Environments

  • Request test merchant credentials and confirm the applicable API documentation.
  • Separate test and production credentials and configuration.
  • Store private credentials in an access-controlled secrets system.

Request Handling

  • Select and document the payment collection model.
  • Calculate and validate amount and currency on the server.
  • Build requests using current documented fields only.
  • Store transaction identifiers and permitted response details.

State and Errors

  • Define explicit payment states and documented response mappings.
  • Distinguish declines from transport failures and timeouts.
  • Use one stable idempotency key per business payment.
  • Resolve unknown outcomes before retrying a payment action.

Webhooks and Reconciliation

  • Use HTTPS and verify webhook signatures.
  • Persist event identifiers and deduplicate deliveries.
  • Queue webhook processing and reconcile events with internal orders.
  • Link orders, transactions, batches, settlements, and payouts.

Stored Credentials, Testing, and Compliance

  • Store credential references rather than raw payment data.
  • Record whether each stored-credential charge is customer initiated or merchant initiated.
  • Test approvals, declines, timeouts, refunds, and duplicate events in the test environment.
  • Test a lost response and close it out through status lookup.
  • Confirm production configuration before enabling live transactions.
  • Review your PCI DSS responsibilities and applicable annual SAQ.

Common Integration Mistakes

These appear in most first integrations. Each one is cheaper to fix at design time than after launch.

  • Trusting browser-submitted totals. Calculate the amount from server-side order data before building the request.
  • Shipping private credentials in a client bundle. Keep transaction credentials on the server and audit bundles before release.
  • Treating a timeout as a decline. Look up the transaction status before deciding the outcome.
  • Retrying captures or refunds blindly. Confirm the original operation result before submitting another.
  • Using a redirect as payment confirmation. Confirm the transaction through the server-side response or status lookup.
  • Processing a duplicate webhook twice. Persist the event identifier and reject repeats before any side effect.
  • Storing raw payment data for convenience. Collect payment data through the gateway and keep only references.
  • Leaving unknown outcomes open. Close every unresolved result through lookup, events, or operational review.

Work through the steps in order and verify each one before moving to the next. For teams that want help architecting the wider project, Integrate Payments works with web and software developers on payment integration design and processor relationships. Review the sandbox-to-production workflow before you enable live transactions.

Compliance disclosure: Hosted collection or tokenization may reduce payment-data exposure but does not by itself establish PCI DSS compliance. Merchants remain responsible for determining and completing the applicable annual Self-Assessment Questionnaire (SAQ).

Integrate Payments Related Blog Posts

Every merchant account will have to stay compliant by completing a SAQ Self Assessment Questionnaire every year or they will be charged a monthly PCI non compliance fee. PCI monthly & annual fees may still apply to a merchant account based on PCI Tier level of business.