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:
- Set up Clover developer and test merchant accounts according to Clover documentation.
- Import sample inventory (https://docs.clover.com/docs/working-with-inventory)
- Order and receive Clover Mini 3 devkit, activate, associate with Merchant
- 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
- Create employee with manager role. Don't modify any other roles.
- Complete all steps to set up REST API access (https://docs.clover.com/docs/making-rest-api-calls)
- Verify you can retrieve orders from the REST API
- Log into the Clover Mini 3 with user account with appropriate r/w permissions to register and orders apps
- Create an order in the register app by adding Espresso Classics > Espresso (quantity 1). Then click "Save" to save the order.
- Open the Orders app and filter by "In Store Orders" to view the order you just created.
- Click to open the order and verify that the order can be opened and can be paid.
- 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.
- 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.
- 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.
- 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 }
- 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 }
- 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).
- Verify the order is created and a new ID is generated with a 200 OK response from the API
- 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. - 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.
- 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.
- 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.
- 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.
- 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.
- Log back into the Clover mini with a user/employee with appropriate permissions.
- Go to the Orders app
- Your will appear in the "Online Orders" filter of the column to the right.
- 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.
- 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."
Things I've tried:
- Reading the documentation: There is nothing in this REST API documentation that indicates that orders created using the REST API cannot be opened on the Clover device.
- Creating a minimal order with just { "state": "open" } as suggested by the documentation as the minimal payload https://docs.clover.com/docs/creating-custom-orders#set-order-state.
- Creating minimal order (as above) with single line item.
- Creating then updating orders
- Creating atomic orders (though the documentation states that this will not be available on the Clover device, so results were expected)
- Changing testMode to true in the JSON. No effect.
- Including or excluding the
- Deleting all other orders
- Checking for updates on the Clover mini (device is up to date)
- Performing another factory reset on the device.
- Reference the following help articles:
- https://community.clover.com/questions/1722/why-i-am-getting-current-order-has-been-deleted-wh.html: Verify that testMode is false and this is not being run on an emulator but an actual devkit device
- https://community.clover.com/questions/37977/order-submitted-through-api-shows-as-deleted.html: Verify no one deleted the order. Verify merchant is sharing accurate information (that is you, the developer when using repro steps above). Try atomic order (documentation states that this is not expected to achieve the goal I'm trying to achieve).
Use repro steps above to repro the problem. - https://community.clover.com/questions/12710/error-the-current-order-has-been-deleted.html: Verify the clover order Id exists in the system. Verify the order contains at least one line item that matches the amount of the order.
Use repro steps above to repro the problem. - https://community.clover.com/questions/9759/sdk-orderconnector-to-getmanagepay-rest-order.html Verify /v3/merchants/{mId}/orders/{orderId}/discounts is correct and matches the original order. Verify the results of all order lifecycle steps below match the valid order that we copied.
POST: /v3/merchants/{mId}/orders - Initial order creation
POST: /v3/merchants/{mId}/orders/{orderId} - Update the customers, orderType, note
POST: /v3/merchants/{mId}/orders/{orderId}/line_items - Add line items to order
POST: /v3/merchants/{mId}/orders/{orderId}/discounts - Add discounts to overall order
POST: /v3/merchants/{mId}/orders/{orderId} - Update total, state, taxRemoved - https://community.clover.com/questions/20670/orders-created-via-rest-api-shown-in-web-dashboard.html: Try updating the order setting "state": "open" again. Factory reset on the device. Recreate issue in Emulator. Can repro issue reliably. No resolution. Use repro steps above.
- https://community.clover.com/questions/2465/creating-an-order.html: Make sure the order "state" is not null.