Create Session
Create a payment session with amount, currency, and items. Supports public (pk_) and secret (sk_) API keys, optional IP validation for fraud prevention, direct provider redirect via paymentMethodId, and rate limiting
Overview
Creates a new payment session for your customer. The session ID can be used to redirect the customer to the payment page or to fetch available payment methods.Authentication
This endpoint accepts both Public API Key (client-side) and Secret API Key (server-side). See Authentication for details.Integration Modes
- Client-side (SDK)
- Server-side (API)
- Client IP is automatically captured from the request
- No need to provide the
ipparameter - Ideal for: websites, single-page applications
Example Requests
Client-side Example (Public API Key)
Server-side Example (Secret API Key with IP)
When creating sessions from your backend, you can provide the client’s IP address for fraud prevention:Direct Redirect (Skip Payment Page)
When you specify apaymentMethodId for a redirect-based payment provider (like Zen, Nicepay, PayPal, etc.), the API will automatically initiate the payment and return a redirect_url in the response.
This allows you to bypass the Payviox payment page entirely and redirect the customer directly to the payment provider.
How it works
- Create a session with a
paymentMethodIdfor a redirect-based provider - The API creates the session and initiates the payment
- You receive both
session_idandredirect_urlin the response - Redirect your customer directly to the
redirect_url
Server-side Direct Redirect Example
Redirect-based Providers
The following providers support direct redirect:| Provider | Payment Methods |
|---|---|
| Zen | zen_card, zen_blik, etc. |
| Nicepay | nicepay_va, nicepay_ewallet, etc. |
| PayPal | paypal |
| Payssion | Various local payment methods |
| Pallapay | Crypto payments |
| Crypto.com | cryptocom |
Handling Payment Errors
If the payment initiation fails (e.g., provider API error), the response will includepayment_error along with the session_id. You can then fall back to the standard flow:
Example Response
Error Responses
400 — Validation Error
400 — Validation Error
- Required fields missing (
amount,currency,customer,order_id,items) - Amount does not match the sum of item prices
- Invalid item structure (missing name, quantity, or price)
400 — Payment Method Not Found
400 — Payment Method Not Found
paymentMethodId parameter references a payment method that does not exist or is not enabled for your business.How to resolve: Use the Get Payment Methods endpoint to list available methods.401 — Unauthorized
401 — Unauthorized
429 — Rate Limit Exceeded
429 — Rate Limit Exceeded
retry_after field (in seconds) and a Retry-After HTTP header indicating when you can retry.How to resolve: Wait for the duration indicated by retry_after before retrying. Implement exponential backoff in your integration.ip parameter when creating the session, the payment page will verify that the user’s IP matches. This is a fraud prevention measure.Next Steps
After creating a session:Redirect Customer
Get Payment Methods
Dashboard
API Playground
Validation Rules
Amount Validation
Amount Validation
- Minimum amount: 100 cents ($1.00)
- Must be a positive integer
- Total amount must equal the sum of all items (price × quantity)
Items Validation
Items Validation
- At least one item is required
- Each item must have a name, quantity, and price
- Quantity must be at least 1
- Price must be at least 1 cent
Order ID
Order ID
- Must be unique per business
- Used for tracking and webhooks
- Recommended to use your internal order/transaction ID
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Payment amount in cents (e.g., 10000 = $100.00)
x >= 100Three-letter ISO currency code (e.g., USD)
3Customer identifier (email, customer ID, or unique identifier)
Your unique order identifier
Array of items being purchased
[
{
"name": "Premium Plan",
"quantity": 1,
"price": 10000
}
]Optional description of the payment
Force a specific payment method (optional)
Server-side only. The end-user's IP address
Custom key-value pairs to attach to this session. These will be returned in webhook notifications.
{
"user_id": "usr_123",
"campaign": "summer_sale"
}Response
Session created successfully
Unique identifier for the created session