question

questioner avatar image
questioner asked questioner commented

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

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

Dan avatar image Dan ♦ commented ·

moving to answer

0 Likes 0 ·
Dan avatar image
Dan answered questioner commented

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
10 |2000

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

questioner avatar image questioner commented ·

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 Deactivated answered questioner commented

The payload to add a customer order to an order:

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

questioner avatar image questioner commented ·

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

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

Yes I have tried it.

0 Likes 0 ·

Welcome to the
Clover Developer Community