Server Error on Requesting Code to Pair Terminal API

Hi,

When trying to pair the Terminal Payment Device via Terminal API, at the stage of requesting the Pairing Code, one of our merchants seems to be getting an error from Square APIs.

Log:

2024-10-21 00:19:53 - SQUARE-TERMINAL API >>>>>>>>>> 
URI         : https://connect.squareup.com/v2/devices/codes
Method      : POST
Headers     : {Accept=[application/json], Content-Type=[application/json], Authorization=[Bearer TOKEN-REDACTED], Square-Version=[2024-01-18], Content-Length=[203]}
Request body: {"idempotency_key":"670f1c710ef632032bbea83b","device_code":{"name":"Sunset Island - Kiosk - A3288SOM0122080211050527 Square Terminal Device","location_id":"LP576VN6Y92PK","product_type":"TERMINAL_API"}}
2024-10-21 00:19:53 - SQUARE-TERMINAL API API  <<<<<<<<<< Status = [500] path = [https://connect.squareup.com/v2/devices/codes]
Status code  : 500
Status text  : Internal Server Error
Headers      : {Date=[Mon, 21 Oct 2024 00:19:53 GMT], Content-Type=[application/json], Content-Length=[118], Connection=[keep-alive], CF-Ray=[8d5d14258bc63961-IAD], CF-Cache-Status=[DYNAMIC], Strict-Transport-Security=[max-age=631152000; includeSubDomains; preload], frame-options=[DENY], square-version=[2024-01-18], squareup--connect--v2--common--versionmetadata-bin=[CgoyMDI0LTAxLTE4], x-content-type-options=[nosniff], x-envoy-decorator-operation=[/v2/devices/codes/**], x-frame-options=[DENY], x-sq-dc=[aws], x-sq-region=[us-east-1], x-xss-protection=[1; mode=block], Set-Cookie=[__cf_bm=vC.4NkxDHsVjsfQaMjza1bzL2lBYgvLZRIE.Ry9Rr4k-1729469993-1.0.1.1-xLcHrJ3giiCDbliCn7rEsd3HWyVFI9Y39D5r9r06kNmIIoaISmgZvb_VkbzF_19kCna2i5LldVWr1VvJAuvQcw; path=/; expires=Mon, 21-Oct-24 00:49:53 GMT; domain=.connect.squareup.com; HttpOnly; Secure; SameSite=None], Vary=[Accept-Encoding], Server=[cloudflare]}
Response body: {"errors": [{"code": "INTERNAL_SERVER_ERROR","detail": "An unexpected error has occurred.","category": "API_ERROR"}]}

..

2024-10-21 00:21:30 - SQUARE-TERMINAL API >>>>>>>>>> 
URI         : https://connect.squareup.com/v2/devices/codes
Method      : POST
Headers     : {Accept=[application/json], Content-Type=[application/json], Authorization=[Bearer TOKEN-REDACTED], Square-Version=[2024-01-18], Content-Length=[203]}
Request body: {"idempotency_key":"670f1c710ef632032bbea83b","device_code":{"name":"Sunset Island - Kiosk - A3288SOM0122080211050527 Square Terminal Device","location_id":"LP576VN6Y92PK","product_type":"TERMINAL_API"}}
2024-10-21 00:21:30 - SQUARE-TERMINAL API API  <<<<<<<<<< Status = [500] path = [https://connect.squareup.com/v2/devices/codes]
Status code  : 500
Status text  : Internal Server Error
Headers      : {Date=[Mon, 21 Oct 2024 00:21:30 GMT], Content-Type=[application/json], Content-Length=[118], Connection=[keep-alive], CF-Ray=[8d5d168288903961-IAD], CF-Cache-Status=[DYNAMIC], Strict-Transport-Security=[max-age=631152000; includeSubDomains; preload], frame-options=[DENY], square-version=[2024-01-18], squareup--connect--v2--common--versionmetadata-bin=[CgoyMDI0LTAxLTE4], x-content-type-options=[nosniff], x-envoy-decorator-operation=[/v2/devices/codes/**], x-frame-options=[DENY], x-sq-dc=[aws], x-sq-region=[us-east-1], x-xss-protection=[1; mode=block], Vary=[Accept-Encoding], Server=[cloudflare]}
Response body: {"errors": [{"code": "INTERNAL_SERVER_ERROR","detail": "An unexpected error has occurred.","category": "API_ERROR"}]}

..

2024-10-21 00:22:27 - SQUARE-TERMINAL API >>>>>>>>>> 
URI         : https://connect.squareup.com/v2/devices/codes
Method      : POST
Headers     : {Accept=[application/json], Content-Type=[application/json], Authorization=[Bearer TOKEN-REDACTED], Square-Version=[2024-01-18], Content-Length=[203]}
Request body: {"idempotency_key":"670f1c710ef632032bbea83b","device_code":{"name":"Sunset Island - Kiosk - A3288SOM0122080211050527 Square Terminal Device","location_id":"LP576VN6Y92PK","product_type":"TERMINAL_API"}}
2024-10-21 00:22:27 - SQUARE-TERMINAL API API  <<<<<<<<<< Status = [500] path = [https://connect.squareup.com/v2/devices/codes]
Status code  : 500
Status text  : Internal Server Error
Headers      : {Date=[Mon, 21 Oct 2024 00:22:27 GMT], Content-Type=[application/json], Content-Length=[118], Connection=[keep-alive], CF-Ray=[8d5d17e69c8c3961-IAD], CF-Cache-Status=[DYNAMIC], Strict-Transport-Security=[max-age=631152000; includeSubDomains; preload], frame-options=[DENY], square-version=[2024-01-18], squareup--connect--v2--common--versionmetadata-bin=[CgoyMDI0LTAxLTE4], x-content-type-options=[nosniff], x-envoy-decorator-operation=[/v2/devices/codes/**], x-frame-options=[DENY], x-sq-dc=[aws], x-sq-region=[us-east-1], x-xss-protection=[1; mode=block], Vary=[Accept-Encoding], Server=[cloudflare]}
Response body: {"errors": [{"code": "INTERNAL_SERVER_ERROR","detail": "An unexpected error has occurred.","category": "API_ERROR"}]}

Merchant ID: LP576VN6Y92PK
Any leads on as to why this seems to be happening?

I see the errors in the logs and have reached out to the team. I’ll be sure to update you when I hear from them. :slightly_smiling_face:

1 Like

Hi Bryan,

Is there any update on this? We’re stuck with this merchant as we can’t complete device pairing and the onboarding process.

This should be fixed now. Is the seller still getting the error? If so can you try it with a different idempotency_key. :slightly_smiling_face:

Hi Bryan,

We tried again but we seem to get an empty code.

Request:

2024-10-30 00:20:41 - SQUARE-TERMINAL API >>>>>>>>>>
URI : https://connect.squareup.com/v2/devices/codes
Method : POST
Headers : {Accept=[application/json], Content-Type=[application/json], Authorization=[Bearer ACCESS_TOKEN], Square-Version=[2024-01-18], Content-Length=[203]}
Request body: {“idempotency_key”:“67217bc90ef632032bbea8a9”,“device_code”:{“name”:“Sunset Island - Kiosk - A3288SOM0122080211050527 Square Terminal Device”,“location_id”:“LP576VN6Y92PK”,“product_type”:“TERMINAL_API”}}

Response:

2024-10-30 00:20:41 - SQUARE-TERMINAL API API <<<<<<<<<< Status = [200] path = [https://connect.squareup.com/v2/devices/codes]
Status code : 200
Status text : OK
Headers : {Date=[Wed, 30 Oct 2024 00:20:41 GMT], Content-Type=[application/json], Connection=[keep-alive], CF-Ray=[8da73dacafa1c973-IAD], CF-Cache-Status=[DYNAMIC], Strict-Transport-Security=[max-age=631152000; includeSubDomains; preload], Vary=[Accept-Encoding], frame-options=[DENY], square-version=[2024-01-18], squareup–connect–v2–common–versionmetadata-bin=[CgoyMDI0LTAxLTE4], x-content-type-options=[nosniff], x-envoy-decorator-operation=[/v2/devices/codes/**], x-frame-options=[DENY], x-sq-dc=[aws], x-sq-region=[us-east-1], x-xss-protection=[1; mode=block], Server=[cloudflare]}
Response body: {“device_code”: {“id”: “DMGCWMFRRC04S”,“name”: “Sunset Island - Kiosk - A3288SOM0122080211050527 Square Terminal Device”,“code”: “”,“product_type”: “TERMINAL_API”,“location_id”: “LP576VN6Y92PK”,“pair_by”: “2024-10-30T00:25:26.000Z”,“created_at”: “2024-10-30T00:20:26.000Z”,“status”: “UNPAIRED”,“status_changed_at”: “2024-10-30T00:20:26.000Z”}}

We changed the idempotency_key as you advised but the code value was empty. Why is this?

I just checked the your API Logs and I see that we returned the code in the API response. Is your application correctly handling the response? :slightly_smiling_face:

Hi Bryan, code value seems to be empty. This seems to happen only for this particular merchant only as well.

If you call GetDeviceCode with the id is it still empty? :slightly_smiling_face: