ElmoSoft
  • How we work
  • Portfolio
  • Services
    • Web Development Services
    • Agentic QA Services & AI Test Automation
    • Software Testing & QA
    • Test Automation Services
    • Nearshore Software Development
    • Financial technology at ElmoSoft
    • Software development for startups
    • Demand Forecasting in Retail
  • Blog
  • About Us
  • Contact Us
November 27, 2026 by Alex Mordas

How to Integrate a Payment Gateway in a Mobile App

How to Integrate a Payment Gateway in a Mobile App
November 27, 2026 by Alex Mordas

Adding payments to a mobile app looks like a two-week job and turns into a two-month one. The code is rarely the problem. The problem is everything around it: store rules, card-data rules, strong authentication, and the dozen failure paths that only appear once real money is moving.

This guide walks through the decisions in the order you have to make them.

First: are you even allowed to use a card?

Before choosing a provider, check what you are selling. Apple and Google draw a hard line here, and getting it wrong means your app is rejected or removed.

What you sellHow you may charge
Digital content used inside the app — subscriptions, extra features, virtual itemsThe platform’s own in-app purchase system, in most cases
Physical goods — anything shippedAny payment provider you like
Services consumed outside the app — a taxi ride, a hotel night, a food deliveryAny payment provider you like
Person-to-person transfers, donations to a registered charityAny payment provider, with conditions

The rules around digital goods have been loosened in some regions after court rulings and regulation, and they keep moving. Read the current App Store and Google Play guidelines for the markets you ship to before you design the flow, not after. A commission of 15–30% on digital sales is a business model decision, not a technical detail.

The rest of this article is about the second case: real card payments for goods and services.

How a card payment actually works

Four parties are involved, and knowing which is which saves a lot of confusion when something fails.

  • Your app collects the intention to pay — it should never handle the card number itself if you can avoid it.
  • The payment gateway takes the card details securely and passes them on. This is Stripe, Adyen, Checkout.com and the rest.
  • The acquiring bank holds your merchant account and receives the money.
  • The issuing bank is the customer’s bank, which approves or declines.

A payment has two steps that teams often merge by mistake. Authorisation reserves the money and gives you an immediate yes or no. Capture actually takes it, and can happen later — when the order ships, for example. Deciding whether you capture immediately or later is a business question with real consequences for refunds and accounting.

Hosted page, SDK, or your own form

This single choice decides most of your compliance work.

Hosted page or provider SDKYour own card form
Card number touches your systemsNoYes
PCI DSS burdenMinimal — a short self-assessmentHeavy — audits, scanning, network controls
Control over the lookLimited to styling optionsComplete
Build timeDaysWeeks, plus ongoing compliance cost
Who to use itAlmost everyoneLarge merchants with a compliance team

Use the provider’s SDK. The card details go from the customer’s device straight to the provider, and your server receives only a token — a harmless string that represents the card. Your app never stores, logs or transmits a card number, which keeps you out of the expensive part of PCI DSS entirely.

Teams sometimes build their own form because the provider’s screen does not match the design. It is rarely worth it. Every modern provider offers an SDK you can style, and the difference in compliance cost is measured in tens of thousands.

Apple Pay and Google Pay

If you accept cards in a mobile app, add the wallets. They remove the worst part of mobile checkout — typing a card number on a phone — and they convert noticeably better. The customer confirms with a fingerprint or face scan and the payment is done.

Practically, the wallet hands your app an encrypted token which you pass to your gateway. Every major provider supports both, usually as a few extra lines on top of an SDK you are already using. The setup work is in the certificates and merchant identifiers, not the code.

One detail worth planning: a wallet gives you the billing address the customer has on file, which may differ from the one in your app. Decide which one wins before you discover the mismatch in production.

3-D Secure and strong customer authentication

In Europe and the UK, most online card payments must be authenticated — the customer confirms the payment in their banking app. This is strong customer authentication, delivered through 3-D Secure.

Three things to know when you build for it:

  • It interrupts your flow. The customer leaves your app, confirms in another app, and comes back. Your payment screen must survive being backgrounded and resumed. This is the most common source of bugs in mobile payment integrations.
  • Not every payment needs it. There are exemptions — low amounts, recurring charges, trusted merchants. Your provider applies them, but you need to handle both outcomes.
  • Authentication can fail on its own. The customer closes the banking app, the session times out, the phone rings. That is not a declined card, and your error message should not say it is.

Getting the result right

Here is the mistake that causes the worst incidents: treating the response your app receives as the truth.

The app can lose connection in the second between the payment succeeding and the confirmation arriving. The customer sees a failure, tries again, and pays twice.

The rule is simple: the payment status comes from your server, and your server learns it from the provider. Three habits make that work.

  1. Use webhooks as the source of truth. The provider calls your server when a payment settles, and your server updates the order — regardless of what the app saw.
  2. Make every handler idempotent. Webhooks can arrive twice and out of order. Record the event id you have processed and ignore repeats, or you will ship the same order two times.
  3. Reconcile on a schedule. A job that asks the provider about anything still pending after an hour catches the webhooks that never arrived. Every production payment system needs this, and most add it only after the first incident.

The same patterns apply to any integration you depend on — we wrote about them in more depth in our guide to third-party integrations.

What it costs

Providers advertise one number and bill several. The ones that matter:

  • Per transaction — a percentage plus a fixed fee, higher for cards issued outside your region.
  • Currency conversion — a margin on top of the exchange rate, easy to miss and significant if you sell internationally.
  • Chargebacks — a fixed fee per dispute, charged whether or not you win.
  • Payouts — some providers charge to move money to your bank, and the delay before they do affects your cash flow more than the fee.

Model the total against your expected volume and average basket before signing. A provider that is cheapest for €5 purchases is often not the cheapest for €500 ones.

How to test a payment flow

Payments are the one area where testing the happy path is close to worthless. Everyone’s checkout works when the card is good and the network is fine.

Use the provider’s test cards. Every gateway publishes card numbers that trigger specific outcomes: approved, declined, insufficient funds, expired, stolen, 3-D Secure required, 3-D Secure failed. Work through them all. Each one should produce a message a real customer can understand and act on.

Test the interruptions. This is where mobile payments differ from web, and where the bugs live:

  • The app is backgrounded during 3-D Secure and comes back a minute later.
  • The phone loses connection right after the pay button is pressed.
  • The customer presses pay twice quickly.
  • The app is killed by the system mid-payment and reopened.
  • A phone call arrives during the banking app confirmation.

In every one of those, the question is the same: does the customer end up charged exactly once, and does the app tell them the truth about it?

Test the money, not just the screen. After a successful payment, check that the order status, the provider’s dashboard and your accounting all agree. A test that stops at “confirmation message appeared” misses the whole second half of the system.

Automate the regression set. Mock the provider for everyday runs so your pipeline is fast and free, and keep a small suite that runs against the real sandbox nightly to catch changes on their side. This is standard practice in the suites we build — see test automation services.

A realistic timeline

StageTypical time
Choosing a provider and opening a merchant account1–4 weeks, mostly waiting on checks
SDK integration and a working sandbox payment3–5 days
Apple Pay and Google Pay2–4 days, mostly certificates
3-D Secure, error handling, edge cases1–2 weeks
Webhooks, idempotency, reconciliation1 week
Testing, including the interruption cases1 week

Four to six weeks of engineering, and the merchant account application often runs longer than the code. Start the paperwork first.

FAQ

Can we store card details to make repeat purchases easier?
Not yourself. Let the provider store the card and give you a token. Saved cards, one-click payments and subscriptions all work this way, and none of them require you to hold a card number.

Do we need PCI DSS certification?
Every merchant is in scope, but the level of work depends on your design. Using a provider SDK so that card data never reaches your systems usually reduces it to a short self-assessment questionnaire. Building your own form does not.

One provider or several?
Start with one. A second provider as a fallback makes sense at high volume or when you expand into a market your first one serves badly, but it doubles the reconciliation work.

How do we handle refunds?
Through the provider’s API, never by sending money back manually. Partial refunds, refunds after a currency change, and refunds of a payment that was authorised but not captured all behave differently — test all three.

What about subscriptions?
Use the provider’s recurring billing rather than charging a saved card on a schedule yourself. Retries, failed renewals, card expiry and dunning emails are solved problems, and rebuilding them is a common and expensive mistake.

Need a hand with payments?

We build and test payment flows for products where the money is real, including the parts that are invisible until they fail: idempotent webhook handling, reconciliation, 3-D Secure interruptions and refund logic.

Our fintech software development page covers the wider picture, and mobile testing covers how we verify it on real devices.

Previous articleSecurity Testing for Web Applications: What to Test and Who Should Do ItSecurity testing of a web application with vulnerability scanning and a protective shield

About The Blog

We estimate professional knowledge and expertise as the most valuable things a company should possess. Our blog is a platform for promoting and sharing those things to make the knowledge work for the goals and for the best purposes.

Recent Posts

How to Integrate a Payment Gateway in a Mobile AppNovember 27, 2026
Security Testing for Web Applications: What to Test and Who Should Do ItNovember 20, 2026
Third-Party Integrations: Types, Costs and What Actually BreaksNovember 13, 2026

Categories

  • fintech
  • Forecast
  • Insights
  • Lifestyle
  • ML
  • Mobile Development
  • News
  • QA
  • retail
  • softwaredevelopment
  • Test Automation
  • Web Development
  • WordPress

Location

Narva mnt 7-557
Estonia, Tallinn, 10117

Orzu MFY, 3 A-uy
Uzbekistan, Navoiy

+375293300656 GB
+375293300656 UZ
info@elmosoft.net
presale@elmosoft.net

Company

  • Blog
  • About Us
  • Contact
  • Careers

Trusted BY

Startups

Mature Business

Reviewed On


Don’t miss our updates

Loading
Copyright © 2016-2026 ElmoSoft LLC, All rights reserved.
Privacy Policy