Skip to content

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/json
http
POST http://staging-spayon-api.eu-north-1.elasticbeanstalk.com/api/product/session
Authorization: Bearer YOUR_BEARER_TOKEN
Content-Type: application/json

Request 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

FieldTypeRequiredDescription
product_idintegerConditionalProduct ID from the admin panel. Use instead of product_name/price/currency.
product_namestringConditionalProduct name. Required when not using product_id.
pricenumberConditionalExact price amount. Required when not using product_id.
currencystringConditionalAMD, RUB, USD, EUR, or GBP. Required when not using product_id.
callback_urlstringYesURL to receive POST payment notifications. Must be publicly accessible.
return_urlstringYesURL the user is redirected to after payment completes (regardless of status).
cancel_urlstringNoURL the user is redirected to when clicking the back button on the payment page.
emailstringNoCustomer email address.
usernamestringNoCustomer username.
full_namestringNoCustomer full name.
order_idstringNoYour internal order identifier for tracking.
defaultPaymentMethodstringNoPre-selected payment method: visamaster or mir.
availablePaymentMethodsarrayNoRestrict available methods: ["visamaster", "mir"].
languagestringNoPayment 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 CodeDescription
200 OKSession created successfully
400 Bad RequestInvalid or missing parameters
401 UnauthorizedInvalid or expired Bearer Token

Session Constraints

PropertyValue
Expiry15 minutes from creation
Single useEach session URL can only be used once
RedirectRedirect users immediately — do not delay