Payments
Create payment sessions and track transactions through the gateways configured in your project.
More information about payments in the OneEntry admin panel: https://doc.oneentry.cloud/docs/category/payments (opens in a new tab)
The Payments module creates a payment session for an order, returns the gateway checkout link, and lets you read session history and status.
The SDK reads payment accounts and creates payment sessions. Accounts and statuses are configured in the admin panel (Payments > Accounts), and you can't create payment accounts through the SDK. Reading payment accounts doesn't require a signed-in user. getSessions() requires an authenticated user (see AuthProvider). Access to the other methods also depends on the module permissions of the caller's user group.
Quickstart
Initialize the module from defineOneEntry:
const { } = defineOneEntry( , { });
Create a payment session for an order and redirect the customer to the gateway (the caller's user group needs permission to create payment sessions):
// Create a Stripe Checkout session for order #179.
const session = await Payments.createSession(179, "session");
if ('statusCode' in session) throw new Error(session.message);
console.log(session.id, session.status, session.paymentUrl);
// Hosted checkout (Stripe) returns a link; custom accounts return null.
if (session.paymentUrl) {
window.location.href = session.paymentUrl;
}
After creating a session, redirect the customer to paymentUrl and handle the gateway's return URLs in your app.
Payment session
A payment session (ISessionEntity) contains:
type:'session'or'intent'status: the payment status:waiting,completed,canceledorexpiredpaymentAccountId: the configured account usedorderId: the associated orderpaymentUrl: gateway checkout link, ornullcreatedDate/updatedDate: timestamps
Session types
| Type | Description |
|---|---|
| session | Creates a Stripe Checkout page with a redirect payment link |
| intent | Creates a payment intent for direct/custom payment processing |
Use session for a hosted payment page: it creates a Stripe Checkout page with a redirect URL. Use intent to integrate a custom payment form directly in your app.
Payment statuses
A session's status is one of four values:
| Status | Meaning |
|---|---|
| waiting | Session created, awaiting payment |
| completed | Payment confirmed by the gateway |
| canceled | Session canceled by the gateway, or automatically when the order is changed or a new payment session is created for it |
| expired | Session lifetime ran out at the gateway |
To confirm a payment, read the session status (or call getSessionByOrderId()) rather than trusting the client.
You can't create or modify payment statuses in the admin panel. You can map them to order storage statuses, though, so the order status updates automatically when the payment status changes: go to Payments > Statuses, select the order storage, map the statuses and save.
Payment lifecycle
1. Configure a payment account in the admin panel (Stripe, YooKassa, Midtrans, Xendit or custom)
↓
2. Customer places an order (Orders module)
↓
3. Create a payment session → Payments.createSession(orderId, type)
↓
4. Redirect the customer to session.paymentUrl
↓
5. Customer completes payment at the gateway
↓
6. Session status reflects the gateway result (e.g. "waiting" → "completed")
↓
7. Mapped order status is updated automatically
Payment accounts
An account's type field reports which payment provider backs it:
type | When to Use | Configuration Required |
|---|---|---|
| stripe | Connect the Stripe payment system | Stripe account, URLs |
| yookassa | Connect YooKassa | Shop id, secret key, URLs |
| midtrans | Connect Midtrans | Provider credentials, URLs |
| xendit | Connect Xendit | Provider credentials, URLs |
| custom | Alternative payment systems or cash payments | Custom configuration |
Provider-specific connection parameters are in the account's settings object; see getAccountById().
Create and edit accounts in the admin panel (Payments > Accounts) with a Name, Type (one of the providers above) and Token. For Stripe accounts, also set the Success URL, Cancel URL and Session lifetime, then call createSession() with type "session" to send customers to Stripe Checkout. Test with Stripe test keys before going to production.
You can create several payment accounts. Each order picks one through its paymentAccountIdentifier.
Never store credit card numbers, CVV or full expiry dates. Payment is handled by the gateway (Stripe), which keeps you out of scope for storing card data; OneEntry never stores raw card details.
Refunds
The Payments module has no refund methods. Refunds are handled in the Orders module with createRefundRequest(), cancelRefundRequest() and getRefunds().
Methods
| Method | Description | Use Case |
|---|---|---|
| getAccounts() | Get all payment accounts | List configured payment accounts |
| getAccountById() | Get a payment account by ID | Fetch specific account details |
| createSession() | Create a payment session | Generate a payment link for an order |
| getSessions() 🔐 | Get all payment sessions (paginated) | View payment session history |
| getSessionById() | Get a payment session by ID | Check a specific session's status |
| getSessionByOrderId() | Get a payment session by order ID | Find the payment for an order |
| getPaymentStagesByOrderId() | Get the payment stages of an order | Track partial payments |
🔐 = Requires authorization
Related
- OneEntry Admin Panel - Payments: admin panel documentation
- OneEntry Admin Panel - Payment Accounts: configure payment accounts
- OneEntry Admin Panel - Payment Statuses: status synchronization
- OneEntry Admin Panel - Stripe Integration: connect Stripe
- Orders Module: orders, checkout and refunds
- AuthProvider Module: authorization for payment sessions
- Stripe Documentation: payment gateway integration