How to solve `not a valid enum value for `address.country` while adding the customer? - square

I'm integrating the square api's with golang in my software. But there is a problem while I'm sending the add customer request with the below json object
{
"given_name": "Sand Box Customer",
"family_name": "This is a sandbox Family",
"email_address": "sandbox#gmail.com",
"address": {
"address_line_1": "500 Electric Ave",
"address_line_2": "Suite 600",
"locality": "New York",
"administrative_district_level_1": "NY",
"postal_code": "10003",
"country": "Australia"
},
"phone_number": "1-212-555-4240",
"reference_id": "YOUR_REFERENCE_ID",
"note": "a customer"
}
and in response it returns me with an error:-
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "INVALID_ENUM_VALUE",
"detail": "`Australia` is not a valid enum value for `address.country`.",
"field": "address.country"
}
]
}
Why this error I'm facing while It will support the Australia country see in the link https://docs.connect.squareup.com/. How can I solve this error?
documentation link:- https://docs.connect.squareup.com/get-started

According to their documentation, you should specify the country in /ISO_3166-1_alpha-2 format.
Refer the doc
https://docs.connect.squareup.com/api/connect/v2#type-location .
You can find more information from this also https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

Related

Google Fit API Rest create data source

I'm learning how to use Google Fit API and right now I'm trying to do the examples Google offers to explore the OAuth 2.0 Playground.
There's one example to create a data source whose code is:
POST
https://www.googleapis.com/fitness/v1/users/me/dataSources
{
"name": "example-fit-heart-rate",
"dataStreamId":
"raw:com.google.heart_rate.bpm:1234567890:Example Fit:example-fit-hrm-1:123456",
"dataType": {
"field": [{
"name": "bpm",
"format": "floatPoint"
}],
"name": "com.google.heart_rate.bpm"
},
"application": {
"packageName": "com.example.fit.someapp",
"version": "1.0"
},
"device": {
"model": "example-fit-hrm-1",
"version": "1",
"type": "watch",
"uid": "123456",
"manufacturer":"Example Fit"
},
"type": "raw"
}
when I write that code down in the OAuth Playground I have this error message:
{
"error": {
"status": "INVALID_ARGUMENT",
"message": "Expected dataStreamId to be [raw:com.google.heart_rate.bpm:com.example.fit.someapp:Example Fit:example-fit-hrm-1:123456], but was [raw:com.google.heart_rate.bpm:1234567890:Example Fit:example-fit-hrm-1:123456]",
"code": 400,
"errors": [
{
"reason": "invalidArgument",
"message": "Expected dataStreamId to be [raw:com.google.heart_rate.bpm:com.example.fit.someapp:Example Fit:example-fit-hrm-1:123456], but was [raw:com.google.heart_rate.bpm:1234567890:Example Fit:example-fit-hrm-1:123456]",
"domain": "global"
}
]
}
}
I guess is because of the structure of the dataStreamID but I find it strange because I didn't change any code from the Google site. Also I tried to delete the dataStreamID, change the numbers, try this format type:dataType.name:developer project number:device.manufacturer:device.model:device.uid:dataStreamName
but I have no results.
I'm no pretty sure of how does the dataStreamID structure works so if anyone could explain it to me that would be great.
The link of this Google Fit site:
[https://developers.google.com/fit/rest/v1/workout?hl=es-419]
Hope someone can help me.
Thank you!!!

Sandbox access token not working [Easyship]

We have to try to integrate Easyship courier API. And We are facing the below issue.
{
"rates": [],
"messages": [
"Sorry, we couldn't find any shipping solutions based on the information provided."
]
}
For more information, I have shared the request parameter and API response.
API URL:- https://api.easyship.com/v2/rates
Request Parameter:
{
"origin_address": {
"postal_code": "91601",
"city": "Los Ángeles",
"state": "CA",
"country_alpha2": "US"
},
"destination_address": {
"postal_code": "95140",
"city": "Mount Hamilton",
"state": "CA",
"country_alpha2": "US"
},
"parcels": [
{
"total_actual_weight": 5,
"items": [
{
"quantity": 1,
"category": "mobile_phones",
"dimensions": {
"width": 10,
"height": 10,
"length": 25
},
"description": "Apple iPad",
"actual_weight": 5,
"declared_currency": "USD",
"declared_customs_value": 49500.55
}
]
}
]
}
Response Parameter:
{
"status": "failure",
"errors": [
"Sorry, we couldn't find any shipping solutions based on the information provided."
],
"request_id": "545b5f76a41e2994a13f384559dee625",
"timestamp": "2022-10-12T10:09:21.272Z"
}
Note:
This request parameter works with the production access token.
We have applied all possible solutions for this issue but didn't find anything.
Also we don't want to use the production access token because we are in the developing stage. so please please provide working with a sandbox solution.

How to display data in table using Keystone6 component in custom page so it looks same?

I have build custom page in Keystone6 using this docs
Now I am getting data from GraphQL query.
{
"members": [
{
"__typename": "Member",
"id": "ckwluj7jd1675l4l8e9yfcwtt",
"name": "User 2",
"companyName": "company1",
},
{
"__typename": "Member",
"id": "ckwltsw620162l4l88g8ox4zo",
"name": "User 1",
"companyName": "company2",
},
{
"__typename": "Member",
"id": "ckwm061f8436554l8ab4ic3dsd5o",
"name": "User 3",
"companyName": "",
}
]
}
Now I am trying to display it on custom page but I am not sure how to use Keystone6 admin component to display data.
Ronald here from the Keystone Team.
At the moment there’s no way to do this using official Keystone components. We’re working on a next-gen Admin UI in 2022 that will make it easier for you to achieve this.

BigCommerce customer attributes from client/store

Can I retrieve the customer's
There is a current-customer API - https://developer.bigcommerce.com/api-docs/customers/current-customer-api, but it only returns the following bits about a customer.
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
}
I'd really to have the ability to get all the data from
https://developer.bigcommerce.com/api-reference/customer-subscribers/v3-customers-api/customer-attributes/customersattributesget as a property of the payload for current-customer-api
/customer/current.jwt?app_client_id={appClientId}&attribute-ids:in=1,2,3
"customer": {
"id": 4927,
"email": "john.doe#gmail.com",
"group_id": "6"
"attributes": [
{
"id": 1,
"name": "Age",
"type": "string",
"date_created": "2018-11-13T21:42:06Z",
"date_modified": "2018-11-14T16:46:23Z"
},
{
"id": 2,
"name": "Shoe Size",
"type": "number",
"date_created": "2018-11-14T16:34:57Z",
"date_modified": "2018-11-14T16:34:57Z"
},
{
"id": 3,
"name": "Date Joined",
"type": "date",
"date_created": "2019-02-19T19:13:21Z",
"date_modified": "2019-02-19T19:13:21Z"
}
]
}
This is an interesting feature request. The purpose of the current customer API is to verify the identity of a logged in customer in a secure way, which is why the payload is so minimal (with the understanding that you would likely be making a request for the full customer record based on the id returned).
We are planning to surface customer attribute data on the storefront though, which sounds like it would solve for your use case. We'll be adding Handlebars support soon, and we've got a storefront GraphQL API in the works as well. You can read more in our blog post here:
https://medium.com/bigcommerce-developer-blog/customize-and-extend-your-customer-data-with-the-new-bigcommerce-v3-customers-api-8609903e102a

Not Found error when charging Square API

The Square REST API docs state that I should get a list of my locations and then use a returned location code when I call the transactions endpoint (to charge a credit card). I am doing exactly this but the returned error says that the merchant has no location with the supplied ID.
I have tried this with and without the location_id in the JSON sent to the transactions endpoint, since it is a path variable. Same result. I have also seen on Square's API FAQ that the usual cause of a 404 not found is the card nonce being created wrong, but this response clearly says the location ID is not valid.
I have tested this with Postman and JSON and I can see that the location code is correct. Here are my calls and the responses:
This is a GET request:
https://connect.squareup.com/v2/locations
And here is the response:
{
"locations": [
{
"id": "FPVPFZ4DXXXXX",
"name": "MyCompany",
"address": {
"address_line_1": "123 Candy Lane",
"address_line_2": "",
"locality": "Smithfield",
"administrative_district_level_1": "RI",
"postal_code": "02917",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
},
{
"id": "4FHNAN1WXXXXX",
"name": "MyCompany2",
"address": {
"address_line_1": "567 Smith Street",
"address_line_2": "",
"locality": "Greenville",
"administrative_district_level_1": "RI",
"postal_code": "02828-2910",
"country": "US"
},
"timezone": "America/Los_Angeles",
"capabilities": [
"CREDIT_CARD_PROCESSING"
]
}
]
}
I modified the returned IDs a bit in the above example.
Next I make a call to charge a card to this uri:
https://connect.squareup.com/v2/locations/FPVPFZ4DXXXXX/transactions
With this body:
{
"note":"",
"idempotency_key":"azsxdcfvrtrewsdf",
"location_id":"FPVPFZ4DXXXXX",
"shipping_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"billing_address":{
"address_line_1":"123 My Street",
"address_line_2":null,
"locality":"Greenville",
"administrative_district_level_1":"RI",
"postal_code":"02828",
"country":"US"
},
"card_nonce":"CBASEPPW7fjdUHe-3jP6ZZ4kvE0gAQ",
"reference_id":"RT-12345678",
"amount_money":{
"amount":12500,
"currency":"USD"
},
"delay_capture":true,
"buyer_email_address":"jim#xxxxxxxxxx.net",
"customer_id":"JIM"
}
And I get this response:
{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "NOT_FOUND",
"detail": "This merchant does not have a location with the ID `FPVPFZ4DXXXXX`.",
"field": "location_id"
}
]
}
So the location ID matches exactly the ID returned by the locations endpoint.
Can someone familiar with this API help me out? Square's docs and support is sadly lacking.
I think the issue here is that you have tried to use your sandbox credentials (sandbox-sq0idp-defoUOlu...) to charge against your production location FPVPFZXXXXX. If you call ListLocations with your sandbox credentials, you should get a different location that you can then do sandbox charges with.