How to set orders to status "completed" with api?

teamsoftteamsoft Posts: 6Member
Helle everyone,

I wonder how we can update the shipment status or payment status of an order with api to get an order to the status completed. We do not use SEOshop invoices or so, but we don't mind if such invoices will be created. We just don't want to update the backend manually when we ship a product with our erp.

Thank you for your assistance.

Heiko

Best Answer

Answers

  • Alex LugoAlex Lugo Posts: 98Administrator, Lightspeed Staff moderator
    Hello @teamsoft,

    This is possible using our Order endpoint. Use the link below to access our API documentation, you'll find some code examples.

    https://developers.lightspeedhq.com/ecom/endpoints/order/#put-update-an-order
    Alex Lugo
    API Support Specialist
    Lightspeed HQ
  • teamsoftteamsoft Posts: 6Member
    Thank you Alex for your reply.

    Unfortunately this is not working at all. I try to update the order, but without any effect and no error returning. Neither shipmentStatus nor status can be changed as described on your site. Even the named example shows, that it is not working, for you are updating the status of the order to cancelled and the return shows the order is still reporting "processing_awaiting_shipment"...

    Maybe you can check this?

    Best Regards,
    Heiko
  • Adrian SamuelAdrian Samuel Posts: 368Moderator, Lightspeed Staff moderator
    @teamsoft could you send us an example payload along with the response obtained 
  • teamsoftteamsoft Posts: 6Member
    @Adrian Samuel Thank you for your assistance. Please tell me, how I shall send you the data. I don't like to post real shop data on a (more or less) public board.
  • TimBloembergenTimBloembergen Posts: 38Moderator, Lightspeed Staff moderator
    @teamsoft

    To complete an order the Payment needs to be set to 'paid' and the shipment needs to be updated to 'shipped'.
    When both of these fields are set to those values the order will be automatically be set to 'completed'.
    Tim Bloembergen
    API Integrations Specialist
    Lightspeed HQ
  • MarcoKMarcoK Posts: 4Member

    @TimBloembergen :

    I tried several ways to Update an Order... Its not working... Can you pleas help?

    Everytime I get Statuscode 200 - OK, but nothing change to my order...

    Is there another way, to add a shipment oder payment to an order?

    Thanks for your assistance!!


    My Code in C#:

                var url = $"https://{api_key}:{api_secret}@{api_base_cluster_url}/orders/{_orderId}.json";

          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

          request.Method = "PUT";

          request.Credentials = new NetworkCredential(api_key, api_secret);

          request.PreAuthenticate = true;

          request.ContentType = "application/json";


          //Not working...

          var json = "{ \"order\": { \"shipmentStatus\": \"shipped\" } }";


          //Not working too...

          //var json = "{ \"order\": { \"paymentStatus\": \"paid\", \"shipmentStatus\": \"shipped\" } }";


          using (var writer = new StreamWriter(request.GetRequestStream()))

          {

            writer.Write(json);

            writer.Flush();

            writer.Close();

          }


          var response = new HttpResponseMessage();


          using (var responseApi = (HttpWebResponse)request.GetResponse())

          {

            using (var reader = new StreamReader(responseApi.GetResponseStream()))

            {

              var objText = reader.ReadToEnd();

              var objJson = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(objText);

              response.Content = new StringContent(objText);

            }

          }

  • teamsoftteamsoft Posts: 6Member

    @TimBloembergen@MarcoK

    It's been a while since I've had enough time for development, but I can confirm that it is impossible to change shipmentStatus or paymentStatus in anyway using the api.


    Best Regards


    Heiko Wrede

  • TimBloembergenTimBloembergen Posts: 38Moderator, Lightspeed Staff moderator

    @teamsoft @MarcoK

    I've just tested this myself and I am able to update both the shipment and invoice to paid and shipped so the order gets completed. You need to make sure the order you want to update has an invoice and a shipment. If both are not present you cannot update them.

    I've used the following endpoint and payload.

    Endpoint: https://api.webshopapp.com/nl/orders/{orderid}.json
    
    Payload:
    {
      "order": {
          "paymentStatus": "paid",
          "shipmentStatus": "shipped"
      }
    }
    
    Tim Bloembergen
    API Integrations Specialist
    Lightspeed HQ
  • MarcoKMarcoK Posts: 4Member

    Thanks @TimBloembergen !

    Can you tell me how i can set an invoice and/or shippment for an order?

    The PUT function of "Update a shipment" or "Update an invoice" doesn't have an orderId value?

  • TimBloembergenTimBloembergen Posts: 38Moderator, Lightspeed Staff moderator
    edited March 15

    @MarcoK

    I just had a quick look in your shop and your orders do not get their invoices created right away when the order gets placed.

    Your invoice setting is set to "manual" this means that you always have to create invoices and shipments manually for your orders. If you would create them in the Backoffice first and then send the API request you will see that they both get updated.

    If you want to change the setting you can navigate to Settings/Administration page in the Backoffice.

    Invoices and shipments cannot be created via the API.

    Tim Bloembergen
    API Integrations Specialist
    Lightspeed HQ
  • MarcoKMarcoK Posts: 4Member

    @TimBloembergen : Thanks !!

    I set this to manual because the invoices are created in another system. When i set the switch to "direct" the customer gets the invoice form lightspeed in first mail. How can i disable that the customer gets the invoice from lightspeed?

  • teamsoftteamsoft Posts: 6Member

    We have a seperated ERP system for generating invoices, too. I wonder, if it is somehow possible to get the correct invoice number transfered from our ERP into our shop so the numbers don't run asynch. We generate much more invoices in our ERP than we get orders in our shop, so not every invoice number will have an invoice in the shop system. So unfortunately it will be not that easy just to set the counter to the right starting value, because there have to be serveral numbers skipped for each invoice in the shop system. Any help concerning this will be appriciated, too.

  • teamsoftteamsoft Posts: 6Member

    @TimBloembergen

    I've just realized, your answer is the answer to my original question too. For we don't generate invoices automatically. Using a seperate ERP system we don't need to generate invoices or shipments in the Lightspeed shop at all. We just do this, to get the orders set to the status "completed". So I tried to update the shipmentStatus and the paymentStatus without generating an invoice or shipment in the Lightspeed shop system for we don't need them (and as stated above get the wrong invoice numbers too). But then the answer is, that the order status cannot be updated to "shipped" or "payed" without generating an invoice in the Lightspeed shop, is this correct?

  • MarcoKMarcoK Posts: 4Member

    @TimBloembergen : I found out how to solve my problem. Thanks for your support.

Sign In or Register to comment.