Idempotency-Key string A unique key for safely retrying a request without duplicating work.
This request creates a credit invoice using only the order lines in the request body. totalRefundAmount must equal the sum of the included order line totalAmount values.
An order must contain captured order lines for a refund to succeed, since ledgerId is taken from captured. To check whether refund is available, inspect availableActions on the sub-order chunk in the GET order 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 Idempotency-Key string ledgerId string orderId string orderLines array description string quantity integer reference string Optional totalAmount integer totalVatAmount integer type string unitDiscountAmount integer Optional unitPrice integer vat integer totalRefundAmount integer note string Optional {
"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 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. - extendExpiry: 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 integer totalOrderAmountExclVat integer totalOrderVatAmount integer 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.updatedAt string