When to Use Integration Patterns
Use these patterns when you need to:- Combine multiple customization approaches: Integrate functional behavior with visual styling
- Handle complex payment flows: Manage subscriptions, one-time payments, and multiple payment methods
- Optimize for specific markets: Configure card networks and locales for different regions
- Implement enterprise-grade experiences: Build robust, scalable checkout implementations
Prerequisites
Before using these advanced patterns, ensure you have:- Basic PayNext SDK knowledge: Familiarity with Getting Started
- React/TypeScript experience: Understanding of React components and TypeScript interfaces
- PayNext dashboard access: Ability to configure payment methods and environments
- Understanding of basic customization: Knowledge of Behavior and Appearance customization
Functional Patterns
Payment method configuration, callback handling, and environment management.
Visual Patterns
Advanced styling approaches using CSS-in-JS and utility classes.
The examples below show configuration fragments. Instantiate with
new PayNextCheckout() and pass the element ID as the first parameter and the combined config object as the second parameter into checkout.mount('element-id', { ...config }) as in Mount the Checkout, adding the illustrated properties before calling mount.Quick Start
Here’s a minimal example combining functional and visual customization:quick-start.tsx
Basic Implementation Patterns
- Transaction Type Handling
- Callback Configuration for Analytics
advanced/transactions.tsx
Visual Patterns
- CSS-in-JS Theming
- Utility Class Implementation
advanced/theme.tsx
The submit icon automatically hides while the spinner is shown during a payment attempt, then reappears once processing finishes.
Advanced Patterns
Complete Configuration Example
Comprehensive example combining multiple customization layers:advanced/comprehensive.tsx
Best Practices
Configuration Management
Keep configuration objects immutable to prevent unnecessary re-renders:- Define configuration objects outside component scope when possible
- Use useMemo for dynamic configurations
- Separate styling from functional configuration
- Test configurations across different environments
Error Handling
Implement comprehensive error handling:- Provide user-friendly error messages
- Log detailed errors for debugging
- Handle different error types appropriately
- Test error scenarios thoroughly
Performance Considerations
Optimize checkout performance:- Minimize runtime style calculations
- Use CSS classes over CSS-in-JS for static styles
- Cache configuration objects
- Test on various devices and connection speeds
Testing Approach
Validate integration patterns:- Test all payment methods in the sandbox
- Verify styling across browsers and devices
- Test error scenarios and edge cases
- Validate callback integrations
Common Pitfalls
Avoid these integration mistakes:- Configuration conflicts between different customization layers
- Missing error handling for payment failures
- Performance issues from unstable configuration objects
- Inconsistent styling across different states
- Browser compatibility issues with advanced features
Start with minimal customization and add complexity incrementally. Test each customization layer thoroughly before combining multiple patterns.