Guys, I would like to issue an invoice the the order that will be payed via terminal checkout.
If I understand the limitations correctly I cannot re-use the Order from TerminalCheckout cause the Order attached to the Invoice cannot be changed, so terminal checkout has to have it’s own Order instance. Then the Order for terminal checkout get payment information attached.
Since the the invoice is also payed cause it’s attached to copy of the order from the terminal checkout, I would like to complete it as well — attach a payment, or at least close it as payed.
I am basically looking to accomplish this through the API:
So how to create invoice for terminal checkout payment and close the invoice as payed?
Reference
Order update is not supported
After an order is associated with an invoice, you cannot update order fields that affect the order amount (or their child fields), such as:
- line_items
- taxes
- discounts
To update these immutable fields, you must cancel the invoice, which also cancels the order. You can then create a new order and a new invoice. However, you can update order fields that don’t affect the cart.
Order used in Invoice cannot be referenced by Terminal Checkout
Payment for the order must be made on the invoice. You cannot use Square APIs such as PayOrderYou can pay for your orders with the Payments API (the CreatePayment endpoint) or with the Orders API (the PayOrder endpoint).Guide or CreatePaymentCreates a payment using the provided source.Endpoint to process a payment for an order that is associated with an invoice. After the invoice is paid in full, Square sets the state field of the order to COMPLETED.
When I try to attach a payment to the Invoice order I get a confusing error that does not indicate what is actually happening.
{
"errors": [
{
"code": "FORBIDDEN",
"detail": "The order `tcn...ZY` is owned by another application.",
"category": "AUTHENTICATION_ERROR"
}
],
"payment": {
"id": "x67x...fcZY",
"created_at": "2024-08-08T08:34:02.469Z",
"updated_at": "2024-08-08T08:34:02.539Z",
"amount_money": {
"amount": 321,
"currency": "USD"
},
"status": "CANCELED",
"source_type": "EXTERNAL",
"location_id": "LYP...1KH",
"order_id": "tcn...LZY",
"total_money": {
"amount": 321,
"currency": "USD"
},
"capabilities": [
"EDIT_AMOUNT_UP",
"EDIT_AMOUNT_DOWN",
"EDIT_TIP_AMOUNT_UP",
"EDIT_TIP_AMOUNT_DOWN"
],
"external_details": {
"type": "EXTERNAL",
"source": "terminal checkout duplicate"
},
"application_details": {
"square_product": "ECOMMERCE_API",
"application_id": "sandbox-sq0idb--TC...Iog"
},
"version_token": "P1T4...85o"
}
}
`
---
If the information from thread [403 Error on Create payment with order_id](https://developer.squareup.com/forums/t/403-error-on-create-payment-with-order-id/1118) is correct then we're basically screwed and we need to create invoices elsewhere.