Skip to main content
PayNext SDK automatically supports all payment methods and 3D Secure authentication configured in your dashboard, including cards, Apple Pay, Google Pay, PayPal, and more.

Prerequisites

  • Create a one-time or subscription plan in Dashboard → Plans
  • Enable desired payment methods in Dashboard → Checkout
  • Configure workflows for each enabled payment method in Dashboard → Workflows
  • PayNext API Key: Available in Dashboard → Developers → API Keys
Never expose your API key in client-side code. Always create client sessions on your server.

How It Works

Integration Steps

1

Create Session

Call the PayNext API from your server. See the API Reference for details.POST /client-session
Example Request
Example Response
Use the id from the response as your clientToken in the frontend.
Note the expiry_date in the response — sessions expire after this time. If your session expires, create a new one before mounting checkout. For more details, see Handle Expired Sessions.
2

Install SDK

3

Preload SDK (Optional)

The SDK uses a CDN-based architecture with a small initial bundle. You can optionally preload the SDK when you anticipate checkout usage (e.g., on pricing pages):
Preloading is recommended as this will speed up how fast payment buttons will load. Without it, the SDK loads on-demand when you call mount.
4

Configure Return URL

Required for redirect-based payment methods (Cash App, Venmo, etc.). Without it, customers cannot complete checkout.
  • Point to a page where the checkout is rendered
  • Optionally, use a URL query parameter (e.g., ?scrollTo=paynext-checkout) to scroll users back to checkout if it’s not at the top of the page
Avoid using hash fragments (e.g., #paynext-checkout) in your returnUrl — they are not supported by all alternative payment methods (APM). Use query parameters instead (e.g., ?scrollTo=paynext-checkout).
5

Mount Checkout

Initialize the SDK with your clientToken and mount the checkout form.
6

Test

Use the sandbox environment and test payment details available for your payment method and processor to validate your setup.
Track test payments in Dashboard → Payments. For Apple Pay and Google Pay, ensure your browser and device meet eligibility requirements.
7

Go Live

  1. Change environment to 'production' in your SDK config
  2. Use production API keys on your backend
  3. Test with real payment methods before launch
  4. Set up webhooks for payment confirmations
onCheckoutComplete is a client-side UX signal, not a settlement confirmation — and it is not guaranteed to run. It fires in the customer’s browser, so a closed or backgrounded tab or a lost connection can prevent it, on any payment method (seen on PayPal and Apple Pay); for asynchronous methods such as Pix the payment can also still be settling when it fires. Grant access and fulfill orders from payment webhooks — the source of truth for the final payment status.