Skip to main content

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
These examples demonstrate how to effectively combine the PayNext SDK configuration options to create sophisticated checkout form experiences.

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
This example combines basic functional configuration (environment, callbacks) with simple visual styling. Use this as a foundation for more complex patterns.
onCheckoutComplete runs on the client when the checkout flow finishes — use it for redirects and analytics, not to fulfill orders. It is not guaranteed to run: a closed or backgrounded tab or a lost connection can prevent it, on any payment method (seen on PayPal and Apple Pay). Trigger fulfillment from payment webhooks, the source of truth for the final payment status (asynchronous methods such as Pix also settle after this callback fires).

Basic Implementation Patterns

advanced/transactions.tsx
Branch on result.subscription to reuse the same checkout for both flows.

Visual Patterns

advanced/theme.tsx
Prefer transforms (scale, translate) for smooth animations.
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.