To integrate the Stripe payment gateway in Android, treat the app as the least trusted part. The server creates the PaymentIntent and hands the app a client secret, and the app shows Stripe's PaymentSheet. When the sheet says Completed, the app can show a thank-you screen, but the order is paid only when the server receives the payment_intent.succeeded event.
Fintech founders and mobile product leads will find who does what, the order record, webhook handling, key storage and pre-launch tests.
How do you integrate the Stripe payment gateway in an Android app?
To integrate Stripe in an Android app, your server creates a PaymentIntent and returns its client secret, the app presents PaymentSheet with it, and your server fulfills the order from Stripe's webhook. Agnotic Technologies keeps secret keys on the server and never marks an order paid from the app's result alone.
Adding payments to an Android app?
We build the server endpoint, the PaymentSheet flow and the webhook that marks orders paid.
Stripe's Android guide says that for security reasons the app cannot create the PaymentIntent. A server endpoint creates it and returns its client secret, which the app passes to PaymentSheet.presentWithPaymentIntent.
| Part | Does | Must not |
|---|---|---|
| Server endpoint | Creates the PaymentIntent with amount, currency and order id | Trust an amount sent by the app |
| Android app | Presents PaymentSheet with the client secret | Hold a secret key or create PaymentIntents |
| PaymentSheet result | Tells the app to show success, failure or cancel | Mark the order paid |
| Webhook handler | Verifies the signature, marks the order paid on payment_intent.succeeded | Fulfill twice when an event is retried |
Why is the app's success screen not a confirmed payment?
The app's success screen is not a confirmed payment because the app can be closed, offline or tampered with, and some payment methods finish later. The server's webhook is the record Agnotic uses to fulfill.
Stripe sends a payment_intent.succeeded event when the payment completes and recommends using it to fulfill the order. For delayed payment methods, the final status is not known when PaymentSheet completes.
- Fulfill on payment_intent.succeeded. Tell the customer the order is pending on payment_intent.processing.
- Make fulfillment safe to repeat: check whether the order is already paid before acting.
- Reply to the webhook quickly, then do slow work in a background job.
What else should the server get right?
The server should prevent duplicate PaymentIntents and protect the client secret. Both are in Stripe's own guidance.
Stripe recommends an idempotency key when creating a PaymentIntent, to prevent duplicate PaymentIntents for the same purchase, and says not to log the client secret or embed it in URLs.
- Use the cart or order id as the idempotency key when creating the PaymentIntent.
- Reuse the same PaymentIntent if checkout is interrupted and resumed.
- Put the order id in metadata, not card or personal details.
What should the order record hold before checkout starts?
Before checkout starts, the order record should hold the amount and currency your server calculated, a status of pending and the idempotency key you will use with Stripe. The PaymentIntent id is added once Stripe returns it, so every later event can be matched to one order.
| Field | Set by | When |
|---|---|---|
| Order id | Your server | When the cart is turned into an order |
| Amount and currency | Your server, from its own prices | Before the PaymentIntent is created |
| Idempotency key | Your server, from the order id | On the create call to Stripe |
| PaymentIntent id | Stripe, stored by your server | In the create response |
| Status | Your webhook handler | Pending, then processing, paid or failed as events arrive |
Keep the status field owned by the webhook handler. If other code paths can set it to paid, the rule that only the server's event confirms payment is lost.
How does a payment move from the app to a paid order?
A payment moves from the app to a paid order in four hops: the app asks your server to start checkout, the server creates the PaymentIntent, the app presents PaymentSheet, and Stripe tells your webhook the result. Only that last hop changes the order to paid.
- Step 1, the app sends the order id to your checkout endpoint, never an amount.
- Step 2, the server creates the PaymentIntent with the idempotency key and returns the client secret.
- Step 3, the app presents PaymentSheet with the client secret and the publishable key, and the customer pays.
- Step 4, Stripe sends payment_intent.succeeded to your webhook, which verifies the signature and marks the order paid.
How should the webhook handler verify and process events?
The webhook handler should verify each event's signature with the endpoint's signing secret, reply with a success status quickly and hand the order update to a background job. Anything that fails verification is rejected and logged.
Stripe signs every webhook event in the Stripe-Signature header and needs the raw request body to verify it. Its docs warn that without verification, an attacker could send fake events to trigger actions such as fulfilling orders.
- Read the raw body before any framework parses it, or verification will fail.
- Use Stripe's official library to verify, rather than writing the check by hand.
- Keep a separate signing secret for test and live endpoints, stored with the server's other secrets.
- Act only on event types you handle, and ignore the rest without error.
What happens when webhook events arrive twice or out of order?
When events arrive twice or out of order, the handler should still end with the right order status, because it records which event ids it has processed and only moves the status forward. A late processing event must never undo a paid order.
| Current status | Event received | Result |
|---|---|---|
| Pending | payment_intent.processing | Processing, and the customer is told payment is pending |
| Pending or processing | payment_intent.succeeded | Paid, and fulfillment starts once |
| Pending or processing | payment_intent.payment_failed | Failed, and the customer can try again |
| Paid | Any earlier event, or the same event again | No change |
How should the app respond to each PaymentSheet result?
The app should treat each PaymentSheet result as a hint for the screen and then ask your server for the order's real status. Completed shows a thank-you or pending screen, Canceled returns to the cart, and Failed shows the error and lets the customer retry.
| Result | What the app shows | What the app asks the server |
|---|---|---|
| Completed | Thank you, or payment pending if the server has no paid event yet | Current order status |
| Canceled | Back to the cart with items kept | Nothing; the same PaymentIntent is reused next time |
| Failed | The error message and a retry button | Nothing until the customer retries |
What if the customer closes the app in the middle of paying?
If the customer closes the app mid-payment, the payment may still finish, and the webhook will still mark the order paid. When the app opens again, it reads the order status from your server instead of guessing from local state.
- Store only the order id on the device, not the client secret.
- On launch, ask the server for any order still pending and show its status.
- If the customer starts checkout again, return the existing PaymentIntent for that order rather than creating a second one.
Which keys belong in the app and which stay on the server?
Only the publishable key belongs in the Android app; the secret key and the webhook signing secret stay on the server. Anything compiled into an app package can be extracted, so the app should hold nothing that can move money.
| Credential | Lives in | Used for |
|---|---|---|
| Publishable key | The Android app | Initializing the SDK and presenting PaymentSheet |
| Secret key | Server secrets store | Creating PaymentIntents and reading their status |
| Webhook signing secret | Server secrets store | Verifying that events came from Stripe |
| Client secret | Passed from server to app per checkout | Presenting one PaymentIntent, then discarded |
How do you test a Stripe Android integration before going live?
Test a Stripe Android integration in Stripe's test mode with test cards, a webhook endpoint that receives test events, and release builds on real devices. The cases that matter most are the ones where the app and the server disagree.
- Pay successfully and confirm the order is paid only after the webhook arrives.
- Cancel the sheet, then pay again, and confirm one PaymentIntent exists for the order.
- Close the app during payment and confirm the order still ends up paid.
- Resend the same event and confirm fulfillment does not run twice.
- Send an event with a bad signature and confirm it is rejected.
What the server should log, and what it must never log
The server should log the order id, the PaymentIntent id, each event id and type and every status change. It must never log the client secret, which Stripe's guidance warns against, and it should keep the secret key and card details out of logs too.
Those logs answer the common support question, which is whether a customer who saw a success screen was charged. Search by order id and the event history shows the answer.
Who owns each part of a Stripe Android checkout?
A Stripe Android checkout spans the mobile app, the backend and the people who handle money and support, and each part needs a named owner. Most payment bugs sit at the boundary between two of them.
- Mobile team: PaymentSheet setup, result handling and the screen that reads order status from the server.
- Backend team: the checkout endpoint, the webhook handler, idempotency and the order status rules.
- Finance or operations: refunds, disputes and matching paid orders against Stripe payouts.
- Support: the order and event history view used to answer whether a customer was charged.
What are the common mistakes when you integrate Stripe in Android?
The common mistakes when you integrate Stripe in Android all give the app a decision that belongs to the server.
- Sending the amount from the app and trusting it on the server.
- Marking the order paid as soon as PaymentSheet returns Completed.
- Parsing the webhook body before verifying the signature, so verification fails and someone switches it off.
- Creating a new PaymentIntent every time the customer reopens checkout for the same order.
- Putting the secret key in the app for a quick test and shipping it by accident.
What does a Stripe Android integration mean for your build plan?
A Stripe Android integration is mostly server work. Once the checkout endpoint and the webhook handler exist, the app side is small, so plan the backend first and the app screens second.
- Step 1, define the order record and its status rules, including the one code path allowed to set an order to paid.
- Step 2, build the checkout endpoint and the webhook handler, and exercise both in Stripe's test mode.
- Step 3, add PaymentSheet to the app, plus the screen that reads order status from the server.
- Step 4, run the failure cases on release builds and agree the support view before launch.
How does Agnotic build Stripe checkout for an Android app?
Agnotic builds Stripe checkout for Android by writing the server endpoint that creates PaymentIntents, the PaymentSheet flow in the app and the webhook handler that alone marks orders paid. Keys and secrets stay on the server from the first build.
We test the failure cases listed above on release builds before launch, and hand over the logs and status rules your support team needs.
Server creates, webhook confirms
The app shows the sheet. The server decides the order is paid.
Related reading on Agnotic
Payment gateway integration, Stripe Connect payouts, NFC tap-to-pay and more industry build notes.

