Delay_action=complete with order ID

When I collect payment from customers, I like to describe how I’m receiving payment by creating an order.

I execute a test delayed payment with order ID and received this result:

{"errors": [{"code": "BAD_REQUEST","detail": "provided value: COMPLETE is invalid if an order_id is provided","field": "delay_action","category": "INVALID_REQUEST_ERROR"}]}

Then the documention goes on to say:

When an order ID isn’t specified, Square creates an order. This ensures that the order amount and payment amounts are the same and Square can therefore complete the payment.

Is there a way to make this call succeed while specifying an order ID if I already calculated the correct amounts?

For example, If I created an order of say:
10 apples at $1, and
20 apples at $2
and I set the payment amount in the payments api to $3, why couldn’t the call succeed? I demonstrated that $1 + $2 = $3.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Capture a Transaction
Payments API Integration
Create and Publish Invoices

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

What’s the application ID that your getting this error with? If your first creating the order then passing in the order_id in the payment request with the correct amount it will charge for the order. :slightly_smiling_face:

That’s my application ID for now as I am testing things in my sandbox:

sandbox-sq0idb-SMAihd3-mYYoPABJNDQU8Q

Yes, I am creating the order before calling the payments

I was able to replicate this and am reaching out to the team. :slightly_smiling_face:

thanks. Can I get an estimated time of when this issue is fixed? And if you update your public documentation in relation to this issue, show me where I can see that as well?
Thanks

This is actually the expected behavior as per our documentation for delay capture. Applications can explicitly set delay_action to COMPLETE to direct Square to complete the payment. However, the application can set delay_action to COMPLETE only if the CreatePayment request doesn’t explicitly specify an order ID. When an order ID isn’t specified, Square creates an order. This ensures that the order amount and payment amounts are the same and Square can therefore complete the payment. :slightly_smiling_face:

In regards to the last part of your paragraph…

Square wants to make it so that it calculates the totals if I try delay_action=complete. I’m trying to avoid manually completing each payment in the 7-day window.

I don’t understand why this rule has to be in place if I already created the order and the total matches up? Is there another reason why square would refuse delay_action=complete when an order ID is set other than to confirm that the total money requested in the payments api is the sum of the order made in the orders api (whether I or square creates the order)?

At this time this is a limitation of the APIs functionality. We’re constantly working to improve our features based on feedback like this, so I’ll be sure to share your request to the API product team. :slightly_smiling_face: