question

bcdi avatar image
bcdi asked cr565 commented

Orders created by REST API encounter "Error The current order has been deleted" when opened on Clover Mini 3

Problem:

When creating an order using the Clover REST API, the order cannot be opened on the Clover device and an error is displayed "Error The current order has been deleted." however the order appears on the Clover device, in the Merchant dashboard, and is successfully retrieved from the API from the endpoint /v3/merchants/{mId}/orders

Overview:

I want to be able to create an order from the API so that it can be paid on the device using a card.

Given the information in this post, does anyone know if what I'm trying to achieve is possible, and, if so, what one needs to do to achieve it successfully?

Setup information:

  • Device: Clover Mini 3 (Clover C305), software version 10 (5050735) (ordered February 2023)
  • Clover developer account
  • Clover test merchant account

Repro steps:

  1. Set up Clover developer and test merchant accounts according to Clover documentation.
  2. Import sample inventory (https://docs.clover.com/docs/working-with-inventory)
  3. Order and receive Clover Mini 3 devkit, activate, associate with Merchant
    1. If you have already completed this, do a factory reset on the device and re-associate it to ensure you're starting with a known good, clean state
  4. Create employee with manager role. Don't modify any other roles.
  5. Complete all steps to set up REST API access (https://docs.clover.com/docs/making-rest-api-calls)
  6. Verify you can retrieve orders from the REST API
  7. Log into the Clover Mini 3 with user account with appropriate r/w permissions to register and orders apps
  8. Create an order in the register app by adding Espresso Classics > Espresso (quantity 1). Then click "Save" to save the order.
  9. Open the Orders app and filter by "In Store Orders" to view the order you just created.
  10. Click to open the order and verify that the order can be opened and can be paid.
  11. Query the API endpoint and verify the order appears in the query. ensure testMode is set to false (https://community.clover.com/questions/1722/why-i-am-getting-current-order-has-been-deleted-wh.html). Copy the JSON structure of the order.
  12. Query the API endpoint for /v3/merchants/{mId}/orders/{orderId}/line_items?display_null_fields=true to verify the order line items. Copy the JSON structure of the line items.
  13. At this point, we now have confirmed that orders created on the device are valid, can be opened on the device and queried from the REST API.
  14. Use the valid order and create it again using the API. According to the documentation, you must create the order first then add the line item(s). Modify the Order JSON that you copied to remove the following fields:
    - href
    - id
    - createdTime
    - clientCreatedTime
    - modifiedTime

    Change the "total" field to be 199 so it matches the line item you will add below.

    The modified JSON should look like this (note, the IDs of your employee, orderType, device may be different than what is below.
    {
      "currency": "USD",
      "employee": {
        "id": "{employeeId-redacted}"
      },
      "total": 199,
      "externalReferenceId": null,
      "unpaidBalance": null,
      "paymentState": "OPEN",
      "title": null,
      "note": null,
      "orderType": {
        "id": "NQTQHPWD6D5KG",
        "labelKey": null,
        "label": null,
        "taxable": null,
        "isDefault": null,
        "filterCategories": null,
        "isHidden": null,
        "fee": null,
        "minOrderAmount": null,
        "maxOrderAmount": null,
        "maxRadius": null,
        "avgOrderTime": null,
        "hoursAvailable": null,
        "customerIdMethod": null,
        "isDeleted": null,
        "systemOrderTypeId": null,
        "hours": null
      },
      "taxRemoved": false,
      "isVat": false,
      "state": "open",
      "manualTransaction": false,
      "groupLineItems": true,
      "testMode": false,
      "payType": null,
      "deletedTimestamp": null,
      "serviceCharge": null,
      "device": {
        "id": "{deviceId-redacted}"
      },
      "merchant": null,
      "onlineOrder": null,
      "orderFulfillmentEvent": null
    }
  15. Modify the order line items JSON so it can be posted as a new line item for your new order.
    You will be posting a single line item so remove everything except the first (only) element in the "elements" array. Remove the following fields:
    - id
    - createdTime
    - orderClientCreatedTime

    Your resulting JSON should look like this (note: you will obtain orderRef id after creating the order in a later step; item id may be different than below)
    {
        "orderRef": {
            "id": "{paste-orderId-after-creating-order-below}"
        },
        "item": {
            "id": "TSTP135BY93Z6"
        },
        "name": "Espresso",
        "alternateName": "",
        "price": 199,
        "itemCode": "",
        "printed": false,
        "exchanged": false,
        "refunded": false,
        "isRevenue": true
    }
  16. Create the order by POSTING the payload to the endpoint https://docs.clover.com/docs/creating-custom-orders#create-an-order. Be sure testMode is set to false and state is set to "open" (these should be unchanged from the order you copied from).
  17. Verify the order is created and a new ID is generated with a 200 OK response from the API
  18. Copy the id. Add it as the value of the orderRef.id field in the line_items payload. You will also use it in the url of the line_items endpoint. Post the line_items payload to the endpoint (https://docs.clover.com/docs/creating-custom-orders#add-order-line-items).

    /v3/merchants/{ {CLOVER_MERCHANT_ID}}/orders/{orderId}/line_items

    Ensure: you get a 200 OK response, the line item was added and given an id, the order ref id and id in the url match the order you created.
  19. At this point, we have used the data from an order that was created, valid and accessible in the Clover mini and re-created a copy of that order using the REST API.
  20. Query the orders endpoint to ensure your newly-created order is present. Note: do not query by the order id. Query all the orders to ensure it appears.
  21. Query the line_items endpoint and verify that the line item you created (one element in the elements array) is present with the matching orderId.
  22. Log into your Clover merchant dashboard as a user with proper permissions to view orders. Navigate to Orders. In "Date Range" section, click the "Last 7 days" filter.
  23. Verify your newly-created API order is there with the matching ID. Click "details" and verify you can view the details and they are correct. Click "Receipt" and verify the receipt is rendered and is correct.
  24. Log back into the Clover mini with a user/employee with appropriate permissions.
  25. Go to the Orders app
  26. Your will appear in the "Online Orders" filter of the column to the right.
  27. Verify your order appears in the list with the matching Id. Note: you may have to tap the "sync" button to force the Mini to refresh from the Clover merchant database.
  28. At this point, you have verified that the order is NOT deleted, it appears in the API query, the merchant dashboard and on the Clover mini device.

    EXPECTED: user should be able to tap the order to open it on the Clover device to view the order and complete payment on it.

    ACTUAL: A modal dialog appears with the title "Error" and the body "The current order has been deleted."

1685108580081.png

Things I've tried:

OrdersREST API
1685108580081.png (502.2 KiB)
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

bryanvargas avatar image bryanvargas ♦♦ commented ·
Hey I am unable to reproduce this error. I followed your steps 3 times and was able to successfully open the order on the device. Do you mind sending me your test merchant ID and developer ID in secure message for me to check some logs for you.
0 Likes 0 ·

1 Answer

·
cr565 avatar image
cr565 answered bryanvargas commented

I also encounter the same error on Sandbox. It's working fine on production but not on Sandbox.

Here's more info on what's happening behind the scenes in case it helps.

This is what the emulator shows when inspecting with `adb logcat`

I/SetupAsyncTask( 3722): onPostExecute(SetupAsyncTask.java:73)[main]: OrderManageActivity @389430a2 isFinishing: false, resumed: true
I/OrderManageActivity( 3722): completeSetup(CommonActivity.java:416)[main]: @389430a2
I/SetupAsyncTask( 3722): onPostExecute(SetupAsyncTask.java:115)[main]: OrderManageActivity @389430a2 setup tasks took: 72ms
I/OrdersProvider( 1775): onPerformSync(SyncProvider.java:356)[Binder_E]: Got server token: 0 for com.clover.orders
I/LogInterceptor( 1775): Executing request GET https://apisandbox.dev.clover.com/v3/merchants/D5XDBFJ2JAK41/orders/GVNSG9KFZFEHA/?autoExpand=true&limit=50...
I/OrdersActivity( 3722): onStop(CommonActivity.java:1159)[main]: @1b6fce3f +onStop
I/OrdersActivity( 3722): onStop(CommonActivity.java:1171)[main]: @1b6fce3f -onStop
I/LogInterceptor( 1775): Execution complete of request GET https://apisandbox.dev.clover.com/v3/merchants/D5XDBFJ2JAK41/orders/GVNSG9KFZFEHA/?autoExpand=true&limit=50 in 114.5ms, status: 500 (Internal Server Error)


The GET is failing and I'm pretty sure that the `autoExpand=true` query param is broken on Sandbox:

GET https://apisandbox.dev.clover.com/v3/merchants/D5XDBFJ2JAK41/orders/GVNSG9KFZFEHA/?autoExpand=true&limit=50 in 114.5ms, status: 500 (Internal Server Error)


Screenshot with evidence:

500 error when using the autoExpand=true query param.

1685140279408.png

200 response when not using the query param

1685140320794.png


1685140279408.png (140.8 KiB)
1685140320794.png (273.4 KiB)
3 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

parquet76 avatar image parquet76 commented ·
Clover better take a serious look at this soon, because what is in sandbox now will be in production soon (I would guess). @bryan.vargas
0 Likes 0 ·
bryanvargas avatar image bryanvargas ♦♦ commented ·
Hey I was unable to reproduce this. But I checked the logs and it was having trouble accessing the database. Do you mind trying again to see if you still have this error.
0 Likes 0 ·
cr565 avatar image cr565 bryanvargas ♦♦ commented ·

Tried again now and got the same error

I/LogInterceptor( 1795): Execution complete of request GET https://apisandbox.dev.clover.com/v3/merchants/D5XDBFJ2JAK41/orders/GVNSG9KFZFEHA/?autoExpand=true&limit=50 in 100.7ms, status: 500 (Internal Server Error)

1685469703338.png

0 Likes 0 ·
1685469703338.png (160.6 KiB)

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community