Purchase of goods and services without user registration
In this example, we demonstrate how to place a guest order without requiring user registration.
✅ Purpose of the scenario:
- User is not authorized.
- The user fills out a form with contacts (for example, guest_orders).
- Selects products (you can pre-set a list).
- The order is placed for the user guest_user.
✅ What you need:
- A valid PROJECT_URL and APP_TOKEN for authentication with the OneEntry API.
- marker of the guest order form, for example guest_orders
- list productId and quantity
📌 Important:
- The form fields (marker, type) must match the form settings in the admin panel.
- If you need to send a notification about an order, you can use Events.
- 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:
- Purchase of goods and services without user registration — In this example, we demonstrate how to place a guest order without requiring user registration.
Scenario
1. Import defineOneEntry from SDK define PROJECT_URL and APP_TOKEN
Example:
import { defineOneEntry } from 'oneentry';
import { IOrderData } from 'oneentry/dist/orders/ordersInterfaces';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
2. Creating an API client
Example:
const { AuthProvider, Orders, Payments } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
3. We form an array with fields required for user authorization
Example:
const authData = [
{
// registration form email marker
marker: 'email_reg',
value: 'your-email',
},
{
// registration form password marker
marker: 'password_reg',
value: 'your-password',
},
];
Result:
[
{
"marker": "email_reg",
"value": "kvasssukr.net@gmail.com"
},
{
"marker": "password_reg",
"value": "123456"
}
]
4. Log in as a guest user to place an order
Example:
const user = await AuthProvider.auth('email', {
authData: authData,
});
console.log(user);
Result:
{
"userIdentifier": "kvasssukr.net@gmail.com",
"authProviderIdentifier": "email",
"accessToken": "eyJhbGciOiJIUzI1NiIsInR...pZCI6MTYsImF1dGhQ"
"refreshToken": "1745494429101-...-2834edf8"
}
5. Generate data that is usually received from the frontend form
Example:
const guestFormData = [
{
marker: 'guest_name',
type: 'string',
value: 'Christina Thomas',
},
{
marker: 'guest_phone',
type: 'string',
value: '+18005000500',
},
{
marker: 'guest_email',
type: 'string',
value: 'guest@yourmail.com',
},
];
const productsData = [
{
productId: 15,
quantity: 1,
},
];
const body: IOrderData = {
formIdentifier: 'guest_order',
paymentAccountIdentifier: 'cash',
formData: guestFormData,
products: productsData,
};
Result:
[
{
"productId": 15,
"quantity": 1
}
]
6. Create a guest order
Example:
const order = await Orders.createOrder('guest_orders', body);
if ('statusCode' in order) {
throw new Error(order.message);
}
Result:
{
"id": 113,
"formIdentifier": "guest_order",
"paymentAccountIdentifier": "cash",
"formData": [
{
"marker": "guest_name",
"type": "string",
"value": "Christina Thomas"
},
{
"marker": "guest_phone",
"type": "string",
"value": "+18005000500"
},
{
"marker": "guest_email",
"type": "string",
"value": "guest@yourmail.com"
}
],
"products": [
{
"productId": 15,
"quantity": 1
}
],
"currency": "USD",
"totalSum": 400,
"bonusApplied": 0,
"totalDue": 400,
"discountConfig": {
"orderDiscounts": [],
"productDiscounts": [],
"coupon": null,
"settings": {
"allowStacking": false,
"maxDiscountValue": null,
"allowGiftStacking": false,
"maxBonusPaymentPercent": null,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"giftRefundPolicy": "KEEP_GIFT"
},
"additionalDiscountsMarkers": [],
"totalRaw": 400,
"totalSumWithDiscount": 400,
"excludedGiftProductIds": [],
"bonus": {
"availableBalance": 0,
"maxBonusDiscount": 0,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"bonusApplied": 0
},
"bonusApplied": 0,
"totalDue": 400
},
"statusIdentifier": "guest_upcoming",
"statusLocalizeInfos": {
"title": "Upcoming"
},
"createdDate": "2026-06-06T11:37:20.044Z"
}
7. Creation of payment session
Example:
const paymentSession = await Payments.createSession(
order.id,
'session',
false,
);
console.log(paymentSession);
Result:
{
"id": 62,
"createdDate": "2026-06-06T11:37:21.260Z",
"updatedDate": "2026-06-06T11:37:21.260Z",
"type": "session",
"status": "waiting",
"paymentAccountId": 1,
"orderId": 113,
"amount": null,
"paymentUrl": null
}
8. Get one payment session object by order identifier with Payments.getSessionByOrderId()
Example:
const sessionByOrderId = await Payments.getSessionByOrderId(order?.id).catch(
(e: any) => e,
);
console.log(sessionByOrderId, paymentSession, user);
Result:
[
{
"id": 62,
"createdDate": "2026-06-06T11:37:21.260Z",
"updatedDate": "2026-06-06T11:37:21.260Z",
"type": "session",
"status": "waiting",
"paymentAccountId": 1,
"orderId": 113,
"amount": null,
"paymentUrl": null
}
]
Final example
// 1. Import defineOneEntry from SDK define PROJECT_URL and APP_TOKEN
import { defineOneEntry } from 'oneentry';
import { IOrderData } from 'oneentry/dist/orders/ordersInterfaces';
const PROJECT_URL = 'your-project-url';
const APP_TOKEN = 'your-app-token';
// 2. Creating an API client
const { AuthProvider, Orders, Payments } = defineOneEntry(PROJECT_URL, {
token: APP_TOKEN,
});
// 3. We form an array with fields required for user authorization
const authData = [
{
// registration form email marker
marker: 'email_reg',
value: 'your-email',
},
{
// registration form password marker
marker: 'password_reg',
value: 'your-password',
},
];
// 4. Log in as a guest user to place an order
const user = await AuthProvider.auth('email', {
authData: authData,
});
console.log(user);
// 5. Generate data that is usually received from the frontend form
const guestFormData = [
{
marker: 'guest_name',
type: 'string',
value: 'Christina Thomas',
},
{
marker: 'guest_phone',
type: 'string',
value: '+18005000500',
},
{
marker: 'guest_email',
type: 'string',
value: 'guest@yourmail.com',
},
];
const productsData = [
{
productId: 15,
quantity: 1,
},
];
const body: IOrderData = {
formIdentifier: 'guest_order',
paymentAccountIdentifier: 'cash',
formData: guestFormData,
products: productsData,
};
// 6. Create a guest order
const order = await Orders.createOrder('guest_orders', body);
if ('statusCode' in order) {
throw new Error(order.message);
}
// 7. Creation of payment session
const paymentSession = await Payments.createSession(
order.id,
'session',
false,
);
console.log(paymentSession);
// 8. Get one payment session object by order identifier with [Payments.getSessionByOrderId()](/docs/payments/getSessionByOrderId)
const sessionByOrderId = await Payments.getSessionByOrderId(order?.id).catch(
(e: any) => e,
);
console.log(sessionByOrderId, paymentSession, user);