question

questioner avatar image
questioner asked ·

How do I add customers to orders using the web api

I have tried many ways of creating orders with customer IDs but the customer ID is always ignored or causes an error.

API /v3/merchants/{mId}/orders/{orderId}

{"customers:["VA48NN5QQVH1G"],"total":5000} <- causes error

{"customers:"VA48NN5QQVH1G","total":5000}

{"customers":[{"id":"VA48NN5QQVH1G"}],"total":5000}.

The first method throws this error:

'Invalid value in JSON: Can not instantiate value of type [simple type, class com.clover.server.data.customers.Customer] from String value ('VA48NN5QQVH1G'); no single-String constructor/factory method at [Source: N/A; line: -1, column: -1] (through reference chain: com.clover.server.data.order.Order["customers"]->java.util.ArrayList[0])'

UPDATE: Documentation has changed for get single order, it now refers to "customerId": "long". I attempted to use this and it failed. Also customer IDs are hashes instead of long integers so that may be the problem.

OrdersCustomers
1 comment
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.

moving to answer

0 Likes 0 · ·
Dan avatar image
Dan answered ·

This is a sample of how to add a customer to an order that has already been created. It looks like you need a bit more information in your customers portion of your request. /v3/merchants/1RXK2PBVRGCDA/orders/22GRFFW2FJ2SE POST {"state":"open","customers":{"elements":[{"marketingAllowed":false,"firstName":"John","id":"F8KNWQJZQP4NE","lastName":"Doe"}]},"employee":{"id":"K3KXSTZE7D7T8"},"clientCreatedTime":1472695543031,"createdTime":1472695543031}

1 comment 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.

I just tried your method and no luck, what you are suggesting doesn't match the documentation. Also note that i'm not adding a new customer. I'm connecting an existing customer.

customers array[Customer] OPTIONAL List of customers associated with this order.

0 Likes 0 · ·
james-cha avatar image
james-cha answered ·

The payload to add a customer order to an order:

{
  "customers":[{"id":"customerId"}]
}
2 comments 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.

Have you tried it? That matches my 3rd example which failed.

0 Likes 0 · ·

Yes I have tried it.

0 Likes 0 · ·

Welcome to the
Clover Developer Community