Prompt
How do I build a payment flow that works on mobile and desktop?
Latest observation
To build a payment flow that works well on both mobile and desktop, design it as a responsive, low-friction, secure checkout experience with payment method flexibility and clear handoff to the payment provider.
1) Start with the payment architecture
Use a payment provider like Stripe, Adyen, Braintree, PayPal, or Square instead of handling card data yourself.
Typical flow:
- User adds items to cart
- User enters checkout
- Your backend creates a payment session/order
- Frontend renders a responsive payment UI
- Payment provider handles card entry / wallets / authentication
- Your backend confirms payment via webhook
- Show success/failure state
2) Build one responsive checkout UI
Make the checkout page adapt to screen size rather than building separate mobile and desktop flows.
Good practices:
- Use a single-column layout on mobile
- Use a two-column layout on desktop if helpful
- Keep forms short and auto-fill friendly
- Use large tap targets and readable labels
- Avoid modals that are hard to use on small screens
- Preserve state if the user rotates the device or refreshes
Example layout:
- Mobile: cart summary collapsible, payment form below, sticky pay button
- Desktop: order summary left, payment form right
3) Support multiple payment methods
Different devices and regions prefer different methods.
Include:
- Credit/debit cards
- Apple Pay / Google Pay
- PayPal or local wallets if relevant
- Saved payment methods for returning users
Wallets are especially important on mobile because they reduce typing.
4) Use provider-hosted or secure payment elements
Don’t collect raw card details yourself unless you absolutely need to.
Safer options:
- Hosted checkout page: fastest to implement
- Embedded payment elements: more control, still PCI-friendly
- Tokenization: provider returns a token; your server charges that token
This helps with:
- PCI compliance
- 3D Secure / SCA authentication
- Cross-device compatibility
5) Handle authentication and redirects properly
Payments may require extra steps like 3D Secure.
Your flow should:
- Support redirect-based authentication
- Return users to the correct success/failure page
- Store order state server-side so a refresh doesn’t lose progress
Important:
- Use webhooks to confirm final payment status
- Don’t rely only on the client-side “success” event
6) Optimize for mobile behavior
Mobile users are more likely to abandon if the process is slow or awkward.
Tips:
- Enable browser autofill
- Use numeric keyboards for card fields
- Keep input fields minimal
- Validate inline with clear error messages
- Make buttons full-width on mobile
- Avoid excessive scrolling
- Support digital wallets prominently
7) Make desktop efficient too
Desktop users often expect more context.
Tips:
- Show order totals, taxes, shipping, and discounts clearly
- Let users edit cart details without leaving checkout
- Keep payment CTA visible
- Use concise but informative copy
8) Make the backend resilient
A solid payment flow depends on server-side state.
Backend should:
- Create payment intents/orders
- Store cart and checkout session state
- Verify prices server-side
- Handle webhook events:
- payment succeeded
- payment failed
- payment pending
- refunded / disputed
Never trust the amount from the client.
9) Test across devices and scenarios
Test:
- iPhone Safari
- Android Chrome
- Desktop Chrome, Safari, Firefox, Edge
- Wallet payments
- Redirect/auth flows
- Poor network conditions
- Cancel/retry behavior
- Different screen sizes and orientations
10) A simple recommended implementation pattern
If you want the simplest reliable setup:
- Use Stripe Checkout if you want fast implementation
- Use Stripe Elements or equivalent if you want custom branding
- Backend creates a checkout session/payment intent
- Frontend redirects or renders embedded payment UI
- Webhook confirms the order
- Success page reads order status from your backend
Example user flow
- User clicks “Checkout”
- App loads a responsive checkout page
- User enters shipping/billing info
- User chooses card or wallet
- Payment provider processes payment
- If authentication is needed, user completes it
- Backend webhook confirms the payment
- User sees order confirmation
Checklist
- Responsive layout
- Mobile-friendly inputs
- Wallet support
- Secure payment provider integration
- Backend payment verification
- Webhooks
- Error handling and retries
- Cross-device testing
If you want, I can also give you:
- a reference architecture diagram,
- a Stripe-based implementation example, or
- a mobile-first checkout UX checklist.