Capture order (partial)
This request will capture the the order lines included in the request body. totalCaptureAmount
must be a valid sum of the order lines totalAmount
.
Sending the id
property of an order line is optional, if it is included it will result in the removal of the order line from the uncaptured state.
In the scenario where you would like to capture only a quantity subset of an order line, for instance 1 out of 3 existing Samsung phones;
you should exclude the id
property from that line in the capture request and then make a subsequent request to edit the order
and decrease the quantity for the uncaptured order line that was partially captured, as well as recalculating the amounts.
Whether the capture action is available on the order or not, can be determined by inspecting the availableActions
array on the suborder chunk.
This can be retrieved from the GET order response.
- Example Request
- Example Response
curl -X POST \
-H 'authorization: Bearer v4.public.eyJpc3MiOiJs...' \
-H 'content-type: application/json' \
-H 'Idempotency-Key: da7ca8f9-915b-472b-b5f0-81945bff9e4a' \
-d '{
"orderLines": [
{
"description": "SAMSUNG Galaxy S20 FE 4G 128GB (6GB RAM) 6.5 Smartphone - Cl",
"id": "ol_2OC52yClydPxsvKPtujAyQmgRrE",
"quantity": 1,
"reference": "1334227",
"totalAmount": 489000,
"totalVatAmount": 97800,
"type": "physical",
"unitDiscountAmount": 0,
"unitPrice": 489000,
"vat": 2500
}
],
"totalCaptureAmount": 489000
}'
https://api.sandbox.ledyer.com/v1/orders/:orderId/partialcapture
Request Headers
Idempotency-Key
stringOptionalBy providing a unique value for this header, the idempotency of the operation will be guaranteed. This means that retries of requests will be safe to apply in case of network errors, socket errors and timeouts, etc. We recommend using UUID version 4 for the key.
Path parameters
orderId
The order ID string that was obtained when the order session was created.
Request body
orderLines
array of orderlinesAn array of order lines.
Please note that excluding the id
property from an order line in the partial capture request will leave the corresponding uncaptured order line intact after the capture is completed,
whilst providing id
ensures that the order line is removed from the corresponding uncaptured order line.
totalCaptureAmount
integerThe sum of all order lines totalAmount
.
{
"authorizeStatus": "authorized",
"captured": [
{
"availableActions": [
{
"type": "refund"
},
{
"type": "partialRefund"
}
],
"createdAt": "2023-04-09T14:45:35.367198726Z",
"documentReference": "088800149117282055",
"documentUrl": "https://invoice.dev.ledyer.com/invoice-088800149-in_2OC54xBO5LV1RVitiv0Ptd3Q1Ph.pdf?Expires=1681055137&Signature=PmCZi-rMdqlPnPCGre6TFR69DvXkjKffZ7PV0aer0UGbUwbwOSPFUwdJ74CY8uK~yF1GPM~r8321X1cinG-nC0BOm5St9dOmhi63RkQtC2yO2Uo-exvAqpE~uC-s60yN7Y7E0jUtEKzyihsOu-HwflLMUem~mlg6~Z5IzBAjxFoJth0VYkWFfyY-vZqN-RPOS3ZST1Oh4yEydYwQGp0eXNFI5qPeQyNzXPzbhKweM1~Sio1VW8r2vb8I9yippikI7NbCrRMUUoBuMrx7wtUuoRLIUHAnSwqj8uPyY4X4zM793HS55etTsJNfcZDMb15ffMxGJcZHZ4vtPZvKs508Vg__&Key-Pair-Id=K1HDCXLOUP2TQK",
"ledgerId": "in_2OC54xBO5LV1RVitiv0Ptd3Q1Ph",
"note": "",
"orderLines": [
{
"description": "SAMSUNG Galaxy S20 FE 4G 128GB (6GB RAM) 6.5 Smartphone - Cl",
"id": "ol_2OC52yClydPxsvKPtujAyQmgRrE",
"reference": "1334227",
"quantity": 1,
"totalAmount": 489000,
"totalVatAmount": 97800,
"type": "physical",
"unitDiscountAmount": 0,
"unitPrice": 489000,
"vat": 2500
}
],
"status": [],
"totalOrderAmount": {
"amount": "4890.00",
"currency": "SEK",
"formatted": "4,890.00",
"formattedWithCurrency": "SEK 4,890.00",
"minorUnits": 489000
},
"totalOrderAmountExclVat": {
"amount": "3912.00",
"currency": "SEK",
"formatted": "3,912.00",
"formattedWithCurrency": "SEK 3,912.00",
"minorUnits": 391200
},
"totalOrderVatAmount": {
"amount": "978.00",
"currency": "SEK",
"formatted": "978.00",
"formattedWithCurrency": "SEK 978.00",
"minorUnits": 97800
}
}
],
"capturedAmount": {
"amount": "4890.00",
"currency": "SEK",
"formatted": "4,890.00",
"formattedWithCurrency": "SEK 4,890.00",
"minorUnits": 489000
},
"createdAt": "2023-04-09T14:45:19.146027Z",
"customer": { ... },
"events": [
{
"amount": {
"amount": "4890.00",
"currency": "SEK",
"formatted": "4,890.00",
"formattedWithCurrency": "SEK 4,890.00",
"minorUnits": 489000
},
"createdAt": "2023-04-09T14:45:35.367198Z",
"id": "oe_2OC54z91XRnRk5v9Ve1yJL2brtI",
"ledgerId": "in_2OC54xBO5LV1RVitiv0Ptd3Q1Ph",
"orderId": "or_2OC51O5BycRRDboM4PPjYSz0vm5",
"type": "partialCapture"
},
{
"amount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"createdAt": "2023-04-09T14:45:19.146027Z",
"id": "oe_2OC537IyOtvn8kCbuN3z3k1ZeOY",
"ledgerId": "in_2OC52zeSKfMJWxz8eKFRlibWiPQ",
"orderId": "or_2OC51O5BycRRDboM4PPjYSz0vm5",
"type": "readyForCapture"
},
{
"amount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"createdAt": "2023-04-09T14:45:20.754919Z",
"id": "oe_2OC537AKCCYkfmoEQsEbocaaBDQ",
"ledgerId": "in_2OC52zeSKfMJWxz8eKFRlibWiPQ",
"orderId": "or_2OC51O5BycRRDboM4PPjYSz0vm5",
"type": "acknowledge"
},
{
"amount": {
"amount": "14880.00",
"currency": "SEK",
"formatted": "14,880.00",
"formattedWithCurrency": "SEK 14,880.00",
"minorUnits": 1488000
},
"createdAt": "2023-04-09T14:45:19.146027Z",
"id": "oe_2OC530BaBoxsWXXdgcBsfqYsdUj",
"ledgerId": "in_2OC52zeSKfMJWxz8eKFRlibWiPQ",
"orderId": "or_2OC51O5BycRRDboM4PPjYSz0vm5",
"type": "create"
}
],
"expiresAt": "2023-04-23T14:45:19.146027Z",
"id": "or_2OC51O5BycRRDboM4PPjYSz0vm5",
"merchantId": "ac_1xWqkkS5aIbxCJsoseRhSd0OJyD",
"merchantReference": "or_24y1E89OBs0KjAmRXEJu5pivxt4",
"orderAmount": {
"amount": "14880.00",
"currency": "SEK",
"formatted": "14,880.00",
"formattedWithCurrency": "SEK 14,880.00",
"minorUnits": 1488000
},
"orderReference": "UB1CECSM",
"paymentMethod": {
"provider": "ledyer",
"type": "invoice"
},
"riskProfile": {
"tags": []
},
"refunded": [],
"refundedAmount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"status": [
"partiallyCaptured"
],
"storeId": "970245072",
"uncaptured": {
"availableActions": [
{
"type": "cancel"
},
{
"type": "capture"
},
{
"type": "partialCapture"
},
{
"type": "editCustomer"
},
{
"type": "editOrder"
},
{
"type": "extendOrderExpiry"
}
],
"createdAt": "2023-04-09T14:45:19.146027112Z",
"ledgerId": "in_2OC52zeSKfMJWxz8eKFRlibWiPQ",
"note": "",
"orderLines": [
{
"description": "APPLE iPhone 13 Pro 5G 256GB - 6.1\\\" Smartphone - Guld",
"id": "ol_2OC52vhkHDwdLnwKkELFwiP6Io9",
"quantity": 1,
"reference": "231654",
"totalAmount": 999000,
"totalVatAmount": 199800,
"type": "physical",
"unitDiscountAmount": 0,
"unitPrice": 999000,
"vat": 2500
}
],
"status": [],
"totalOrderAmount": {
"amount": "9990.00",
"currency": "SEK",
"formatted": "9,990.00",
"formattedWithCurrency": "SEK 9,990.00",
"minorUnits": 999000
},
"totalOrderAmountExclVat": {
"amount": "7992.00",
"currency": "SEK",
"formatted": "7,992.00",
"formattedWithCurrency": "SEK 7,992.00",
"minorUnits": 799200
},
"totalOrderVatAmount": {
"amount": "1998.00",
"currency": "SEK",
"formatted": "1,998.00",
"formattedWithCurrency": "SEK 1,998.00",
"minorUnits": 199800
}
},
"uncapturedAmount": {
"amount": "9990.00",
"currency": "SEK",
"formatted": "9,990.00",
"formattedWithCurrency": "SEK 9,990.00",
"minorUnits": 999000
},
"updatedAt": "2023-04-09T14:45:35.367198Z",
}
captured
array of suborderA list of captures, what was partially captured will be removed from the uncaptured
object, and enter the captured list.
capturedAmount
objectAn object containing strings amount
, currency
, formatted
, formattedWithCurrency
and integer minorUnits
, in case of a partial capture the amount that was captured so far.
events
array of eventsA list of event objects, or snapshots on the order.
Each object contains an amount
object with the strings amount
, currency
formatted
, formattedWithCurrency
and integer minorUnits
pertaining to the event.
The event object also contains the date string createdAt
as well as orderId
and ledgerId
, and finally the event type
.
Events can have one of the following types:
acknowledge
: Order has been acknowledged.authorize
: Order has been authorized.cancel
: Order has been cancelled.create
: Order has been created.edit
: The order lines etc have been edited since first authorized.editCustomer
: The customer details of the order have been edited.editPaymentMethod
: The payment method of the order has been changed.extendExpiry
: The expiry date of the order has been extended at least once.fullCapture
: All order lines have been captured.fullRefund
: All order lines have been added to a credit invoice.paid
: Order has been paid.partialCapture
: Some of the order lines have been captured.partialRefund
: Some of the order lines have been added to a credit invoice.readyForCapture
: Order has been made ready for capture.setReference
: The merchant's order reference has been updated.
status
array of stringsA list of strings indicating the current status of the order (can be both captured and refunded, for instance).
cancelled
: Order has been cancelled.expired
: The expiry date of the order is passed.fullyCaptured
: All order lines have been captured.fullyPaid
: The order has been paid fully.fullyRefunded
: All order lines have been added to a credit invoice.partiallyCaptured
: Some of the order lines have been captured.partiallyPaid
: The order has been paid partially.partiallyRefunded
: Some of the order lines have been added to a credit invoice.unacknowledged
: The order has not yet been acknowledged.uncaptured
: The order has not yet been captured.
uncaptured
objectA list of what is still uncaptured after the partial capture.
uncapturedAmount
nullAn object containing strings amount
, currency
, formatted
, formattedWithCurrency
and integer minorUnits
, in case of a partial capture a part of the amount will have been deducted, which will be reflected in capturedAmount
.
updatedAt
stringThe timestamp of the latest added event under events
.