Overview
Openfront supports multiple payment providers through a flexible adapter system. You can integrate Stripe, PayPal, manual payment methods (like Cash on Delivery), or build custom payment adapters.Payment Adapter Interface
All payment providers in Openfront implement a standard adapter interface with these core functions:createPaymentFunction- Initialize a payment intent or ordercapturePaymentFunction- Capture an authorized paymentrefundPaymentFunction- Process refundsgetPaymentStatusFunction- Check payment statusgeneratePaymentLinkFunction- Generate payment dashboard linkshandleWebhookFunction- Verify and process webhook events
features/integrations/payment/index.ts:
features/integrations/payment/index.ts
Stripe Configuration
Environment Variables
Add these variables to your.env file:
.env
Implementation Details
The Stripe adapter (features/integrations/payment/stripe.ts) uses the official Stripe SDK:
Webhook Verification
Stripe webhooks are verified using signature validation:features/integrations/payment/stripe.ts
PayPal Configuration
Environment Variables
.env
Implementation Details
The PayPal adapter (features/integrations/payment/paypal.ts) handles currency formatting, including zero-decimal currencies:
Currency Handling
PayPal supports zero-decimal currencies (JPY, KRW, etc.) which require special formatting:features/integrations/payment/paypal.ts
Manual Payment Provider
The manual payment provider is used for Cash on Delivery, bank transfers, and other offline payment methods:features/integrations/payment/manual.ts
Building Custom Payment Adapters
To create a custom payment provider:- Create a new file in
features/integrations/payment/ - Implement all required adapter functions
- Register your adapter in the
paymentProviderAdaptersobject
Example Custom Adapter
features/integrations/payment/custom.ts
Register Custom Adapter
features/integrations/payment/index.ts
Using Payment Providers in Your Application
Payment providers are managed through the KeystoneJS admin panel. ThePaymentProvider model stores configuration:
Best Practices
Security
Security
- Store API keys in environment variables, never in code
- Always verify webhook signatures
- Use HTTPS for all payment communications
- Implement rate limiting on webhook endpoints
Error Handling
Error Handling
- Implement proper error handling for network failures
- Log payment errors for debugging
- Provide clear error messages to users
- Implement retry logic for transient failures
Testing
Testing
- Use sandbox/test modes during development
- Test with various currencies and amounts
- Verify webhook delivery and retry logic
- Test payment capture and refund flows
Multi-Currency Support
Multi-Currency Support
- Handle zero-decimal currencies correctly
- Convert amounts to smallest currency unit (cents)
- Store currency codes with transactions
- Test currency conversion edge cases
Related Resources
- Webhooks - Learn about webhook configuration and events
- Shipping Providers - Configure shipping integrations
- API Reference - Full API documentation