Payment gateway integration: choosing a provider and integrating securely

We explain hosted-platform setup versus custom integration, fee and settlement assessment, payment verification and data protection before release.

Payment gateway integration: choosing a provider and integrating securely

Start with the business model

When a business wants to integrate a payment gateway into a website or app, establish its sales model first. Does it collect a single payment or recurring subscriptions, accept quotations before invoicing, or operate a marketplace? Integration, merchant approval and settlement differ with the model. We do not choose providers simply because a fee looks lower or a logo is familiar. Review required payment methods, territories, currency, business accounts, provider conditions and suitability for the activity.

Request an official fee schedule covering each payment method, fixed fees, refunds, settlement and applicable taxes. Examine how funds are transferred, normal settlement arrangements and circumstances that may delay payment. Do not model every transaction using one rate. Selecting a provider is separate from merchant-account approval, which belongs to the relevant provider.

Hosted setup or custom development?

A commerce platform with a supported gateway integration may only require configuration, connection to a merchant account and workflow testing. Our hosted payment setup service is listed at SAR 750 for its defined scope. Reimplementing payment logic is unnecessary if the existing integration meets the requirements. A custom system needs its own authorised payment-creation, verification, order association and error handling workflow. Our custom payment integration service is listed at SAR 3,000 within the published scope. Neither fee automatically includes payment-provider charges or complex financial functions outside the agreed work.

From order creation to confirmation

In a custom integration, the backend determines the order amount and currency from authoritative records and retains an operation reference. The application uses the provider's supported payment method, then receives a result, notification or verifies the payment through a documented interface. A success page shown to the customer is not conclusive proof of payment. The backend must validate payment state, reference, amount, currency and association with the order according to the gateway's instructions.

If connectivity fails after payment, retain a reconcilable order state rather than immediately asking the customer to pay again. Notifications can arrive repeatedly, late or out of order. Use operation identifiers and appropriate constraints to prevent a duplicate payment update or financial record, and define how staff investigate a mismatch between the gateway and local system.

Protect payment information

Use the provider's supported payment flow and avoid unnecessary handling or storage of card information. Keep secrets on the backend rather than public application code, and separate testing from production credentials. Verify notification authenticity according to current documentation and review access to refunds and reports. Avoid sensitive data in logs or error messages, and never distribute production credentials to parties that do not need them.

A hosted payment page can reduce direct handling of card data, but does not automatically remove all security obligations or applicable PCI DSS responsibilities. Determine the relevant obligations based on the actual integration model, provider requirements and specialist guidance. Review the current gateway documentation before implementation.

Illustrative transaction-cost calculation

For illustration only, assume a SAR 300 transaction with a hypothetical 2% fee plus SAR 1 fixed charge. The example fee would be SAR 7 before applicable taxes or other charges. One hundred transactions of the same amount would incur SAR 700 for that item. These are not any provider's rates or a binding quote. Calculate percentage and fixed fees separately using realistic basket values. Payment methods and refund conditions may differ. Substitute the official offer and incorporate it into your online store budget.

Acceptance tests before enabling live payment

  • Successful test payment matching the expected reference, amount, currency and order.

  • Failed or cancelled payment without marking an unpaid order as paid.

  • Delayed and duplicate notifications without duplicate financial updates.

  • Lost connectivity after a payment attempt followed by reconciliation of its state.

  • Authorised refund behaviour where in scope, including consistent records.

  • Review of production configuration, credential access and operational monitoring.

We define these tests according to functions the provider actually supports. For an existing system, our website improvement guide explains assessing the architecture before implementing changes.

Reconcile payments and investigate discrepancies

After a successful online payment, the merchant may receive a bank settlement differing from gross order values because of fees, refunds or settlement timing. We distinguish provider transaction status, the order's internal payment state and financial settlement status. A customer's successful payment does not automatically establish receipt of net funds into the merchant's bank account. Finance personnel need to reconcile transaction and order identifiers, amounts, currency and fees against provider records, with a defined procedure for unexplained differences.

Test a customer losing connectivity immediately after approving payment. The provider may have processed the transaction despite the browser not receiving its response. Do not instruct the customer to pay again without verifying the earlier transaction through the approved process. Duplicate notifications should not create duplicate payments or shipments. Events may also arrive in an unexpected order; use confirmed state and permitted transitions instead of assuming every notification arrives exactly once and in sequence.

Separate test and production credentials

Use the provider's test environment to verify successful and declined payments and supported refund cases. Keep secret credentials in their designated server environment, not public interfaces or request logs. Before enabling production transactions, review the approved merchant account, contact configuration, notification endpoints and settlement procedures. We do not initiate real transactions without explicit authorisation and an agreed testing plan. Assign responsibility for failed notifications or changed provider requirements after release.

Document the payment journey across customer, application and provider

When creating an order, the application establishes its amount, currency and identifier before initiating payment. Do not rely on a browser-controlled amount without server validation. After creating a provider transaction, retain its reference against the correct order. On receiving a payment outcome, verify authenticity using the provider's documented method, then compare amount, currency, reference and status. If information differs, do not mark the order paid simply because the received message indicates success. Route the discrepancy for appropriate review.

Provider-hosted checkout and embedded payment interfaces have different integration boundaries. Establish what the provider supports and what the business remains responsible for, including information protection. Hosted checkout does not remove the application's responsibility for account and order security or server-side outcome verification. A successful sandbox integration also does not establish that the merchant account is approved for live settlement. Confirm account approval, required payment methods and production configuration before accepting real transactions.

Design reviewable financial states

If the business supports partial payments or refunds, define how amounts appear in orders, invoices and financial records. Do not alter the original amount merely to conceal the effect of a refund. Preserve the original transaction reference and refund amount and status according to system rules. For an illustrative SAR 500 order with a SAR 100 refund, the remaining amount after refund is SAR 400 before provider fees or other settlement adjustments. This does not imply every gateway supports partial refunds or applies identical fees. Consult provider documentation and the agreement for supported operations.

Test to prevent duplicate payments and fulfilment errors

Prepare a sandbox order and perform a successful payment, then test a declined payment and closing checkout before returning to the site. Verify the order cannot be released for fulfilment before the required state is confirmed. Replay the same provider notification in the test and confirm payment and order counts do not increase. Test an unexpected late outcome from an older transaction after a newer attempt. Review with operations how a transaction can be found and who may request refunds, documenting whether refund functionality belongs to the agreed scope or requires separate implementation. Full card information should not be stored in application logs for convenience during troubleshooting.

Choose a payment gateway by transaction needs, not fees alone

When comparing gateways, consider required payment methods, business type, supported currencies, settlement, refunds and dispute procedures. A low individual transaction fee does not establish that the provider meets operational requirements. Review all contractual charges, including fixed fees, method-specific charges and subsequent processing costs; avoid treating an old advertisement or article as a definitive tariff. If the business wants a second provider for operational reasons, assess effects on customer experience, reporting and reconciliation. Adding another provider does not automatically ensure recovery from an outage: retries must prevent duplicate charges.

During integration, examine official documentation and select the operations needed rather than implementing every available interface. A project may cover one-time order payments and outcome handling, or require partial refunds or recurring subscriptions if supported and authorised. Define covered scenarios and separate acceptance tests. We do not promise financial features unavailable under the merchant agreement or account configuration.

Support payment operations after launch

A customer may report a bank charge while their order remains unpaid in the application. Staff need a transaction-verification procedure rather than instructing the customer to pay again immediately or manually changing the status without evidence. Review the available reference, timing and amount through provider-approved processes, and identify who is authorised to update the record or request a refund. Administrative interfaces should avoid exposing unnecessary card information. If the issue belongs to the provider, identify relevant support evidence without sharing secrets or sensitive information through inappropriate channels.

At handover, identify configuration requiring review when a domain, merchant account or operating environment changes and who may access it. Retain a change history and do not use production credentials in unapproved test environments. If applicable processing or compliance obligations require additional assessment, allocate responsibility with the appropriate specialist. The objective is a payment operation staff can run and troubleshoot through documented procedures, not merely a checkout button that works in its first demonstration.

Frequently asked questions

Can we connect more than one gateway?

Yes, subject to review. Each requires separate state handling, fees, settlement and testing. Multiple providers should serve a defined objective and agreed scope.

Does integration include merchant account approval?

No. Applications, documentation and merchant acceptance are handled by the provider. We support the technical integration within scope once prerequisites are available.

Is a success message in the interface sufficient?

No. Backend verification of status, reference, amount and currency must follow the provider's documentation, with consistent and non-duplicating records.

Confirming the service scope before ordering

When you request Payment Gateway Setup for Hosted Platforms, we review the published scope with you. Included items are: Configure one supported provider; Enable supported payment methods; Test payment and fix configuration issues. Items you should not assume are included: Custom payment engine; Provider fees. We specify additional work in the quotation before implementation and agree acceptance against the defined deliverables rather than a general service description.

Our related services: Custom Payment Gateway Integration.

Official references

Related articles