Payment Implementation
Learn how to implement subscription payments in your a0 app using thea0-purchases
library.
The a0 payment system uses the
a0-purchases
library. All apps built with a0 come with the necessary configuration and providers built in.Prerequisites
Before implementing payments in your code, ensure you have:1
Completed Payment Setup
Created your features, plans, and offerings in the a0 dashboard. See the Payment Setup guide.
2
Synced to Providers
Synced your plans to Stripe and/or Apple App Store Connect.
3
Created Offerings
Created at least one offering and set it as current - this is required for paywalls to display products.
Building a Paywall
Here’s a simple paywall component using theuseA0Purchases
hook:
Your paywall will show no products if you haven’t created offerings. Offerings are REQUIRED for the paywall to work.
Checking Premium Status
The simplest way to gate content is using theisPremium
property:
Checking Specific Entitlements
isPremium
returns true if the user has ANY active entitlement. If you have multiple features/entitlements and need to check specific ones, use getCustomerInfo()
.Advanced Implementation
Custom Paywall with Package Details
Handling Purchase States
Testing Purchases
Test Credentials
Stripe Test Cards:- Success:
4242 4242 4242 4242
- Decline:
4000 0000 0000 0002
- More test cards in Stripe docs
- Use App Store Connect sandbox tester accounts
- Subscriptions auto-renew every few minutes for testing
- Clear purchase history in Settings → App Store → Sandbox Account
Testing Flow
1
Enable Test Mode
For Stripe, ensure you synced to the sandbox environment in your payment setup.
2
Test Purchase Flow
Make test purchases using the test credentials above.
3
Verify Entitlements
Check that
isPremium
updates correctly and specific entitlements are active.4
Test Restore
Clear app data and test the restore purchases functionality.
Troubleshooting
Paywall shows 'No products available'
Paywall shows 'No products available'
Cause: No offerings created or no current offering setSolution:
- Go to a0 dashboard → Payments → Offerings
- Create an offering with your subscription plans
- Set it as the current offering
Purchase fails immediately
Purchase fails immediately
Common causes:
- Not synced to payment provider
- Testing with production credentials
- Invalid product identifiers
isPremium not updating after purchase
isPremium not updating after purchase
Entitlements showing as undefined
Entitlements showing as undefined
Cause: Features not properly configured in a0 dashboardSolution:
- Verify feature names match exactly (case-sensitive)
- Ensure plans include the features you’re checking
- Sync plans to payment providers after changes