In my Flutter service apps, a customer could pay for a job and a technician could receive a transfer after the work. The payment sheet was one part of that flow. The backend also had to keep the payment, order, and recipient account in agreement when requests were delayed or interrupted.
I implemented PaymentIntents, customer credentials, connected-account transfers, and backend scheduling with Firebase Functions and Firestore. For an extension of this integration, I would focus on recovery across payment, order, and transfer states.
The server decides what is being paid
The client can identify an order and request checkout. The server should authenticate the user, verify ownership, determine the payable amount from trusted records, and select the currency. Accepting an arbitrary client-supplied amount would let a modified app redefine the transaction.
A PaymentIntent tracks a payment lifecycle. Stripe recommends creating one for each order or customer session and reusing it where appropriate; its integration guide explains that relationship.
Here is an illustrative server operation, after validation and order lookup:
const intent = await stripe.paymentIntents.create(
{
amount: order.amountMinorUnits,
currency: order.currency,
customer: customer.stripeId,
metadata: { orderId: order.id },
},
{ idempotencyKey: `order:${order.id}:payment:${order.paymentVersion}` }
);
Persist the relationship between the order and PaymentIntent, and handle price or order revisions deliberately. Reusing that relationship keeps repeated checkout attempts traceable.
Separate SDK access from authority
The mobile app receives the limited information required to present the payment interface. In customer-based integrations, a short-lived customer credential can grant SDK access to customer resources. The backend retains authority over the amount, order relationship, and financial updates.
Stripe’s secret API key stays on the server. Payment client secrets and customer credentials should also be handled as sensitive values, with access scoped to the authenticated transaction and no routine logging.
The exact mobile SDK configuration depends on the integration and version; follow the supported SDK path for the deployed client.
Reconcile payment state on the server
A client callback is useful for the immediate interface, but server-side reconciliation determines the authoritative order payment state. The user may close the app, lose connectivity, or complete a payment that requires asynchronous processing.
Stripe’s webhook guidance covers signature verification, duplicate events, and delivery behavior. I would verify the signature against the raw request body before accepting the event, store a durable receipt, and make subsequent business updates idempotent.
Handle events that arrive out of order. If an update is ambiguous or stale, retrieve the current payment state before deciding the next business transition.
Connect introduces another lifecycle
A technician connected account can have incomplete onboarding or unavailable capabilities. Check the account’s current status and required capabilities after the onboarding return.
A transfer moves funds from the platform to the connected Stripe account. A payout moves available funds to an external account such as a bank account. The distinction matters for status text, support investigation, and scheduling. Stripe documents those boundaries; delaying funds should not be described as Stripe escrow.
A delayed transfer job needs ownership, retry rules, a stable idempotency key, and reconciliation when the process stops after the API succeeds. A refund may require a separate transfer reversal decision, depending on the charge model. Record and reconcile each fund movement explicitly.
Test the uncertain moments
Beyond a successful card payment, I would check a declined method, authentication interruption, duplicate checkout requests, a delayed webhook, an incomplete connected account, insufficient available balance, and a partial refund.
The UI should explain whether payment is processing, failed, or confirmed, and check the existing attempt before inviting the user to pay again.
The cases I find most revealing are the uncertain ones: the server succeeded but the client timed out, a webhook arrived twice, or a transfer stopped midway through reconciliation. Testing those transitions is how I would establish confidence in the order history.