question

aadel avatar image
aadel asked ·

Orders Not Created By Create Order REST API On Sandbox

Hi,

We are trying to create orders using REST API. Sending a POST request to create order REST API

https://apisandbox.dev.clover.com/v3/merchants/T4N...

with the following body:

{ 
	"customers": [ 
		{
		  "id": "83D4...", 
		  "merchant": {"id": "T4NX..."},
		  "metadata": {},
		  "state": "open"
		}
	]
}
Returns the following 200 OK response:
{
	"href": "...",  
	"id": "G6R2...",
	"currency": "USD",
	"employee": { "id": "T5B6..."  },
	"taxRemoved": false,
	"isVat": false,
	"manualTransaction": false,
	"groupLineItems": true,
	"testMode": false,
	"createdTime": 1552932177000,
	"clientCreatedTime": 1552932177000,
	"modifiedTime": 1552932176000
}
However, querying Orders REST API following this call returns the following response:
{
  "elements": [],
  "href": "http://apisandbox.dev.clover.com/v3/merchants/T4NX.../orders?filter=stateIS%20NOT%20NULL&limit=100"
}
Also, displaying Orders from the sandbox merchant panel returns no orders. Could you please advise?

Thanks!

UPDATE

Modifying the request body to

{
	"currency": "USD",
	"customers":[
		{
		  "id": "83D4...",
		  "merchant": {"id": "T4NX..."},
		  "metadata": {}
		}
	],
	"employee": {"id": "CVPV..."},
	"total": 1900,
	"state": "open"
}
created the order successfully.
OrdersSandboxREST API
10 |2000 characters needed characters left characters exceeded

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

1 Answer

zgreathouse avatar image
zgreathouse answered ·
This request body is invalid for creating an order. Additionally, you cannot initialize an order with a customer. The order must already be created before making the association between the order and the customer.

To create an order you would use the following endpoint and request body:
POST "https://apisandbox.dev.clover.com/v3/merchants/mId/orders"
//minimum required field
{
	"state": "open"
}

To associate a customer with an order you would use the following endpoint and request body:
POST "https://apisandbox.dev.clover.com/v3/merchants/mId/orders/orderId"
{
	"customers": [
		{ "id": "*************" }
	]
}
Share
10 |2000 characters needed characters left characters exceeded

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