When and Why to Configure Behavior
Configure checkout form behavior to optimize for your specific business requirements and user demographics. Strategic configuration helps reduce payment failures while improving user experience.Card Network Filtering
Optimize payment acceptance by controlling which card brands to support. Reduce processing fees and improve conversion rates by accepting only the most relevant cards for your target markets and business agreements.
Payment Method Priority
Payment method ordering and priority are automatically managed through the PayNext Dashboard. The SDK automatically optimizes for user context and device capabilities.
Callback Integration
Build robust payment workflows with comprehensive event handling. Implement custom business logic, analytics tracking, and user experience flows that respond to payment success, failures, and different payment methods.
Environment Management
Ensure reliable deployments across all environments with proper configuration management. Set up environment-specific validation, error handling, and testing strategies that prevent production issues and maintain security.
Configure via PayNextConfig
Configure checkout form behavior through the PayNextConfig interface:
Create the instance with
new PayNextCheckout() and pass the element ID as the first parameter and your assembled PayNextConfig as the second parameter into checkout.mount('element-id', { ...config }) as demonstrated in Mount the Checkout. Apply the configuration fragments below before calling mount.Supported Card Networks
Visa
CardType.Visa
Mastercard
CardType.Mastercard
JCB
CardType.JCB
Discover
CardType.Discover
American Express
CardType.AmericanExpress — Apple Pay / Google Pay only, not accepted on the card form
Restrict Card Networks per Payment Method
Available in SDK1.2.0 and later. Pass acceptedCardNetworks at mount to control which card networks each payment method accepts. This is useful when your business agreements or per-customer rules differ from your global dashboard configuration.
- A non-empty list overrides the dashboard configuration for that method — it can both narrow and widen the accepted set, bounded to what the method technically supports. Networks the method doesn’t support are dropped (for example,
CardType.AmericanExpresson theCARDmethod). - An empty array
[], a missing key, or a list of only unsupported networks falls back to the dashboard default. A method is never left with zero networks, and its button is never hidden. - Keys other than
CARD,APPLEPAY, andGPAYare ignored.
acceptedCardNetworks is read once when the checkout mounts. It is not part of the runtime checkout.update(...) surface — change it by re-mounting with a new configuration.Advanced Patterns
Gate Payments Behind a Consent Checkbox
UsepaymentsEnabled when payment must be blocked until an external condition is met — for example, the customer ticking a terms or consent checkbox that lives in your UI, outside the SDK.
While paymentsEnabled is false:
- Tapping any payment button (Google Pay, PayPal, Apple Pay, etc.) does not start a payment and does not open the provider’s sheet or popup.
- The card and Pix forms can still expand, but submitting them is blocked.
- Every blocked interaction fires
onCheckoutBlockedwith{ paymentMethod, cardType }, so you know which button was tapped and can react (e.g. highlight your checkbox). - Buttons render identically — there is no visual disabled state.
true, so omitting it keeps the normal payment flow. Toggle it at runtime with checkout.setPaymentsEnabled(enabled) — no re-mount required.
paymentsEnabled controls whether a payment can be initiated; beforeCheckoutAttempt runs a last-mile async check at the moment of an attempt and can reject it. Use paymentsEnabled for a standing on/off gate tied to your own UI state, and beforeCheckoutAttempt for per-attempt validation.Update Configuration at Runtime
checkout.update(config) is available in SDK 1.1.0 and later. Upgrade @paynext/sdk if your project pins an earlier version.checkout.update(config) to change selected config fields without re-mounting. Only what changed re-renders, and form state (entered card data, open forms) is preserved — so switching language or theme no longer needs an unmount() + mount() cycle.
Fields you can update at runtime:
clientToken, environment, and apiVersion cannot be updated at runtime — they initialize the API client, so changing them requires a fresh mount. TypeScript rejects them in update(); passing them from plain JavaScript logs a console warning and is ignored (it never throws). variant, styles, and the callback handlers are likewise fixed at mount.Digital Wallet Configuration
Digital wallet availability (Apple Pay, Google Pay, PayPal, Venmo, Cash App Pay) depends on both your dashboard configuration and the user’s device/browser capabilities.All digital wallet configurations (merchant names, supported networks, authentication settings) are managed in your PayNext dashboard. No code changes are required when enabling or disabling payment methods.
Payment Method Priority
Set priority directly in the PayNext Dashboard (Checkout → Payment methods). Drag to reorder wallets, toggle them on/off, and add conditions for card visibility. The SDK reads this configuration on every load—no code changes or redeploys required.
- The dashboard order becomes the exact order shown in the SDK (top to bottom).
- If you never customized the list, PayNext falls back to its default order: digital wallets → PayPal → cards.
- When a method is disabled or hidden by conditions, the SDK closes the gap and keeps the remaining order intact.
- Shows payment methods available to the customer’s device/browser (e.g., hides Apple Pay on Windows)
- Applies your dashboard ordering after filtering out unsupported methods
- Respects your conditions per processor/country/currency
- Automatically hides methods when a processor disconnects or the customer’s device can’t use it.
Understanding Payment Method Availability
The SDK determines payment method availability using multiple factors:Device Capabilities
Device Capabilities
- Apple Pay: Safari on iOS/macOS with Apple Pay configured
- Google Pay: Chrome/Chromium browsers with Google Pay enabled
- PayPal: Shown when enabled in your dashboard
- Venmo: Shown for US users on desktop browsers (via QR code) and mobile browsers (via deep link or web fallback)
- Cash App Pay: Available when Stripe + Cash App Pay are enabled and the customer is in a supported region/device context
- Amazon Pay: Available when Stripe + Amazon Pay are enabled and the customer is in a supported region/device context
Geographic Optimization
Geographic Optimization
- North America: Prioritizes Apple Pay, Google Pay, PayPal, Venmo
- Europe: Emphasizes Apple Pay, Google Pay, PayPal, SEPA
- Asia: Focuses on local payment methods and digital wallets
- Global: Falls back to major card networks (Visa, Mastercard)
User Behavior Patterns
User Behavior Patterns
- Returning users: May see previously used payment methods first
- Mobile users: Digital wallets prioritized over card forms
- Desktop users: Traditional card forms are more prominent
- High-value transactions: May show premium payment options first
Layout Variants
Control how payment methods are initially presented:- Default Layout
- Compact Layout
Refer to Mount the Checkout for the complete mounting flow.
- Desktop-focused experiences
- Users are comfortable with traditional forms
- When screen space is abundant
- Clear overview of all payment options needed
Success States and Decline Messages
The SDK automatically handles success states and localized decline fallback messaging across all devices and browsers. Success States The SDK automatically displays success confirmations when payments are completed successfully. No additional configuration is required.The on-screen success confirmation reflects that the checkout flow finished — it is a UX signal, not a guarantee that funds have settled. It also renders in the customer’s browser, so it isn’t guaranteed to be seen: a closed or backgrounded tab or a lost connection can prevent it, on any payment method. Fulfill orders from payment webhooks, the source of truth for the final payment status. For asynchronous methods such as Pix the payment can also still be settling when the confirmation appears.
Best Practices
Environment Configuration
Configure different behavior per environment:environment-detection.ts
Form Validation and Error Handling
The SDK provides real-time validation for all payment fields:Card Number Validation
Card Number Validation
- Format validation: Checks card number format in real-time
- Card type detection: Automatically detects Visa, Mastercard, etc.
- Luhn algorithm: Validates card number using industry standard
- Length verification: Ensures correct number of digits
Expiry Date Validation
Expiry Date Validation
- Format checking: MM/YY format validation
- Date logic: Validates month (01-12) and future dates
- Expiry detection: Prevents expired card acceptance
- Input formatting: Auto-formats as user types
Security Code (CVC) Validation
Security Code (CVC) Validation
- Length validation: 3 digits for most cards, 4 for Amex
- Numeric verification: Ensures only numbers are entered
- Real-time feedback: Immediate validation as user types
- Card-specific rules: Adapts based on detected card type
Common Pitfalls
Avoid these behavior configuration mistakes:- Overly restrictive card filtering that excludes common payment methods
- Missing error handling for network or payment failures
- Exposing sensitive data in client-side error messages
- Not testing across environments before production deployment
- Ignoring mobile-specific considerations for payment method availability