x

Resource Not Found while trying to process a simple payment using Square Connect API

Hi guys, I'm testing out the Square Connect API in the Sandbox environment and getting the following results below.

 

I'm using my Sandbox Application ID and Sandbox Access Token. What is the reason that I'd be getting a "Resource Not Found" error message. I'm using a location that does have Credit Card processing enabled. I'm just using the basic example code found here --> https://github.com/square/connect-api-examples/tree/master/connect-examples/v2/php_payment

 

Caught exception!
Response body:

object(stdClass)#6 (1) {
  ["errors"]=>
  array(1) {
    [0]=>
    object(stdClass)#7 (4) {
      ["category"]=>
      string(21) "INVALID_REQUEST_ERROR"
      ["code"]=>
      string(9) "NOT_FOUND"
      ["detail"]=>
      string(19) "Resource not found."
      ["field"]=>
      string(10) "card_nonce"
    }
  }
}


Response headers:

array(12) {
  [0]=>
  string(22) "HTTP/1.1 404 Not Found"
  ["Content-Type"]=>
  string(16) "application/json"
  ["Vary"]=>
  string(15) "Accept-Encoding"
  ["X-Content-Type-Options"]=>
  string(7) "nosniff"
  ["X-Download-Options"]=>
  string(6) "noopen"
  ["X-Frame-Options"]=>
  string(10) "SAMEORIGIN"
  ["X-Permitted-Cross-Domain-Policies"]=>
  string(4) "none"
  ["X-Xss-Protection"]=>
  string(13) "1; mode=block"
  ["Date"]=>
  string(29) "Fri, 24 Jun 2016 03:45:38 GMT"
  ["Content-Length"]=>
  string(3) "121"
  ["Keep-Alive"]=>
  string(10) "timeout=60"
  ["Strict-Transport-Security"]=>
  string(17) "max-age=631152000"
}

 

7,348 Views
Message 1 of 26
Report
25 REPLIES 25
Square

Sorry to hear about the trouble. I'm going to loop in our developer team on this and we'll get back to you shortly. 

6,803 Views
Message 2 of 26
Report
Square

Thanks for your patience, just heard back!

 

So the 404 not found error you are receiving is on the field for card nonce. That means you're trying to charge without one. You need to use the payment form to create a card nonce (https://docs.connect.squareup.com/articles/adding-payment-form/) that you can then use to call the charge endpoint.

 

Alternately, you could use the customers endpoints (https://docs.connect.squareup.com/articles/saving-customer-information/) to perform card on file transactions. 

 

Hope that helps, let me know if you have additional questions @nmcwilli.

6,804 Views
Message 3 of 26
Report

@Spenser I'm having the same issue. I have the request JSON and the card_nonce field is present and populated. Could you help me any further?

6,793 Views
Message 4 of 26
Report
Square

Thanks for the heads up, @zhlavinka. I'll report back when I have an update!

6,790 Views
Message 5 of 26
Report

@Spenser Thanks! I must have setup that username with one of my clients on accident. I figured out the issue though.

6,783 Views
Message 6 of 26
Report
Square

@zhlavinka, it looks like you obtained the card-nonce using your sandbox access token, and then tried to charge the sandbox nonce in your non-sandbox (production) application. The sandbox nonces will only work for the charge endpoint in the sandbox, and production application nonces only work in production. 

 

Hope that info helps!

6,774 Views
Message 7 of 26
Report

I'm having the same issue.  Any ideas?

6,761 Views
Message 8 of 26
Report

Let me know if you need the code.

6,758 Views
Message 9 of 26
Report

@Spenser Any ideas?

6,735 Views
Message 10 of 26
Report
Square

Sorry I missed your previous replies, thanks for tagging me @txtumble! I'll report back shortly. 

6,119 Views
Message 11 of 26
Report
Square

Alright, @txtumble, sorry for the delay! 

 

Receiving a not_found error from the charge endpoint is most commonly caused by one of two issues:


1) Not using the payments form to obtain a card_nonce before calling the charge endpoint. Documentation for setting up the payment form can be found at https://docs.connect.squareup.com/articles/adding-payment-form/


2) Either obtaining a card_nonce using your sandbox credentials and attempting to charge that nonce with your oauth credentials, or obtaining a card_nonce using your oauth credentials and attempting to charge it with your sandbox sandbox credentials. Please check to make sure that the credentials used to obtain the card_nonce are the same as the credentials used to charge. Sandbox credentials are identifiable by starting with the string "sandbox-". You can find documentation on using the sandbox here and your application credentials at https://connect.squareup.com/apps.

 

Hope that helps!

6,109 Views
Message 12 of 26
Report

I've used this exact form https://docs.connect.squareup.com/articles/adding-payment-form/ I also know that I'm not using the sandbox because I have several charges that have go through correctly. What would happen if the user had javascript turned off?  Could that cause an issue?

6,101 Views
Message 13 of 26
Report
Square

You might actually be using sandbox mode still, @txtumble. You can confirm that you are not in sandbox mode by opening up the browser console (command-option-i in Chrome). If you are in sandbox mode, there will be a short message that starts out "SqPaymentForm initialized in Sandbox Mode...".

 

That form requires that you replace the application ID (it's marked in a comment in the code: "// <-- Add your application ID here"). Can you confirm that you've added the application ID?

 

Would you mind sending the specific error that you're receiving? The response body and response headers would be very helpful.

6,082 Views
Message 14 of 26
Report

Active URL: https://txtumbleweed100.com/register_online.php?rid=21

 

Failed response:

 

(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [category] => INVALID_REQUEST_ERROR
                    [code] => NOT_FOUND
                    [detail] => Resource not found.
                    [field] => card_nonce
                )

        )

)

 

 

6,079 Views
Message 15 of 26
Report
Square

Thanks! The issue is likely on the server side. Can you see if the code that is making the request is from your server to ours.


Additionally, make sure: 

 

  • You're including the card nonce that is generated from the frontend in the request you're making to our servers, using the same applicationId in the frontend and the server side.
  • The frontend is using the id "sq0idp-SU7J4NyFb_Gu5z-C70OS4w". The server needs to use that same id when it tries to charge the card. 

Keep me updated!

6,070 Views
Message 16 of 26
Report

My experience with this error is with clients using FireFox.  Transactions work in all other browsers.

6,032 Views
Message 17 of 26
Report

@Spenser did you see this?  I've disallowed Firefox.  Any idea on when this will be fixed?

6,002 Views
Message 18 of 26
Report
Square

Thanks for the mention, @txtumble, and for the heads up @digitalcreation

 

It sounds like you need to have an event argument to the submitButtonClick() function when you setup the form. Chrome has a global event, whereas firefox does not. You should be able see the difference between your code (missing event argument) and our example code here: https://github.com/square/connect-api-examples/blob/master/connect-examples/v2/php_payment/index.htm...

 

This should fix the issue in firefox, but let me know if you're still having any trouble. 

 

 

5,994 Views
Message 19 of 26
Report

I'm having the same problem, and have verified all the items mentioned in previous posts.  Just can't figure out what is causing the problem.

5,834 Views
Message 20 of 26
Report
Alumni

@TMBWT, bummer!

 

Can you share some of your code, or an example of your requests? Is it the exact same error message? 

4,819 Views
Message 21 of 26
Report