Skip to main content

getPaymentStagesByOrderId

Get the payment progress of an order: its stages and whether they are paid.

Description​

Fetches the payment stages of an order, plus two flags that describe the order as a whole. Resolves to an IPaymentProgress.

.getPaymentStagesByOrderId(

);

Parameters schema​

Schema

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

What the two flags mean​

completed is true when every stage is paid. partial is true once at least one stage is paid, so check completed first. Each stage has its own status, and sessionId is null until a payment session is created for that stage.

const progress = await Payments.getPaymentStagesByOrderId(205);
if ('statusCode' in progress) throw new Error(progress.message);

if (progress.completed) {
// Nothing left to pay.
} else if (progress.partial) {
const left = progress.stages.filter((stage) => stage.status === 'planned');
console.log(`${left.length} stages still to pay`);
}

Authorization​

Access depends on the module permissions of the caller's user group; configure them in the admin panel.

Examples​

Minimal example​

const response = await Payments.getPaymentStagesByOrderId(205);

Example response​

{
"completed": false,
"partial": true,
"stages": [
{
"marker": "part_a",
"sessionId": 100,
"productId": 200,
"title": "Part A",
"value": 150,
"status": "completed"
},
{
"marker": "part_b",
"sessionId": 101,
"productId": 200,
"title": "Part B",
"value": 150,
"status": "planned"
}
]
}

Response schema​

Schema: IPaymentProgress

completed: boolean
true when every stage of the order has been paid.
example: false

partial: boolean
true once at least one stage is paid. Check completed first: it is true when nothing is left to pay.
example: true

stages: IPaymentStage[]
The stages themselves, in the order the API returns them.

stages.marker: string
Marker of the attribute that sets the price of the stage.
example: "part_a"

stages.sessionId: number
Identifier of the payment session bound to the stage.
example: 100

stages.productId: number
ID of the product the stage belongs to.
example: 200

stages.title: string
Title of the stage.
example: "Part A"

stages.value: number
Amount due for the stage.
example: 150

stages.status: "planned" | "completed"
Stage status: "planned" — not paid yet, "completed" — paid.
example: "planned"