Tickets order
In this example, we demonstrate how to order tickets for an event using the OneEntry API.
✅ Purpose of the scenario:
- The user logs in with their credentials
- Selects the ticket type, date and time from the schedule
- Pays for the order and receives a ticket by email
✅ What you need:
- A valid PROJECT_URL and APP_TOKEN for authentication with the OneEntry API.
- Registered user for authentication
- Form with marker "tickets_form" and fileds "schedule" and "tickets"
- Configured order storage with marker "tickets"
📌 Important:
- These examples do not include error handling.
- You can manage errors using a try-catch block or by employing a construction like await Promise.catch((error) => error).
📚 See in documentation:
📦 SDK reference:
Try it live
Run this method interactively in the JS SDK sandbox — connect your Project URL and App Token on first visit, then open:
- Tickets order — In this example, we demonstrate how to order tickets for an event using the OneEntry API.
Scenario
1. Import defineOneEntry from SDK and define PROJECT_URL and APP_TOKEN
Example:
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
2. Creating an API client with defineOneEntry()
Example:
const { AuthProvider, Forms, Orders, Payments } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. User authorization with AuthProvider.auth()
Example:
const authData = [
{ marker: 'email_reg', value: 'your-email' },
{ marker: 'password_reg', value: 'your-password' },
];
const authResponse = await AuthProvider.auth('email', { authData });
console.log(authResponse);
Result:
{
"userIdentifier": "kvasssukr.net@gmail.com",
"authProviderIdentifier": "email",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR...pZCI6MTYsImF1dGhQ"
"refreshToken": "1745494429101-...-2834edf8"
}
4. We receive form data from OneEntry Platform with Forms.getFormByMarker() to generate a form on the frontend
Example:
const formData = await Forms.getFormByMarker('tickets_form');
console.log(formData);
Result:
{
"id": 9,
"attributeSetId": 12,
"type": "order",
"localizeInfos": {
"title": "Tickets",
"titleForSite": "Tickets",
"successMessage": "",
"unsuccessMessage": "",
"urlAddress": "",
"database": "0",
"script": "0"
},
"version": 6,
"position": 1,
"identifier": "tickets_form",
"processingType": "script",
"templateId": null,
"attributes": [
{
"type": "timeInterval",
"marker": "schedule",
"position": 1,
"settings": {},
"isVisible": true,
"listTitles": [],
"validators": {},
"initialValue": null,
"localizeInfos": {
"title": "Schedule",
"intervals": [
{
"id": "ef9cf848-7373-4b81-98bd-7ad33aa951e2",
"range": [
"2025-04-26T21:00:00.000Z",
"2025-04-26T21:00:00.000Z"
],
"external": [],
"intervals": [
{
"id": "f2042e47-c650-4fc6-ae1c-efdb109b450f",
"end": {
"hours": 21,
"minutes": 30
},
"start": {
"hours": 16,
"minutes": 30
},
"period": 90
}
],
"inEveryWeek": true,
"inEveryMonth": true
}
]
},
"additionalFields": {}
},
{
"type": "entity",
"marker": "tickets",
"position": 2,
"settings": {},
"isVisible": true,
"listTitles": [
{
"title": "Tickets",
"value": {
"id": 8,
"depth": 0,
"isPinned": false,
"parentId": null,
"position": "0|hzzzz3:"
}
},
{
"title": "Bronze",
"value": {
"id": "p-8-10",
"depth": 1,
"isPinned": false,
"parentId": 8,
"position": 1,
"selected": true
}
},
{
"title": "Silver",
"value": {
"id": "p-8-11",
"depth": 1,
"isPinned": false,
"parentId": 8,
"position": 2,
"selected": true
}
},
{
"title": "Gold",
"value": {
"id": "p-8-12",
"depth": 1,
"isPinned": false,
"parentId": 8,
"position": 3,
"selected": true
}
}
],
"validators": {
"requiredValidator": {
"strict": true
}
},
"initialValue": null,
"localizeInfos": {
"title": "Tickets"
},
"additionalFields": {}
}
],
"total": "1",
"moduleFormConfigs": []
}
The schedule attribute carries a compact recurrence rule, not a list of slots. Resolve it into concrete [start, end] pairs for the dates you render with expandTimeIntervals - see Time Intervals:
import { expandTimeIntervals } from 'oneentry';
const field = formData.attributes.find((a) => a.marker === 'schedule');
const slots = (field?.localizeInfos.intervals ?? []).flatMap((schedule) =>
expandTimeIntervals(schedule, { from: '2025-04-01', to: '2025-04-30' }),
);
5. Creation of an order in the order storage with Orders.createOrder()
Data:
{
"formIdentifier": "tickets_form",
"paymentAccountIdentifier": "cash",
"formData": {
"en_US": [
{
"type": "entity",
"marker": "tickets",
"value": [
"p-8-10"
]
}
]
},
"products": [
{
"productId": 10,
"quantity": 1
}
]
}
Example:
const body = {
formIdentifier: 'tickets_form',
paymentAccountIdentifier: 'cash',
formData: [{ type: 'entity', marker: 'tickets', value: ['p-8-10'] }],
products: [{ productId: 10, quantity: 1 }],
};
const order = await Orders.createOrder('tickets', body);
if ('statusCode' in order) {
throw new Error(order.message);
}
Result:
{
"id": 123,
"formIdentifier": "tickets_form",
"paymentAccountIdentifier": "cash",
"formData": [
{
"type": "entity",
"marker": "tickets",
"value": [
"p-8-10"
]
}
],
"products": [
{
"productId": 10,
"quantity": 1
}
],
"currency": "USD",
"totalSum": 100,
"bonusApplied": 0,
"totalDue": 100,
"discountConfig": {
"orderDiscounts": [],
"productDiscounts": [],
"coupon": null,
"settings": {
"allowStacking": false,
"maxDiscountValue": null,
"allowGiftStacking": false,
"maxBonusPaymentPercent": null,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"giftRefundPolicy": "KEEP_GIFT"
},
"additionalDiscountsMarkers": [],
"totalRaw": 100,
"totalSumWithDiscount": 100,
"excludedGiftProductIds": [],
"bonus": {
"availableBalance": 0,
"maxBonusDiscount": 0,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"bonusApplied": 0
},
"bonusApplied": 0,
"totalDue": 100
},
"statusIdentifier": "new",
"statusLocalizeInfos": {
"title": "new"
},
"createdDate": "2026-06-06T11:54:31.545Z"
}
6. Creation of payment session with Payments.createSession()
Example:
const paymentSession = await Payments.createSession(order.id, 'session', false);
console.log(paymentSession);
Result:
{
"id": 71,
"createdDate": "2026-06-06T11:54:31.857Z",
"updatedDate": "2026-06-06T11:54:31.857Z",
"type": "session",
"status": "waiting",
"paymentAccountId": 1,
"orderId": 123,
"amount": null,
"paymentUrl": null
}
7. Get one payment session object by order identifier with Payments.getSessionByOrderId()
Example:
const sessionByOrderId = await Payments.getSessionByOrderId(order.id);
console.log(sessionByOrderId);
Result:
[
{
"id": 71,
"createdDate": "2026-06-06T11:54:31.857Z",
"updatedDate": "2026-06-06T11:54:31.857Z",
"type": "session",
"status": "waiting",
"paymentAccountId": 1,
"orderId": 123,
"amount": null,
"paymentUrl": null
}
]
Final example
// 1. Import defineOneEntry from SDK and define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
// 2. Creating an API client with [defineOneEntry()](/docs/index/#Installation)
const { AuthProvider, Forms, Orders, Payments } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. User authorization with [AuthProvider.auth()](/docs/auth-provider/auth)
const authData = [
{ marker: 'email_reg', value: 'your-email' },
{ marker: 'password_reg', value: 'your-password' },
];
const authResponse = await AuthProvider.auth('email', { authData });
console.log(authResponse);
// 4. We receive form data from OneEntry Platform with Forms.getFormByMarker() to generate a form on the frontend
const formData = await Forms.getFormByMarker('tickets_form');
console.log(formData);
// 5. Creation of an order in the order storage with [Orders.createOrder()](/docs/orders/createOrder)
const body = {
formIdentifier: 'tickets_form',
paymentAccountIdentifier: 'cash',
formData: [{ type: 'entity', marker: 'tickets', value: ['p-8-10'] }],
products: [{ productId: 10, quantity: 1 }],
};
const order = await Orders.createOrder('tickets', body);
if ('statusCode' in order) {
throw new Error(order.message);
}
// 6. Creation of payment session with [Payments.createSession()](/docs/payments/createSession)
const paymentSession = await Payments.createSession(order.id, 'session', false);
console.log(paymentSession);
// 7. Get one payment session object by order identifier with [Payments.getSessionByOrderId()](/docs/payments/getSessionByOrderId)
const sessionByOrderId = await Payments.getSessionByOrderId(order.id);
console.log(sessionByOrderId);