2

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":"[email protected]",
"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.

1 Answer 1

3

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.

5
  • Thanks @tristansokol but I tried that. Then I do that, I get different locations and when I try to use one, I got forbidden and an error that says I don't have access to that location.
    – Jim Archer
    Commented Feb 15, 2017 at 22:55
  • Then I think you tried to use your personal access token with a sandbox location. Try location CBASEHHNorL75Tj... with sandbox-sq0atb-R6... and any errors you get should be related the body of your request. Commented Feb 15, 2017 at 23:12
  • Thanks @tristansokol I'm willing to try, but the comment editor truncated the location key and sandbox token you posted. Could you perhaps edit your answer and add them there? Thank you again!
    – Jim Archer
    Commented Feb 15, 2017 at 23:19
  • Sorry, I did that truncation so that your credentials aren't posted online (even if they are sandbox). You can find that sandbox token on the Square Developer Portal and the location by calling list locations with that access code. Commented Feb 15, 2017 at 23:27
  • Okay I tried that again and this time I got a valid response, thank you. I am sure that when I tried it initially I got "forbidden" but perhaps it was because the location added was new or the account is new. Anyhow it's working now, thank you.
    – Jim Archer
    Commented Feb 16, 2017 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.