Credit invoice endpoint not working as per docs

in Development
Hi,
The endpoint for creating a credit invoice is not working as per the docs (or at all). No matter what payload we send in (including a blank payload - which should credit the entire invoice according to the docs), we get the following error:
Error: Credit invoice be created. No items specified. +1s
Request data: {} +1ms
Response body: { error:
{ code: 400,
method: 'CREATE',
request: '/en/orders/106677092/credit.json',
message: 'Credit invoice be created. No items specified.' } }
Can this be fixed please, as our customers cannot do refunds via the API at the moment.
Thanks,
John
11 comments
Hi John,
I've taken a look at this and I've been able to create a credit invoice without any problems in my shop. I do see that the "send an empty payload" via the phpclient does not get accepted. I will make sure to update the documentation to reflect this.
Because of this it is required to send a payload according to the example that can be found in our documentation. I tested with the code below.
The orderProduct id that you have to specify in the orderProducts array can be found by querying the orders/{orderid}/products.json endpoint.
Hope this helps.
Tim
API Integrations Specialist
Lightspeed HQ
Hi Tim,
Thanks for the response, and for the php example - however I've tried this multiple different ways providing the correct product ID from the order/{orderid}/products.json endpoint, and I still cannot create a credit.
With this request body (using JSON this end):
{
"credit": {
"creditPayment": true,
"creditShipment": true,
"notifyNew": true,
"updateStock": true,
"orderProducts": [{
"quantity": 1,
"id": 214190495
}]
}
}
I always receive the response:
Error: Credit invoice be created. No items specified. +1s
Request data: {} +0ms
Response body: { error:
{ code: 400,
method: 'CREATE',
request: '/en/orders/107318285/credit.json',
message: 'Credit invoice be created. No items specified.' } }
Our request seems to fully match the JSON payload sample given in the docs{
"credit" : {
"creditPayment": true,
"creditShipment": true,
"notifyNew": true,
"updateStock": true,
"orderProducts" : [
{
"quantity" : 1,
"id" : 1354
}
]
}
}
I really don't see any difference in what we send and in what is in the example, so don't understand why it gives the error every time...
John
Hi John,
Could you send me the url of the shop you are trying this on? I will then check some things.
API Integrations Specialist
Lightspeed HQ
Thanks Tim - DM sent with the info
Hi, I've the same issue here, how did you solve the issue ?
Hi,
Can you send the payload you're using.
Hi,
here the payload:
{
"credit": {
"creditPayment": true,
"creditShipment": true,
"notifyNew": true,
"updateStock": true,
"orderProducts" : [
{
"quantity" : 1,
"id" : 44449542
}
]
}
}
Sended tu url /us/orders/10934571/credit.json
A product with the id 44449542 is in the order.
The payload looks good, what is the response you're getting?
Can you send me the shopID or url so that I can check some things.
The response I get is
{
"error": {
"code": 400,
"method": "CREATE",
"request": "/us/orders/10934571/credit.json",
"message": "Credit invoice be created. No items specified."
}
}
I send you the url and shop ID in DM
Hi @Flavien_Louis,
You'll need to get the ID from https://developers.lightspeedhq.com/ecom/endpoints/orderproduct/ and use this in your payload instead of the productID.
Perfect, it works !
I used product ID instead of OrderProduct ID !
Thx for help !