x

square payment gateway integration error using php

Exception when calling TransactionApi->charge:

C:\wamp\www\square_pay\v3\connect-php-sdk-master1\payment-process.php:38:
object(stdClass)[6]
  public 'errors' => 
    array (size=1)
      0 => 
        object(stdClass)[7]
          public 'category' => string 'AUTHENTICATION_ERROR' (length=20)
          public 'code' => string 'UNAUTHORIZED' (length=12)
          public 'detail' => string 'The `Authorization` http header of your request was malformed. The header value is expected to be of the format "Bearer TOKEN" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. "Bearer ABC123def456GHI789jkl0"). For more information, see https://developer.squareup.com/docs/build-basics/using-rest-api#__set-the-headers__. If you are seeing this error message while using one of our officially supported SDKs, please report this to developers@squareup.com.' (length=491)
3,113 Views
Message 1 of 7
Report
6 REPLIES 6
Alumni

@ndulg - Passing this up to our API team. We'll come back once we get a response. ๐Ÿ™‚

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
3,105 Views
Message 2 of 7
Report

Exception when calling TransactionApi->charge:object(stdClass)#7 (1) { ["errors"]=> array(1) { [0]=> object(stdClass)#6 (3) { ["category"]=> string(20) "AUTHENTICATION_ERROR" ["code"]=> string(12) "UNAUTHORIZED" ["detail"]=> string(352) "The `Authorization` http header of your request was incorrect or expired. The header value is expected to be of the format "Bearer TOKEN" (without quotation marks), where TOKEN is a valid access token (e.g. "Bearer ABC123def456GHI789jkl0"). For more information, see https://developer.squareup.com/docs/build-basics/using-rest-api#__set-the-headers__ ." } } }

2,998 Views
Message 3 of 7
Report
Alumni

Does this thread that I moved you to help? @gautam

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
2,939 Views
Message 4 of 7
Report
Alumni

Unauthorized errors are typically due to incorrect access tokens. If you're using sandbox, make sure you're using https://connect.squareupsandbox.com instead of https://connect.squareup.com .

 

Another reason could be that your access token has expired. If the above doesnโ€™t help them, send you their application ID as well as a code snippet of how you're setting your credentials in PHP (with the access token hidden). 

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
2,939 Views
Message 5 of 7
Report

I got the same error:

{"errors": [{"code": "UNAUTHORIZED","detail": "Your request did not include an `Authorization` http header with an access token. The header value is expected to be of the format \"Bearer TOKEN\" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. \"Bearer ABC123def456GHI789jkl0\"). For more information, see https://developer.squareup.com/docs/build-basics/using-rest-api#__set-the-headers__ . If you are seeing this error message while using one of our officially supported client libraries, please report this to developers@squareup.com.","category": "AUTHENTICATION_ERROR"}]}
Athena Garden: https://athenagarden.org
Thuy Sinh Nha Trang: https://thuysinhnhatrang.com
MICROTRAN: https://microtran.org
1,668 Views
Message 6 of 7
Report

My Opencart 3.0.3.7 uses Square. It was configured properly and worked fine before. Then I got an email asking to update the SSN/EIN. After I updated with a new EIN, Square stop working. I got similar error:

{"errors": [{"code": "UNAUTHORIZED","detail": "Your request did not include an `Authorization` http header with an access token. The header value is expected to be of the format \"Bearer TOKEN\" (without quotation marks), where TOKEN is to be replaced with your access token (e.g. \"Bearer ABC123def456GHI789jkl0\"). For more information, see https://developer.squareup.com/docs/build-basics/using-rest-api#__set-the-headers__ . If you are seeing this error message while using one of our officially supported client libraries, please report this to developers@squareup.com.","category": "AUTHENTICATION_ERROR"}]}

 Please help.

Athena Garden: https://athenagarden.org
Thuy Sinh Nha Trang: https://thuysinhnhatrang.com
MICROTRAN: https://microtran.org
1,667 Views
Message 7 of 7
Report