Credit invoice endpoint not working as per docs

JohnCountrJohnCountr Member Posts: 3

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

4 comments

  • TimBloembergenTimBloembergen Moderator, Lightspeed Staff Posts: 38 moderator

    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.

    $order_id = 105393920;
    
    $r = $api->ordersCredit->create($order_id, [
        "creditPayment" => false,
        "creditShipment"=> false,
        "notifyNew"     => true,
        "updateStock"   => true,
        "orderProducts" => [
            [
                "quantity" => 1,
                "id" => 210245747
            ]
        ]
    ]);
    
    echo '<pre>';
    print_r($r);
    echo '</pre>';
    

    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

    Tim Bloembergen
    API Integrations Specialist
    Lightspeed HQ
  • JohnCountrJohnCountr Member Posts: 3

    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

  • TimBloembergenTimBloembergen Moderator, Lightspeed Staff Posts: 38 moderator

    Hi John,

    Could you send me the url of the shop you are trying this on? I will then check some things.

    Tim Bloembergen
    API Integrations Specialist
    Lightspeed HQ
  • JohnCountrJohnCountr Member Posts: 3

    Thanks Tim - DM sent with the info

Sign In or Register to comment.