<?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: Create a Customer Card in Sandbox in Archived Discussions (Read Only)</title>
    <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28379#M94790</link>
    <description>&lt;P&gt;Investigating this issue a little more, it looks like this error comes up for a few different reasons. Are you sure you aren't mixing up your sandbox credentials?&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 13 Jan 2017 02:58:31 GMT</pubDate>
    <dc:creator>tristansokol</dc:creator>
    <dc:date>2017-01-13T02:58:31Z</dc:date>
    <item>
      <title>Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28188#M94786</link>
      <description>&lt;P&gt;I'm trying to:&lt;/P&gt;
&lt;P&gt;1. Create Customer&lt;/P&gt;
&lt;P&gt;2. Create Customer Card&lt;/P&gt;
&lt;P&gt;3. Make Transaction&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This code works live but fails in sandbox. Is it possible to store cards in sandbox mode?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;// NOTE: $access_token is my sandbox token&lt;BR /&gt; // create customer
    $customer = $customer_api-&amp;gt;createCustomer($access_token, $cust_obj)-&amp;gt;getCustomer();

    // store card
    $body = array(
        'card_nonce' =&amp;gt; $nonce,
        'cardholder_name' =&amp;gt; $cust_obj['given_name'].' '.$cust_obj['family_name']
    );  
    $customerCard = $customerCard_api-&amp;gt;createCustomerCard($access_token, $customer-&amp;gt;getId(), $body)-&amp;gt;getCard();

    // make the transaction with the stored card
    $request_body = array(
        'customer_id' =&amp;gt; $customer-&amp;gt;getId(),
        'customer_card_id' =&amp;gt; $customerCard-&amp;gt;getId(),
        'amount_money' =&amp;gt; array(
            'amount' =&amp;gt; (int)$_POST['amount'],
            'currency' =&amp;gt; 'USD'
        ),  
        # Every payment you process with the SDK must have a unique idempotency key.
        # If you're unsure whether a particular payment succeeded, you can reattempt
        # it with the same idempotency key without worrying about double charging
        # the buyer.
        'idempotency_key' =&amp;gt; uniqid()
    );  
    $result = $transaction_api-&amp;gt;charge($access_token, $location_id, $request_body);&lt;/PRE&gt;
&lt;P&gt;my error:&lt;/P&gt;
&lt;PRE&gt;Caught exception!
Response body:
object(stdClass)#46 (1) {
  ["errors"]=&amp;gt;
  array(1) {
    [0]=&amp;gt;
    object(stdClass)#43 (4) {
      ["category"]=&amp;gt;
      string(21) "INVALID_REQUEST_ERROR"
      ["code"]=&amp;gt;
      string(9) "NOT_FOUND"
      ["detail"]=&amp;gt;
      string(19) "Resource not found."
      ["field"]=&amp;gt;
      string(10) "card_nonce"
    }
  }
}
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 18:36:21 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28188#M94786</guid>
      <dc:creator>funk101</dc:creator>
      <dc:date>2017-01-10T18:36:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28200#M94787</link>
      <description>&lt;P&gt;The error you are getting is related to not supplying the card nonce. Are you sure you setting `$nonce` correctly?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 20:02:03 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28200#M94787</guid>
      <dc:creator>tristansokol</dc:creator>
      <dc:date>2017-01-10T20:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28202#M94788</link>
      <description>&lt;P&gt;Yes, it's coming from the square form on previous page:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;input type="hidden" id="card-nonce" name="nonce" value=""&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--- next page&lt;/P&gt;
&lt;PRE&gt;$nonce = $_POST['nonce'];&lt;/PRE&gt;
&lt;P&gt;-- I echo out the $nonce on the page that throws the error:&lt;/P&gt;
&lt;PRE&gt;Nonce: CBASEKrzEbnfCZ1mo1eqTeLTqPw&lt;/PRE&gt;
&lt;P&gt;This works in live mode, fails in sandbox. I'm sure I'm missing something but I can't find it&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 20:15:39 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28202#M94788</guid>
      <dc:creator>funk101</dc:creator>
      <dc:date>2017-01-10T20:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28204#M94789</link>
      <description>&lt;P&gt;It creates the customer ok, but fails when trying to create the card. After I create the customer I populate the $body array with the $nonce. I var_dump() the $body array and I see the $nonce is there, however it fails on creating card:&lt;/P&gt;
&lt;PRE&gt;  // create customer
    $customer = $customer_api-&amp;gt;createCustomer($access_token, $cust_obj)-&amp;gt;getCustomer();

    // store card
    $body = array(
        'card_nonce' =&amp;gt; $nonce,
        'cardholder_name' =&amp;gt; $cust_obj['given_name'].' '.$cust_obj['family_name']
    );  
    echo '&amp;lt;pre&amp;gt;';
    var_dump($body);
    echo '&amp;lt;/pre&amp;gt;';
    $customerCard = $customerCard_api-&amp;gt;createCustomerCard($access_token, $customer-&amp;gt;getId(), $body)-&amp;gt;getCard();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var_dump($body);&lt;/P&gt;
&lt;PRE&gt;Nonce: CBASEFIptxpy2UEOLf3RgsX3o6k
array(2) {
  ["card_nonce"]=&amp;gt;
  string(27) "CBASEFIptxpy2UEOLf3RgsX3o6k"
  ["cardholder_name"]=&amp;gt;
  string(11) "Tommy Smith"
}
Caught exception!&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 20:25:40 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28204#M94789</guid>
      <dc:creator>funk101</dc:creator>
      <dc:date>2017-01-10T20:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28379#M94790</link>
      <description>&lt;P&gt;Investigating this issue a little more, it looks like this error comes up for a few different reasons. Are you sure you aren't mixing up your sandbox credentials?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 02:58:31 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28379#M94790</guid>
      <dc:creator>tristansokol</dc:creator>
      <dc:date>2017-01-13T02:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create a Customer Card in Sandbox</title>
      <link>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28384#M94791</link>
      <description>&lt;P&gt;Ah, I just found the culprit. It was in the .js I hadn't checked. Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 04:45:29 GMT</pubDate>
      <guid>https://community.squareup.com/t5/Archived-Discussions-Read-Only/Create-a-Customer-Card-in-Sandbox/m-p/28384#M94791</guid>
      <dc:creator>funk101</dc:creator>
      <dc:date>2017-01-13T04:45:29Z</dc:date>
    </item>
  </channel>
</rss>

