Idempotency-Key string A unique key for safely retrying a request without duplicating work.
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.
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 Idempotency-Key string ledgerId string orderId string note string Optional {
"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 A list of order event snapshots. Each event includes an amount object with amount, currency, formatted, formattedWithCurrency, and minorUnits, plus createdAt, orderId, ledgerId, and type.
Supported type values:
acknowledge: Order has been acknowledged.authorize: Order has been authorized.cancel: Order has been cancelled.create: Order has been created.edit: Order lines and related order details have been edited since
first authorization.editCustomer: Customer details have been edited.editPaymentMethod: Payment method has been changed.extendExpiry: Order expiry has been extended at least once.fullCapture: All order lines have been captured.fullRefund: All order lines have been added to a credit invoice.invoiceRecourse: The customer paid the invoice directly to the
merchant.paid: Order has been paid.partialCapture: Some order lines have been captured.partialRefund: Some order lines have been added to a credit invoice.readyForCapture: Order has been made ready for capture.setReference: Merchant order reference has been updated.refunded array availableActions array type property that describes an available action. The following types can be listed: - cancel: The order can be cancelled. - capture: The order can be fully
captured. - editCustomer: The customer details of the order can be
edited. - editOrder: The order lines can be edited. - editPaymentMethod: The payment method of the order can be edited. - extendOrderExpiry:
The expiry date of the order can be extended. - partialCapture: The order
can be partially captured. - partialRefund: The order can be partially
refunded. - recourseOrderInvoice: The captured invoice can be marked as
paid directly to the merchant. - refund: The order can be fully refunded.createdAt string ledgerId string documentReference string Optional documentUrl string Optional note string Optional orderLines array description string quantity integer reference string Optional totalAmount integer totalVatAmount integer type string unitDiscountAmount integer Optional unitPrice integer vat integer status array totalOrderAmount object totalOrderAmountExclVat object totalOrderVatAmount object refundedAmount object status array of strings 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 null updatedAt string