Appearance
Create Payment Session
Create a payment session to initiate a transaction. The response includes a session_url — redirect the user there immediately to complete payment on the hosted Spayon page.
Endpoint
http
POST https://api.spayon.io/api/product/session
Authorization: Bearer YOUR_BEARER_TOKEN
Content-Type: application/jsonhttp
POST http://staging-spayon-api.eu-north-1.elasticbeanstalk.com/api/product/session
Authorization: Bearer YOUR_BEARER_TOKEN
Content-Type: application/jsonRequest Body
There are two ways to create a session depending on whether you are using a product pre-configured in the admin panel.
Option 1 — Using a Marketplace Product
Use this when the product already exists in your admin panel. Provide product_id instead of price/currency.
json
{
"product_id": 1,
"callback_url": "https://example.com/api/payment-callback",
"return_url": "https://example.com/thank-you",
"cancel_url": "https://example.com/payment-cancelled",
"email": "user@example.com",
"username": "john_doe",
"full_name": "John Doe",
"order_id": "ORDER_123456",
"defaultPaymentMethod": "visamaster",
"availablePaymentMethods": ["visamaster", "mir"],
"language": "en"
}Option 2 — Custom Product Details
Use this when the product is not in the admin panel. Provide product_name, price, and currency directly.
json
{
"product_name": "Custom Product",
"price": 1000,
"currency": "amd",
"callback_url": "https://example.com/api/payment-callback",
"return_url": "https://example.com/thank-you",
"cancel_url": "https://example.com/payment-cancelled",
"email": "user@example.com",
"username": "john_doe",
"full_name": "John Doe",
"order_id": "ORDER_123456",
"defaultPaymentMethod": "visamaster",
"availablePaymentMethods": ["visamaster", "mir"],
"language": "en"
}Field Reference
| Field | Type | Required | Description |
|---|---|---|---|
product_id | integer | Conditional | Product ID from the admin panel. Use instead of product_name/price/currency. |
product_name | string | Conditional | Product name. Required when not using product_id. |
price | number | Conditional | Exact price amount. Required when not using product_id. |
currency | string | Conditional | AMD, RUB, USD, EUR, or GBP. Required when not using product_id. |
callback_url | string | Yes | URL to receive POST payment notifications. Must be publicly accessible. |
return_url | string | Yes | URL the user is redirected to after payment completes (regardless of status). |
cancel_url | string | No | URL the user is redirected to when clicking the back button on the payment page. |
email | string | No | Customer email address. |
username | string | No | Customer username. |
full_name | string | No | Customer full name. |
order_id | string | No | Your internal order identifier for tracking. |
defaultPaymentMethod | string | No | Pre-selected payment method: visamaster or mir. |
availablePaymentMethods | array | No | Restrict available methods: ["visamaster", "mir"]. |
language | string | No | Payment page language: en, hy, or ru. |
Protocol
In Production, callback_url and return_url must use HTTPS. In Staging, HTTP is also accepted.
Response
json
{
"session_url": "https://spayon.io/session/5716f328-5adb-46fe-938f-d72f1d65b98e",
"session_id": "5716f328-5adb-46fe-938f-d72f1d65b98e",
"status": "pending",
"order_id": "ORDER_123456"
}Immediately redirect the user to session_url after receiving this response.
Response Codes
| Status Code | Description |
|---|---|
200 OK | Session created successfully |
400 Bad Request | Invalid or missing parameters |
401 Unauthorized | Invalid or expired Bearer Token |
Session Constraints
| Property | Value |
|---|---|
| Expiry | 15 minutes from creation |
| Single use | Each session URL can only be used once |
| Redirect | Redirect users immediately — do not delay |