Skip to main content

getSessionByOrderId

Get the payment session of an order. Access depends on the module permissions of the caller's user group; a signed-in user isn't required.

Description​

Fetches the payment session of the order with the given id. Resolves to an ISessionEntity or an array of ISessionEntity objects.

.getSessionByOrderId(

);

Parameters schema​

Schema

id(required): number
Order ID.
example: 12345

Examples​

Minimal example​

const response = await Payments.getSessionByOrderId(2);

Example response​

[
{
"id": 1,
"createdDate": "2025-02-25T10:52:59.634Z",
"updatedDate": "2025-02-25T10:52:59.634Z",
"type": "session",
"status": "waiting",
"paymentAccountId": 1,
"orderId": 2,
"amount": null,
"paymentUrl": null
}
]

Response schema​

Schema: ISessionEntity | ISessionEntity[]

id: number
Object ID.
example: 1764

createdDate: string
Creation date.
example: "2025-02-26T10:13:16.839Z"

updatedDate: string
Date the object was last modified.
example: "2025-02-26T10:13:16.839Z"

type: 'session' | 'intent'
Session type: "session" or "intent".
example: "session"

status: string
Payment status.
example: "completed"

paymentAccountId: number
ID of the payment account.
example: 1

orderId: number | null
ID of the order; null for the session of a subscription, which has no order.
example: 1

paymentUrl: string | null
Payment page URL.
example: "https://www.sandbox.paypal.com/checkoutnow?token=9BE88048TU058770M"

amount: number | null
Payment session amount.
example: 100

clientSecret: string
Client secret returned by the payment provider (for example, Stripe) when the session is created.
example: "pi_3MtwBwLkdIwHu7ix28a3tqPa_secret_YrKJUKribcBjcG8HVhfZluoGH"


Usage examples​

Step-by-step walkthroughs in the documentation:

  • Order pay: fetch the payment session for an order placed by a registered user.
  • Tickets order: get the payment session created for a tickets order.
  • Guest order: retrieve the payment session for a guest order.

Try it live​

Run this method interactively in the JS SDK sandbox. On your first visit, connect your Project URL and App Token, then open:

  • Order pay: fetch the payment session for an order placed by a registered user.
  • Tickets order: get the payment session created for a tickets order.
  • Guest order: retrieve the payment session for a guest order.