Refund order (partial)
This request will create a credit invoice with order lines included in the request body. totalRefundAmount
must be a valid sum of the order lines totalAmount
.
An order must have a captured
array populated with order lines for a refund to be successful, that is where the ledgerId
string is located.
Whether the refund 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",
"quantity": 2,
"reference": "321-321",
"totalAmount": 999000,
"totalVatAmount": 199800,
"type": "physical",
"unitPrice": 499500,
"vat": 2500
}
],
"totalRefundAmount": 999000
}'
https://api.sandbox.ledyer.com/v1/orders/:orderId/partialrefund/:ledgerId
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
ledgerId
The ledger ID string that is included in a capture
.
orderId
The order ID string that was obtained when the order session was created.
Request body
orderLines
array of orderlinesOptionalAn array of order lines.
Please note that order line id
property must be excluded in this request.
totalRefundAmount
integerThe sum of all order lines totalAmount
.
note
stringOptionalA note for the refund reason.
{
"authorizeStatus": "authorized",
"captured": [
{
"availableActions": [
{
"type": "refund"
},
{
"type": "partialRefund"
}
],
"createdAt": "2023-02-15T08:58:30.074840356Z",
"documentReference": "970245072092446903",
"documentUrl": "https://invoice.sandbox.ledyer.com/invoice-970245072-1",
"ledgerId": "in_258jE7yM5TxedaYYuzw0ApaqDFs",
"note": "some reason",
"orderLines": [
{
"description": "APPLE iPhone 13 Pro 5G 256GB - 6.1\" Smartphone - Guld",
"id": "ol_258jE6HSi0gtKwKQwxk27IAFkOL",
"quantity": 3,
"reference": "123-123",
"totalAmount": 4077000,
"totalVatAmount": 815400,
"type": "physical",
"unitPrice": 1359000,
"vat": 2500
},
{
"description": "SAMSUNG Galaxy S20 FE 4G 128GB (6GB RAM) 6.5 Smartphone - Cl",
"id": "ol_258jE65TwHIeyTOfjvD0CEe6EwC",
"quantity": 2,
"reference": "321-321",
"totalAmount": 999000,
"totalVatAmount": 199800,
"type": "physical",
"unitPrice": 499500,
"vat": 2500
}
],
"status": [],
"totalOrderAmount": {
"amount": "50760.00",
"currency": "SEK",
"formatted": "50,760.00",
"formattedWithCurrency": "SEK 50,760.00",
"minorUnits": 5076000
},
"totalOrderAmountExclVat": {
"amount": "40608.00",
"currency": "SEK",
"formatted": "40,608.00",
"formattedWithCurrency": "SEK 40,608.00",
"minorUnits": 4060800
},
"totalOrderVatAmount": {
"amount": "10152.00",
"currency": "SEK",
"formatted": "10,152.00",
"formattedWithCurrency": "SEK 10,152.00",
"minorUnits": 1015200
}
}
],
"capturedAmount": {
"amount": "50760.00",
"currency": "SEK",
"formatted": "50,760.00",
"formattedWithCurrency": "SEK 50,760.00",
"minorUnits": 5076000
},
"createdAt": "2023-02-15T08:58:12.778683Z",
"customer": { ... },
"events": [
{
"amount": {
"amount": "9990.00",
"currency": "SEK",
"formatted": "9,990.00",
"formattedWithCurrency": "SEK 9,990.00",
"minorUnits": 999000
},
"createdAt": "2023-02-15T08:58:38.929025Z",
"id": "oe_258jHMYwAqMvjnIbFH37mjsD1hN",
"ledgerId": "in_258jHIUx28bLgmJo7wEaCpfvcKL",
"orderId": "or_258jARIhO7PK0faX86WiIpWV47A",
"type": "partialRefund"
},
{
"amount": {
"amount": "50760.00",
"currency": "SEK",
"formatted": "50,760.00",
"formattedWithCurrency": "SEK 50,760.00",
"minorUnits": 5076000
},
"createdAt": "2023-02-15T08:58:30.07484Z",
"id": "oe_258jGIcqGpi9zfALw63wnyAfWNL",
"ledgerId": "in_258jE7yM5TxedaYYuzw0ApaqDFs",
"orderId": "or_258jARIhO7PK0faX86WiIpWV47A",
"type": "fullCapture"
},
{
"amount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"createdAt": "2023-02-15T08:58:13.778683Z",
"id": "oe_258jE8M2I8PtdBFPkVBURw4dYlw",
"ledgerId": "in_258jE7yM5TxedaYYuzw0ApaqDFs",
"orderId": "or_258jARIhO7PK0faX86WiIpWV47A",
"type": "readyForCapture"
},
{
"amount": {
"amount": "50760.00",
"currency": "SEK",
"formatted": "50,760.00",
"formattedWithCurrency": "SEK 50,760.00",
"minorUnits": 5076000
},
"createdAt": "2023-02-15T08:58:12.778683Z",
"id": "oe_258jE8M2I8PtdBFPkVBURw4dYlw",
"ledgerId": "in_258jE7yM5TxedaYYuzw0ApaqDFs",
"orderId": "or_258jARIhO7PK0faX86WiIpWV47A",
"type": "create"
}
],
"expiresAt": "2023-03-01T08:58:12.778683Z",
"id": "or_258jARIhO7PK0faX86WiIpWV47A",
"merchantId": "ac_1xWqkkS5aIbxCJsoseRhSd0OJyD",
"merchantReference": "or_258jARIhO7PK0faX86WiIpWV47A",
"orderAmount": {
"amount": "50760.00",
"currency": "SEK",
"formatted": "50,760.00",
"formattedWithCurrency": "SEK 50,760.00",
"minorUnits": 5076000
},
"orderReference": "EBZI5JDN",
"paymentMethod": {
"provider": "ledyer",
"type": "invoice"
},
"refunded": [
{
"availableActions": [],
"createdAt": "2023-02-15T08:58:38.929025856Z",
"documentReference": "970245072092446992",
"documentUrl": "https://invoice.sandbox.ledyer.com/invoice-970245072-2",
"ledgerId": "in_258jHIUx28bLgmJo7wEaCpfvcKL",
"note": "some reason",
"orderLines": [
{
"description": "SAMSUNG Galaxy S20 FE 4G 128GB (6GB RAM) 6.5 Smartphone - Cl",
"id": "ol_258jE65TwHIeyTOfjvD0CEe6EwC",
"quantity": 2,
"reference": "321-321",
"totalAmount": -999000,
"totalVatAmount": -199800,
"type": "physical",
"unitPrice": -499500,
"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
}
}
],
"refundedAmount": {
"amount": "9990.00",
"currency": "SEK",
"formatted": "9,990.00",
"formattedWithCurrency": "SEK 9,990.00",
"minorUnits": 999000
},
"riskProfile": {
"tags": []
},
"status": [
"fullyCaptured",
"partiallyRefunded"
],
"storeId": "970245072",
"uncaptured": null,
"uncapturedAmount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"updatedAt": "2023-02-15T08:58:38.929025Z"
}
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.
refunded
array of suborderA list of refunds.
refundedAmount
objectAn object containing strings amount
, currency
, formatted
, formattedWithCurrency
and integer minorUnits
.
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.
updatedAt
stringThe timestamp of the latest added event under events
.