Payment endpoint returns 400 Bad Request

juliandjuliand Member Posts: 9

We are calling https://api-trial.ikentoo.com/o/op/1/pay with the following request, but it is returning a fail message "org.springframework.web.reactive.function.client.WebClientResponseException$BadRequest: 400 Bad Request from PUT http://backend:8086/integration/1/payments". Can you point us in the right direction please?\

{

"iKaccountIdentifier": "A54602.37",

"thirdPartyPaymentReference": "ReferenceFromStripe",

"endpointId": "FETCH",

"businessLocationId": 940967205011458,

"staffId": 163811,

"paymentMethod": "CASH",

"paymentAmount": 1.00,

"tipAmount": 0

}

Tags:

Answers

  • YorickYorick Moderator, Lightspeed Staff Posts: 112 moderator

    Hello,

    Your account was not setup to apply API payment, could you please try again now?

    Make sure the iPad is up to date and at the bottom right corner of the ordering screen, tap the reload logo to make sure the last configuration is on the iPad. Then tap the four dots and make sure the shopping bag logo is green.

    Thank you.

    API integration specialist
    Lightspeed HQ
  • juliandjuliand Member Posts: 9

    Hi Yorick,

    Thanks we are getting a "status": "ok" response back from the payment endpoint now, however when we call order/table/getCheck we don't see the payment reflected on the check. The payment fields remain empty, i.e. "paidAmount": "0.00" and "paymentEntries": [].

    Any idea why the payment might not be showing on the check?

    Thanks

    Julian

  • TrungTrung Member, Moderator, Lightspeed Staff Posts: 28 moderator

    Hi @juliand,

    Your payload contains a typo; there's an extra A in the iKaccountIdentifier.

    "iKaccountIdentifier": "AA54602.88" instead of "iKaccountIdentifier": "A54602.88".

    On a side note, did you register a webhook endpoint to receive notifications about order updates from this article https://redoc.lsk.lightspeed.app/#tag/Order-and-Pay/operation/createWebhookOo? This will allow you to receive a notification letting you know whether the payment was applied successfully.

  • juliandjuliand Member Posts: 9

    Hi Trung,

    We have tried putting an extra A at the front of the iKaccountIdentifier but it is still not adding any payment records to the order. It looks like it should only be one A, judging by the getCheck response:

    [
        {
            "clientCount": 2,
            "uuid": "42c99fec-efd2-4a0b-be09-e352d08c24fb",
            "openDate": "2022-07-04T04:28:38.815+0000",
            "paidAmount": "0.00",
            "name": "Floor 1, Table 3",
            "currentAmount": "14.08",
            "staffName": "Manager",
            "staffId": 163811,
            "salesEntries": [...],
            "paymentEntries": [],
            "ikaccountId": "A54602.95",
            "tableNumber": 3,
            "posId": 54602
        },
    

    In the above example I have tried A54602.95 and AA54602.95 in the "iKaccountIdentifier" field of the payment call but neither is going through. "paymentEntries" remains empty and "paidAmount" remains at 0. For reference, here is the latest attempt:

    {
      "iKaccountIdentifier": "AA54602.95",
      "thirdPartyPaymentReference": "AA54602.95.1",
      "endpointId": "FETCH",
      "businessLocationId": 940967205011458,
      "staffId": 163811,
      "paymentMethod": "FETCH",
      "paymentAmount": 1.00,
      "tipAmount": 0
    }
    

    And the response:

    {
      "status": "ok"
    }
    
  • TrungTrung Member, Moderator, Lightspeed Staff Posts: 28 moderator

    Hi @juliand,

    Could you try redoing the process from scratch? I just logged in to your account -> Created a new receipt "A54929.1" from an iPad -> Applied the following payload for the payment:

    {
      "iKaccountIdentifier": "A54929.1",
      "thirdPartyPaymentReference": "11111",
      "endpointId": "FETCHTRUNG",
      "businessLocationId": 940967205011458,
      "paymentMethod": "FETCH",
      "paymentAmount": 1.00,
      "tipAmount": 0
    }
    

    This resulted in the expected behaviour. Can you try it on your end and let me know?

  • juliandjuliand Member Posts: 9

    Hi Trung,

    Interesting... I don't see A54929.1 in my list of open orders. Furthermore, when I tried to specify FETCHTRUNG in my endpointId I got the message "This webhook endpoint id belongs to another integration".

    It looks like we are using the same businessLocationId but somehow on different systems! Here is my full curl request in case it has any clues about how we are seeing different things:

    curl --location --request POST 'https://api-trial.ikentoo.com/o/op/1/pay' \
    --header 'Authorization: Bearer 10b2552a-6cea-49eb-a8d7-342325368be2' \
    --header 'Content-Type: application/json' \
    --data-raw '{
      "iKaccountIdentifier": "A54602.95",
      "thirdPartyPaymentReference": "A54602.95.1",
      "endpointId": "FETCHTRUNG",
      "businessLocationId": 940967205011458,
      "paymentMethod": "FETCH",
      "paymentAmount": 1.00,
      "tipAmount": 0
    }'
    

    Here is the full response:

    {
        "timestamp": "2022-07-04T15:25:40.668+0000",
        "status": 403,
        "error": "Forbidden",
        "message": "This webhook endpoint id belongs to another integration",
        "path": "/o/op/1/pay"
    }
    

    Here is the curl request for pulling back orders:

    curl --location --request GET 'https://api-trial.ikentoo.com/o/op/1/order/table/getCheck?businessLocationId=940967205011458' \
    --header 'Authorization: Bearer 10b2552a-6cea-49eb-a8d7-342325368be2'
    

    And here is the response where I don't see your order A54929.1:

    [
        {
            "clientCount": 2,
            "uuid": "42c99fec-efd2-4a0b-be09-e352d08c24fb",
            "openDate": "2022-07-04T04:28:38.815+0000",
            "paidAmount": "0.00",
            "name": "Floor 1, Table 3",
            "currentAmount": "14.08",
            "staffName": "Manager",
            "staffId": 163811,
            "salesEntries": [...],
            "paymentEntries": [],
            "ikaccountId": "A54602.95",
            "tableNumber": 3,
            "posId": 54602
        },
        {
            "clientCount": 2,
            "uuid": "ee6eb0f1-7fc7-4582-827a-1c4f3ee19a99",
            "openDate": "2022-07-04T04:28:38.868+0000",
            "paidAmount": "0.00",
            "name": "Floor 1, Table 5",
            "currentAmount": "81.58",
            "staffName": "Manager",
            "staffId": 163811,
            "salesEntries": [...],
            "paymentEntries": [],
            "ikaccountId": "A54602.96",
            "tableNumber": 5,
            "posId": 54602
        },
        {
            "clientCount": 2,
            "uuid": "36a27687-0831-4911-af15-5fe32b7512c9",
            "openDate": "2022-07-04T04:28:38.962+0000",
            "paidAmount": "0.00",
            "name": "Floor 1, Table 8",
            "currentAmount": "45.03",
            "staffName": "Manager",
            "staffId": 163811,
            "salesEntries": [...],
            ],
            "paymentEntries": [],
            "ikaccountId": "A54602.97",
            "tableNumber": 8,
            "posId": 54602
        }
    ]
    


  • TrungTrung Member, Moderator, Lightspeed Staff Posts: 28 moderator

    Hi @juliand ,

    You will not be able to retrieve information on the endpoint I created due to that webhook being attached to the client I used to create it. However, the endpointId you created should work independently of mine.

    As for retrieving the order I created, you can use either of these endpoints:

    /f/finance/{{businessLocationId}}/saleByExternalReference?externalReferenceId=TASK:11111

    or

    /f/finance/{{businessLocationId}}/sale?accountId=A54929.1

  • juliandjuliand Member Posts: 9

    Hi Trung,

    We don't have access to the finance scope which means we can't call the endpoint above. We only have access to the orders-api scope. Maybe that's why payments aren't working either? Here are the steps I am following from the very beginning, including creating the webhook. I'm still not getting any notifications on the web hook or an updated payment entry on the order.

    1. Webhook created at https://webhook.site/#!/3f34a37b-39e2-4390-b831-70d0c18d495c

    2. Register webhook in the K-Series API:

    3. Verify the ikaccountId of order A54602.115:

    4. Make a payment to order A54602.115:

    5. Wait a few minutes

    6. Check for any callback on the webhook (none received):

    7. Check for any payment entries on order A54602.115 (none received):


  • TrungTrung Member, Moderator, Lightspeed Staff Posts: 28 moderator

    Hi @juliand,

    You should still be able to able to apply payments to an open order even without the financial scope.

    After checking our logs, the reason why it's not working is because you are trying to apply the payment to a transitory order. Transitory orders are carried-over orders that have not been closed within the same business day (i.e. from 5:30 AM to 4:59 AM local time). As such, could I ask you to retry these steps but making sure that the payment is applied on the same day?

    Lastly, I recommend that you update your webhook to provide accounts, transactions and payments information:

    POST /o/wh/1/webhook

    with the following body:

    {
     "endpointId": {{endpointID}},
     "url": {{webhookUrl}},
     "withBasicAuth": false,
     "username": null,
     "password": null,
     "provideAccount": true,
     "expandTransactions": true,
     "expandPayments": true
    }
    


  • juliandjuliand Member Posts: 9
    edited July 11

    Hi Trung,

    Thanks for bearing with us.

    Unfortunately your last advice doesn't seem to have made any difference. We created a webhook to provide accounts, transactions and payments information and posted a fresh order from the iPad to ensure that the payment was taking place on the same day. We still haven't received any posts to the webhook nor has the order been updated with the payment details. Can you please check the logs for A54602.142?

    A few screenshots below for your reference:

    Creating the new webhook:

    Applying the payment to order A54602.142:

    Checking order A54602.142 for payment entries:

    Checking webhook for callbacks:


  • TrungTrung Member, Moderator, Lightspeed Staff Posts: 28 moderator

    I am unable to reproduce the issue but I am seeing that your attempts failed from our logs.

    Just to get some housekeeping out of the way, can you confirm that:

    • You have at least one iPad that is online and connected to K-Series?
    • Are all the devices running the latest backoffice configuration? You can update the device config by reloading the device from this article.

    Furthermore, which endpointId are you using? I'm seeing multiple ones on my end (FETCHBIJAAY, FETCHJD).

    Lastly, here are the steps I did which resulted in the expected result.


  • juliandjuliand Member Posts: 9

    Hi Trung,

    We seem to be able to make payments more reliably now, I think it came down to the iPad and making sure it stayed online and connected to K-Series. Thanks so much for your help!

Sign In or Register to comment.