<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>thread Re: PaymentsApi-&amp;gt;createPayment: [HTTP/1.1 401 Unauthorized] in Archived Discussions (Read Only)</title>
    <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/PaymentsApi-gt-createPayment-HTTP-1-1-401-Unauthorized/m-p/162881#M93797</link>
    <description>&lt;P&gt;This error looks super familiar and I swear I got it recently, but can't remember exactly what was causing it, but in general I almost always have problems with the Access Token and the Location ID... so my advice is to carefully double check those. Like really don't assume they're both correct. Look for a missing character if you have to because 8 times out of 10 one of those is always my problem!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 06:01:18 GMT</pubDate>
    <dc:creator>PreOrder_Apps</dc:creator>
    <dc:date>2020-04-15T06:01:18Z</dc:date>
    <item>
      <title>PaymentsApi-&gt;createPayment: [HTTP/1.1 401 Unauthorized]</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/PaymentsApi-gt-createPayment-HTTP-1-1-401-Unauthorized/m-p/161248#M93796</link>
      <description>&lt;P&gt;I am completely new to Square, so please pardon if I am missing something simple, but I have been trying to test the createPayment() for days now and keep hitting the NOT AUTHORIZED response!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I set up the sandbox account and fetched the access token, and used the sample code to generate a nonce which I plugged into the server-side php page that will handle the payment. But I keep getting an Unauthorized response!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me with what I hope is an obvious and simple tweak to make this work? Here is my PHP code that is trying to create the payment on the nonce:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;?php&lt;/P&gt;
&lt;P&gt;require_once('include/square/connect-php-sdk-master/autoload.php'); // This from the github PHP SDK &lt;BR /&gt;SquareConnect\Configuration::getDefaultConfiguration()-&amp;gt;setAccessToken('I input my sandbox ACCESS TOKEN here'); // Sandbox Access Token&lt;/P&gt;
&lt;P&gt;$apiInstance = new SquareConnect\Api\PaymentsApi();&lt;BR /&gt;$body = new \SquareConnect\Model\CreatePaymentRequest(); */&lt;/P&gt;
&lt;P&gt;$Money = new \SquareConnect\Model\Money(); &lt;BR /&gt;$Money-&amp;gt;setAmount(100);&lt;BR /&gt;$Money-&amp;gt;setCurrency('USD');&lt;/P&gt;
&lt;P&gt;$body-&amp;gt;setLocationId('I input my sandbox location ID here');&lt;BR /&gt;$body-&amp;gt;setSourceId('I input the nonce generated from the card form here');&lt;BR /&gt;$body-&amp;gt;setIdempotencyKey('ABCDECBASEDheAIwXfvIOoWfqzKac9yY'); // just a random string&lt;BR /&gt;$body-&amp;gt;setAmountMoney($Money);&lt;/P&gt;
&lt;P&gt;try {&lt;BR /&gt;$result = $apiInstance-&amp;gt;createPayment($body);&lt;BR /&gt;print_r($result);&lt;BR /&gt;} catch (Exception $e) {&lt;BR /&gt;echo 'Exception when calling PaymentsApi-&amp;gt;createPayment: ', $e-&amp;gt;getMessage(), PHP_EOL;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;?&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 17:19:18 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/PaymentsApi-gt-createPayment-HTTP-1-1-401-Unauthorized/m-p/161248#M93796</guid>
      <dc:creator>babycity</dc:creator>
      <dc:date>2020-04-06T17:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: PaymentsApi-&gt;createPayment: [HTTP/1.1 401 Unauthorized]</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/PaymentsApi-gt-createPayment-HTTP-1-1-401-Unauthorized/m-p/162881#M93797</link>
      <description>&lt;P&gt;This error looks super familiar and I swear I got it recently, but can't remember exactly what was causing it, but in general I almost always have problems with the Access Token and the Location ID... so my advice is to carefully double check those. Like really don't assume they're both correct. Look for a missing character if you have to because 8 times out of 10 one of those is always my problem!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:01:18 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/PaymentsApi-gt-createPayment-HTTP-1-1-401-Unauthorized/m-p/162881#M93797</guid>
      <dc:creator>PreOrder_Apps</dc:creator>
      <dc:date>2020-04-15T06:01:18Z</dc:date>
    </item>
  </channel>
</rss>

