Stripe Payments
Stripe lets you accept payments in your iOS app. Process one-time purchases, set up subscriptions, and manage customers.What You Can Build
- One-time Payments — Single purchases
- Subscriptions — Recurring billing
- In-App Purchases — Digital content
- Marketplace — Split payments
Prerequisites
- Stripe account (free to create)
- Apple Developer account (for real device testing)
- Understanding of your pricing model
Important Considerations
Apple’s Rules
For digital goods and services (like app features or subscriptions), Apple requires you to use In-App Purchases, not Stripe directly. Use Stripe for:- Physical goods
- Services delivered outside the app
- Business-to-business transactions
- Premium app features
- Digital subscriptions
- Virtual currency/items
PCI Compliance
Stripe handles credit card data, so you stay PCI compliant. Never store card numbers in your app.Setting Up Stripe
Create Stripe account
Go to stripe.com and sign up
Get API keys
Dashboard → Developers → API keys
- Use Test mode keys during development
- Switch to Live mode keys for production
Test vs Live Mode
Test Mode
- Use
pk_test_andsk_test_keys - Use test card numbers
- No real money processed
- Perfect for development
Test Card Numbers
| Card | Number | Use |
|---|---|---|
| Successful | 4242 4242 4242 4242 | Normal success |
| Declined | 4000 0000 0000 0002 | Test decline |
| Requires auth | 4000 0025 0000 3155 | Test 3D Secure |
Live Mode
- Use
pk_live_andsk_live_keys - Real money processed
- Only after thorough testing
Basic Payment Flow
Collect Payment
Using Stripe Payment Sheet
The easiest integration uses Stripe’s pre-built UI:Implementation Approaches
Client-Side Only (Simple)
For simple use cases:- Create PaymentIntent on Stripe dashboard
- Confirm payment from app
Client + Server (Recommended)
More secure and flexible:- Your server creates PaymentIntent
- App receives client secret
- App confirms payment
- Server receives webhook confirmation
Server-side component typically requires additional development beyond Nativeline. Consider services like Firebase Functions or Supabase Edge Functions.
Common Scenarios
Single Purchase
Subscription
Tipping / Variable Amount
Apple Pay
Stripe supports Apple Pay for faster checkout:- Apple Developer account
- Merchant ID configured in Stripe
- Device with Apple Pay capability
Webhooks
For reliable payment confirmation, use webhooks:- Stripe sends event to your server
- Server updates your database
- App reflects the change
Security Best Practices
Never log or store card numbers
Never log or store card numbers
Stripe handles all card data. Your app never sees the actual card number.
Verify payments server-side
Verify payments server-side
Don’t trust client-side confirmations alone. Use webhooks to verify.
Use test mode during development
Use test mode during development
Always develop with test keys. Only switch to live for production.
Validate amounts server-side
Validate amounts server-side
Users can modify client code. Always verify amounts on your server.
Error Handling
Common Errors
| Error | User Message |
|---|---|
| Card declined | ”Your card was declined. Please try another card.” |
| Insufficient funds | ”Insufficient funds. Please try another card.” |
| Expired card | ”Your card has expired. Please update your card.” |
| Network error | ”Connection error. Please try again.” |
Handling in App
Refunds
Process refunds from Stripe Dashboard:- Payments → Find payment
- Click “Refund”
- Full or partial refund
Testing Checklist
Before going live:- Successful payment completes
- Declined card shows error
- Network failure handled
- Loading states shown
- Confirmation displayed
- Purchase recorded in database
- Refund process works
- Subscription renewal works
- Cancellation handled