x

Error while posting data to the Square Checkout to get checkout ID

ERRORS that i recieved in the console:

 

=>angular.js:11048 OPTIONS https://connect.squareup.com/v2/locations/xxxxxxxxxxxxx/checkouts 403 (Forbidden)

=>XMLHttpRequest cannot load https://connect.squareup.com/v2/locations/xxxxxxxxxxxxx/checkouts. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 403.

 

i am receiving this error while connecting Square Checkout from localhost.

 

 

2,466 Views
Message 1 of 4
Report
1 Best Answer
Alumni

Best Answer

Like I said, you need to make the request to the checkout enpoint from the server side, not client side. It looks like you are trying to use AngularJS, which makes requests in the client. Instead you need to make the request with your server. That is why postman works, whereas your browser does not. 

View Best Answer >

2,904 Views
Message 4 of 4
Report
3 REPLIES 3
Alumni

What do you mean by connecting? 

 

You'll need to use a server-side language to generate a checkout form. 

2,452 Views
Message 2 of 4
Report

Actually we post object to this api "https://connect.squareup.com/v2/locations/XXXXXXXXX/checkouts" from our dev browser "http://localhost:9000".  We get error

 

=>angular.js:11048 OPTIONS https://connect.squareup.com/v2/locations/xxxxxxxxxxxxx/checkouts 403 (Forbidden)

=>XMLHttpRequest cannot load https://connect.squareup.com/v2/locations/xxxxxxxxxxxxx/checkouts. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 403.

 

But when we tried to post object to the above api using postman application, it returns checkout ID in response.

 

2,447 Views
Message 3 of 4
Report
Alumni

Best Answer

Like I said, you need to make the request to the checkout enpoint from the server side, not client side. It looks like you are trying to use AngularJS, which makes requests in the client. Instead you need to make the request with your server. That is why postman works, whereas your browser does not. 

2,905 Views
Message 4 of 4
Report