x

Is square checkout api broken?

I am trying to checkout using a thoroughly tested checkout page and I am getting an error I never got before [HTTP/2 400 ] {"errors":["category":"INVALID_REQUEST_ERROR", "code":"MISSING_REQUIRED_PARAMETER","detail":"Field must be set", "field":"order"}]}

This is not acceptable for square to change their API requirements without informing us or documenting what is needed.

1,439 Views
Message 1 of 9
Report
8 REPLIES 8

There have been a dozen successful transactions with the same form before.

1,438 Views
Message 2 of 9
Report
Alumni

I was able to reach out to our API team to gather a bit more detail about the Checkout API, @busaccagallery. You'll want to include two order objects in your request, so it will look something like this:

 

"idempotency_key": "XYZ",

    "order": {

        "order": {

            "line_items": { ...

 

Let us know here in this thread if any other questions come up!

Valentina
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
1,389 Views
Message 3 of 9
Report

I've discovered this same problem. It coincided with me moving to a new hosting environment on April 1, so I thought it was a new version of PHP or something that broke my old scripts. I will reach out to Square's API support to see if they can offer guidance. However, it would be useful if there was better Square Checkout API documentation online. The documentation that's there now feels very incomplete.

1,368 Views
Message 4 of 9
Report
Alumni

Hey there @superkev - you've got the right idea to contact our API Team. They'll be able to give you a more tailored level of support.

 

Thanks for the feedback about the API documentation. Sorry it didn't help much.  I'll be sure to bubble your voice through the appropriate channels so we can expand our API resources to make for a more informative, self-guided experience. 

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

Thanks for the reply. I actually just fixed it by following the guidance offered by @Valentina above. I nested the "order" object inside another "order" object. That solved it immediately.

 

As for documentation, what would be helpful is something similar to what existed when I first implemented the Checkout API, which is example code that can be customized. There used to be a full example, including sc-helper-func.php file with functions that could be easily modified. Now none of this exists, so it seems like we're supposed to figure this stuff out from scratch. That makes sense for the regular Connect API, but for something that is supposed to be easy like Checkout, there's surprisingly little documentation available.

1,360 Views
Message 6 of 9
Report
Alumni

Oh good! Glad Valentina was able to help @superkev

 

Thanks for feedback. It's been brought to our API Team's attention that the Checkout API needs improvement and they're working to make for a better experience.  With that said, our documentation does provide two example codes (C# and PHP): Here's one, and the Technical Reference also shows this

 

I hope this helps! In the meantime, I'll be sure to add your feedback to the voices of other Sellers that noticed opportunities for improvement. Thanks so much for posting! ​​​​​​ 

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

I did find those, thanks! I tried to understand them, but I found it much more difficult and complicated than when I initially set up my website with Connect about 2 years ago.

 

Currently, the Checkout PHP examples seem to require you to clone the entire project from git and use Composer to get a bunch of other stuff. After doing all of this, I couldn't even locate the example code. I'm not an advanced PHP coder, but I thought Checkout is for people who aren't advanced? Otherwise I'd dig deeper and implement Connect instead.

 

It seems like the missing piece is an easy way to see the helper function that structures your data into an array to send to the Checkout API. They might be buried somewhere in that giant git project, but digging through it to find the simple piece you need is overly  burdensome. I never actually found it.

 

In the past, this info was easier to find. I remember downloading sample code including very useful store-config.php and sc-helper-func.php files that contained template functions that I edited to format my data perfectly. These things don't seem to exist in your documentation anymore. 

 

In the end, it was this forum post that helped me see what had changed in the API to break my code. I'm glad this thread exists.

1,345 Views
Message 8 of 9
Report
Alumni

Eeek 😖 @superkev

 

Totally see your point. That's not the type of guidance we aim to offer our seller through our API self-help articles. We'll need to go back to the drawing board on this one.  

 

Glad this thread was able to help you though. If you run into any other issues, let us know so we can loop in our API Team. 

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
1,343 Views
Message 9 of 9
Report