Refund order (full)
This request will create a credit invoice with all order lines belonging to the ledgerId
parameter of the request.
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-9155-4721-b5f0-81945bff9e4a' \
https://api.sandbox.ledyer.com/v1/orders/:orderId/refund/: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
note
stringOptionalA note for the refund reason.
{
"authorizeStatus": "authorized",
"captured": [
{
"availableActions": [],
"createdAt": "2022-02-11T13:57:55.528553966Z",
"documentReference": "970245072092446903",
"documentUrl": "https://invoice.sandbox.ledyer.com/invoice-970245072-1",
"ledgerId": "in_24y1AG2dGQ6thv0YzRq0wglLU9T",
"note": "some reason",
"orderLines": [
{
"id": "ol_24y1AO9hoNLvovjAhJlrKk7ksg4",
"description": "APPLE iPhone 13 Pro 5G 256GB - 6.1\" Smartphone - Guld",
"quantity": 3,
"reference": "1336371",
"totalAmount": 4077000,
"totalVatAmount": 815400,
"type": "physical",
"unitPrice": 1359000,
"vat": 2500
},
{
"id": "ol_24y1AOwnAV8oSEp0nTwsjoGBaVO",
"description": "Shipping fee",
"quantity": 1,
"reference": "444-555-666",
"totalAmount": 10000,
"totalVatAmount": 2000,
"type": "shippingFee",
"unitPrice": 10000,
"vat": 2500
}
],
"status": [],
"totalOrderAmount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"totalOrderAmountExclVat": {
"amount": "32696.00",
"currency": "SEK",
"formatted": "32,696.00",
"formattedWithCurrency": "SEK 32,696.00",
"minorUnits": 3269600
},
"totalOrderVatAmount": {
"amount": "8174.00",
"currency": "SEK",
"formatted": "8,174.00",
"formattedWithCurrency": "SEK 8,174.00",
"minorUnits": 817400
},
}
],
"capturedAmount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"customer": { ... },
"createdAt": "2022-02-11T13:57:46.899097Z",
"events": [
{
"amount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"createdAt": "2022-02-15T08:14:41.651403Z",
"id": "oe_258dw0n4EgW1ezJAUUzFwkivuWj",
"ledgerId": "in_258dvy7QvgeYujLBVEXcT4IF6ez",
"orderId": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"type": "fullRefund"
},
{
"amount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"createdAt": "2022-02-11T13:57:55.528553Z",
"id": "oe_24y1BJkGLXJve0S2lait2vhTCzK",
"ledgerId": "in_24y1AG2dGQ6thv0YzRq0wglLU9T",
"orderId": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"type": "fullCapture"
},
{
"amount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"createdAt": "2022-02-11T13:57:47.899097Z",
"id": "oe_24y1ACVJ4DBpAmxDjJ7K8VCoeA3",
"ledgerId": "in_24y1AG2dGQ6thv0YzRq0wglLU9T",
"orderId": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"type": "readyForCapture"
},
{
"amount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"createdAt": "2022-02-11T13:57:46.899097Z",
"id": "oe_24y1ACVJ4DBpAmxDjJ7K8VCoeA3",
"ledgerId": "in_24y1AG2dGQ6thv0YzRq0wglLU9T",
"orderId": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"type": "create"
}
],
"expiresAt": "2022-02-25T13:57:46.899097Z",
"id": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"merchantId": "ac_1xWqkkS5aIbxCJsoseRhSd0OJyD",
"merchantReference": "or_24y19msU3GktrNI8mKOdIUcfBSX",
"orderAmount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"orderReference": "LRLFHZ2Y",
"paymentMethod": {
"provider": "ledyer",
"type": "advanceInvoice"
},
"refunded": [
{
"availableActions": [],
"createdAt": "2022-02-15T08:14:41.651403Z",
"documentReference": "970245072092446999",
"documentUrl": "https://invoice.sandbox.ledyer.com/invoice-970245072-2",
"ledgerId": "in_258dvy7QvgeYujLBVEXcT4IF6ez",
"note": "some reason",
"orderLines": [
{
"id": "ol_24y1AO9hoNLvovjAhJlrKk7ksg4",
"description": "APPLE iPhone 13 Pro 5G 256GB - 6.1\" Smartphone - Guld",
"quantity": 3,
"reference": "1336371",
"totalAmount": -4077000,
"totalVatAmount": -815400,
"type": "physical",
"unitPrice": -1359000,
"vat": 2500
},
{
"id": "ol_24y1AOwnAV8oSEp0nTwsjoGBaVO",
"description": "Shipping fee",
"quantity": 1,
"reference": "444-555-666",
"totalAmount": -10000,
"totalVatAmount": -2000,
"type": "shippingFee",
"unitPrice": -10000,
"vat": 2500
}
],
"status": [],
"totalOrderAmount": {
"amount": "-40870.00",
"currency": "SEK",
"formatted": "-40,870.00",
"formattedWithCurrency": "-SEK 40,870.00",
"minorUnits": -4087000
},
"totalOrderAmountExclVat": {
"amount": "-32696.00",
"currency": "SEK",
"formatted": "-32,696.00",
"formattedWithCurrency": "-SEK 32,696.00",
"minorUnits": -3269600
},
"totalOrderVatAmount": {
"amount": "-8174.00",
"currency": "SEK",
"formatted": "-8,174.00",
"formattedWithCurrency": "-SEK 8,174.00",
"minorUnits": -871400
},
}
],
"refundedAmount": {
"amount": "40870.00",
"currency": "SEK",
"formatted": "40,870.00",
"formattedWithCurrency": "SEK 40,870.00",
"minorUnits": 4087000
},
"riskProfile": {
"tags": []
},
"status": [
"fullyCaptured",
"fullyRefunded"
],
"storeId": "970245072",
"uncapturedAmount": {
"amount": "0.00",
"currency": "SEK",
"formatted": "0.00",
"formattedWithCurrency": "SEK 0.00",
"minorUnits": 0
},
"uncaptured": null,
"updatedAt": "2022-02-15T08:14:41.651403Z"
}
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
, in case of a full refund the amount will be what was previously captured.
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
nullIn case of a full refund request the uncaptured
object will come back empty as null
.
updatedAt
stringThe timestamp of the latest added event under events
.