Custom API Integration
Build your own checkout experience with complete control using Gale’s APIs. Perfect for mobile apps, custom platforms, and merchants who need full flexibility.When to Use Custom API
Perfect for you if:
- You’re building a mobile app (iOS, Android, React Native)
- You need complete UI control over checkout
- You want to manage subscriptions externally
- You require advanced features (batch operations, custom flows)
- You have development resources for custom implementation
Architecture Overview
The custom API integration follows this flow:- Create Products - Sync your products with Gale’s Product API
- Check Eligibility - Verify HSA/FSA eligibility via Eligibility API
- Create Checkout - Create checkout session via Checkout API
- Redirect/Open - Send customer to Gale’s hosted checkout page
- Process Payment - Gale processes payment securely
- Webhook - Receive webhook notification when payment completes
- Fulfill Order - Your backend fulfills the order
Implementation Guide
Step 1: Product Management
Sync your products with Gale and verify HSA/FSA eligibility:Step 2: Check Eligibility (Optional)
Verify eligibility before adding to cart:Step 3: Create Checkout Session
When customer checks out, create a checkout session:Step 4: Handle Checkout
Option A: Use Gale’s Hosted Checkout (Recommended) Redirect tocheckout_url for payment. Customer completes payment on Gale’s secure page.
Option B: Embedded Checkout (Alternative)
For a more seamless experience, embed the checkout in a webview or iframe within your app. See Embedded Checkout Guide.
Step 5: Handle Payment Confirmation
Use webhooks to receive real-time payment confirmation (recommended) or poll the Order API if needed:Step 6: Handle Webhooks
Configure webhook endpoint to receive real-time updates:Subscription Support
Gale handles subscriptions for you. When creating a checkout session, pass subscription parameters:- Collect payment method
- Charge customer monthly
- Send webhooks for each payment
- Handle failed payments and retries
Batch Operations
Batch Eligibility Check
Check multiple products at once:Advanced Features
Idempotency
Prevent duplicate operations using idempotency keys:Rate Limiting
See Rate Limits for handling rate limits.Best Practices
Secure API Keys
Never hardcode API keys in mobile apps. Proxy through your backend.
Handle Errors
Implement proper error handling for all API calls
Use Webhooks
Don’t rely solely on polling - use webhooks for reliability
Cache Eligibility
Cache product eligibility to reduce API calls
Error Handling
Testing
Test Environment
Always use test keys during development:Test Scenarios
- Successful payment: Use test card
4111111111111111 - Card declined: Use test card
4000000000000002 - Expired session: Create checkout and wait 24+ hours
- Mixed eligibility: Create checkout with eligible and non-eligible products
API Reference
Complete API documentation:Next Steps
Webhook Guide
Set up webhook endpoints
Core Objects
Understand data structures
Test Cards
Test payment scenarios
Error Codes
Handle errors properly
Support
Building a custom integration?- 📧 Email: support@withgale.com
- 📚 Full API Reference
- 💬 Contact Support
