question

dcode avatar image
dcode asked dcode answered

Hosted CheckOut customer Error

Hi I am trying to test hosted checkout using

https://docs.clover.com/reference/createcheckout


but everytime i am gettting this error


{

"status": {

"reason": "Bad Request",

"code": 400

},

"message": "COS create customer failed with exception: 400 Bad Request: [{\"message\":\"Please provide a valid email\"}]"

}

here is the request i am sending


using System.Net.Http.Headers;

var client = new HttpClient();

var request = new HttpRequestMessage

{

Method = HttpMethod.Post,

RequestUri = new Uri("https://sandbox.dev.clover.com/invoicingcheckoutservice/v1/checkouts"),

Headers =

{

{ "accept", "application/json" },

{ "X-Clover-Merchant-Id", "4JFGGNQ1YN471" },

{ "authorization", "Bearer [Private token from Ecommerce API Tokens]" },

},

Content = new StringContent("{\"customer\":{\"emailAddresses\":{\"elements\":[{\"id\":\"600\",\"emailAddress\":\"william.smith@dcode.com\"}]},\"phoneNumbers\":{\"elements\":[{\"id\":\"600\",\"phoneNumber\":\"123442123\"}]},\"firstName\":\"William\",\"lastName\":\"Smith\",\"phoneNumber\":\"7077777777\",\"email\":\"\",\"id\":\"600\"},\"shoppingCart\":{\"lineItems\":[{\"name\":\"Coke\",\"price\":185,\"unitQty\":1}],\"total\":175},\"merchantUuid\":\"712W8BCT38EM1\"}")

{

Headers =

{

ContentType = new MediaTypeHeaderValue("application/json")

}

}

};

using (var response = await client.SendAsync(request))

{

response.EnsureSuccessStatusCode();

var body = await response.Content.ReadAsStringAsync();

Console.WriteLine(body);

}

e-commerce api
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.

Richelle Herrli avatar image Richelle Herrli ♦♦ commented ·
Context: why is emailAddress nested under emailAddresses?
0 Likes 0 ·
Richelle Herrli avatar image
Richelle Herrli answered

According to https://docs.clover.com/docs/making-a-checkout-request, the key for the email should be email rather than emailAddress.

10 |2000

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

dcode avatar image
dcode answered

Hi


I am using this tool on the website which generates the request automatically I am just filling the form on the left side the example request is auto generated on right side and I can’t modify auto generated code


https://docs.clover.com/reference/createcheckout

10 |2000

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

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