Skip to main content

Complete Integration Examples

Three complete setups. Option 1 is the recommended integration — use it if you have a backend. Your server creates the session (amount computed from your own data, ip passed for fraud prevention), the browser only receives a session ID.
server.js — Express
checkout.html
The amount never travels through the browser, so it can’t be tampered with — and you still get the SDK’s redirect handling.

Option 2: SDK only (no backend)

The SDK creates the session itself with your public key. Best for static sites, prototypes, and evaluating Payviox. Full HTML page with SDK integration:
When you click “Pay Now”, the SDK automatically creates a session and redirects to the secure payment page.
Here the amount originates in the browser and can be modified by the customer. Always verify amount and order_id in your webhook handler before fulfilling the order — or use Option 1.

Option 3: REST API only (no browser)

For backend services, mobile app backends, non-JavaScript stacks, and payment links sent by email.
The response contains a session_id. Build the payment page URL from it and send the customer there — an HTTP redirect, a link in an email, wherever your product reaches them:
Passing an optional paymentMethodId sends the customer straight to that provider instead of the Payviox payment page. For redirect-based providers the response then contains a redirect_url — use it instead of building the URL above. See POST /session.

Webhook Handler Examples

All three setups require a webhook handler on your server — it’s what confirms the payment.

Testing Your Integration

1

Use test credentials

Use your test API token to avoid real charges:
2

Test card numbers

Use these test card numbers in the payment form:
  • 4242 4242 4242 4242 - Successful payment
  • 4000 0000 0000 0002 - Card declined
  • 4000 0000 0000 0341 - Insufficient funds
3

Test webhooks locally

Use ngrok to expose your local server:
Then configure the ngrok URL as your webhook URL.
4

Monitor in dashboard

View all test transactions in your dashboard.

Next Steps

SDK Documentation

Learn more about the SDK

API Documentation

Explore the REST API

Webhook Guide

Complete webhook documentation

Best Practices

Security and best practices