getPaymentStagesByOrderId
Getting the payment progress of an order: its stages and whether they are paid.
Description
This method retrieves the payment stages of one order, together with two flags that describe the order as a whole. It returns a Promise that resolves to an IPaymentProgress object.
Payments.getPaymentStagesByOrderId(id);
Parameters
id: number
ID of the order object.
example: 1
💡 What the two flags mean
An order can be paid in parts rather than in one payment. partial says which case it is, completed says whether anything is left to pay, and each stage carries its own status.
const progress = await Payments.getPaymentStagesByOrderId(205);
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
This method requires user authorization. See the AuthProvider module.
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 when the order is paid in stages rather than in one payment.
example: true
stages: IPaymentStage[]
The stages themselves, in the order the API returns them.
example: [{ "marker": "part_a", "status": "completed" }]
stages[].marker: string
Marker of the attribute that set 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
Identifier of the product the stage belongs to.
example: 200
stages[].title: string
Title of the stage.
example: "Part A"
stages[].value: number
Price of the stage.
example: 150
stages[].status: "planned" | "completed"
Stage status: planned - not paid yet, completed - paid.
example: "planned"