The total of the requested payments does not match the total of the sale order."

Hi,

I’m trying to send an order to a POS, so I’m following the structure of 1) create order 2) Pay order

The problem is that I get an error with the order/pay API. It says "The total of the requested payments does not match the total of the sale order." but from what I can see it’s the same amount everywhere: 265 cents.

What is the cause of this error so I can solve it?

Thank you very much :slight_smile:

v2/orders/tgCNA6tn1nbLaLifXSPm0MoEJYFZY/pay

 {
  "idempotency_key": "5bb1c88e-c689-46d6-b95f-78f95d817801",
  "order": {
    "location_id": "REDACTED",
    "fulfillments": [
      {
        "state": "PROPOSED",
        "type": "PICKUP",
        "uid": "34b9a35a-aa25-4519-8afe-0b9fa348098d",
        "pickup_details": {
          "auto_complete_duration": "P0DT1H30M15S",
          "is_curbside_pickup": true,
          "pickup_window_duration": "P0DT0H20M15S",
          "prep_time_duration": "P0DT0H05M15S",
          "recipient": {
            "display_name": "TEST REDACTED - DO NOT  FULLFILL",
            "email_address": "[email protected]",
            "phone_number": "8018954223"
          },
          "schedule_type": "ASAP"
        }
      }
    ],
    "line_items": [
      {
        "quantity": "1",
        "base_price_money": {
          "amount": 265,
          "currency": "USD"
        },
        "catalog_object_id": "REDACTED",
        "item_type": "ITEM"
      }
    ],
    "source": {
      "name": "REDACTED"
    },
    "state": "OPEN"
  }
}
{
  "idempotency_key": "3e3300d2-576b-408b-beb1-c036d34ea6a9",
  "source_id": "EXTERNAL",
  "amount_money": {
    "amount": 265,
    "currency": "USD"
  },
  "external_details": {
    "type": "OTHER",
    "source": "Subscription Redemption",
    "Source_id": "REDACTED",
    "source_fee_money": {
      "amount": 265,
      "currency": "USD"
    }
  }
}
{
  "errors": [
    {
      "code": "BAD_REQUEST",
      "detail": "The total of the requested payments does not match the total of the sale order.",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

PUTTING THE RESPONSE FOR REFERNECE BELOW:

{
  "order": {
    "id": "tgCNA6tn1nbLaLifXSPm0MoEJYFZY",
    "location_id": "REDACTED",
    "line_items": [
      {
        "uid": "XlHiwxfaD3fBh7OU4EjwMC",
        "catalog_object_id": "REDACTED",
        "catalog_version": 1693791865805,
        "quantity": "1",
        "name": "REDACTED",
        "variation_name": "",
        "base_price_money": {
          "amount": 265,
          "currency": "USD"
        },
        "gross_sales_money": {
          "amount": 265,
          "currency": "USD"
        },
        "total_tax_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_discount_money": {
          "amount": 0,
          "currency": "USD"
        },
        "total_money": {
          "amount": 265,
          "currency": "USD"
        },
        "variation_total_price_money": {
          "amount": 265,
          "currency": "USD"
        },
        "item_type": "ITEM",
        "total_service_charge_money": {
          "amount": 0,
          "currency": "USD"
        }
      }
    ],
    "fulfillments": [
      {
        "uid": "34b9a35a-aa25-4519-8afe-0b9fa348098d",
        "type": "PICKUP",
        "state": "PROPOSED",
        "pickup_details": {
          "pickup_at": "2023-09-06T03:10:20.158Z",
          "schedule_type": "ASAP",
          "recipient": {
            "display_name": "TEST REDACTED - DO NOT  FULLFILL",
            "email_address": "REDACTED",
            "phone_number": "8018954223"
          },
          "auto_complete_duration": "P0DT1H30M15S",
          "pickup_window_duration": "P0DT0H20M15S",
          "prep_time_duration": "P0DT0H05M15S",
          "is_curbside_pickup": true
        }
      }
    ],
    "created_at": "2023-09-06T03:05:05.160Z",
    "updated_at": "2023-09-06T03:05:05.160Z",
    "state": "OPEN",
    "version": 1,
    "total_tax_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_discount_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_tip_money": {
      "amount": 0,
      "currency": "USD"
    },
    "total_money": {
      "amount": 265,
      "currency": "USD"
    },
    "total_service_charge_money": {
      "amount": 0,
      "currency": "USD"
    },
    "net_amounts": {
      "total_money": {
        "amount": 265,
        "currency": "USD"
      },
      "tax_money": {
        "amount": 0,
        "currency": "USD"
      },
      "discount_money": {
        "amount": 0,
        "currency": "USD"
      },
      "tip_money": {
        "amount": 0,
        "currency": "USD"
      },
      "service_charge_money": {
        "amount": 0,
        "currency": "USD"
      }
    },
    "source": {
      "name": "REDACTED"
    },
    "net_amount_due_money": {
      "amount": 265,
      "currency": "USD"
    }
  }
}

Looking at the logs it appears your calling PayOrder instead of CreatePayment. PayOrder expects an array of payment_ids if the total of the order is greater then 0.

To make an EXTERNAL payment you’ll need to call CreatePayment with something like the following:

  {
  "idempotency_key": "3e3300d2-576b-408b-beb1-c036d34ea6a9",
  "source_id": "EXTERNAL",
  "order_id": "tgCNA6tn1nbLaLifXSPm0MoEJYFZY",
  "amount_money": {
    "amount": 265,
    "currency": "USD"
  },
  "external_details": {
    "type": "OTHER",
    "source": "Subscription Redemption",
    "Source_id": "Subport",
    "source_fee_money": {
      "amount": 265,
      "currency": "USD"
    }
  }
}

Also here’s the link to our guid on external payments. :slight_smile:

Thank you @Bryan-Square,
If the order is paid with the Square Payment SDK but I send the order details as an action after the payment was successful, can I put the resulting payment_id in the PayOrder?
Like this ID: JWjfDlQzVPQawzrb9HdjRweMkyCZY

Because it was not working with that ID, but maybe it’s something else that was wrong?

If the order is fully paid for from the Payments API there isn’t any need to call PayOrder since it will be fully paid for. The PayOrder endpoint is used if there are multiple payments that are being used to pay for a single order. For example if a group is going to share the cost of an order and use multiple cards to pay for the order. :slight_smile:

1 Like

Thanks @Bryan-Square, so the order arrives to the POS if I just send the Create Order? I do not need to create a payment nor use PayOrder for the order to arrive at the POS?

No, it won’t. Only fully paid orders that have a fulfillment will show in the orders section of the POS. You will still need to call CreatePayment with the order_id to get it to push to the POS. :slight_smile:

Thanks.
I’ve tried this but the order does not arrive to the POS:

Order_id: "t0EfdjPoeMZxo8sM2lDsOtYgsMKZY",

Payment_id: "588WAg8w6bLCfchsZ9bR2rH2tUaZY",

these are the fulfillments detials:

“fulfillments”: [
{
“uid”: “356292”,
“type”: “PICKUP”,
“state”: “PROPOSED”,
“pickup_details”: {
“pickup_at”: “2023-09-06T18:26:39.217Z”,
“schedule_type”: “ASAP”,
“recipient”: {
“display_name”: “Rafid”,
“email_address”: “[email protected]”,
“phone_number”: “1234567”
},
“auto_complete_duration”: “P0DT1H30M15S”,
“pickup_window_duration”: “P0DT0H20M15S”,
“prep_time_duration”: “P0DT0H05M15S”,
“is_curbside_pickup”: true
}
}

Nevermind, it was because autocomplete needs to be set to true :slight_smile:

Order arrived, thank you so much for your help @Bryan-Square!

Last question about this topic: if the order is tied to a Square-processed payment that has a resulting payment ID but the payment is done at a different moment, is there a way to link to it when using CreatePayment.

Right now I write as source External, but the payment is processed by Square, just in a different component

Great! Yes, the order will be updated with the payment_id. So when you RetrieveOrder you can find the associated payment for the order. Also the payment will always include the order_id. :slight_smile:

Hi @Bryan-Square ,

I implemented it on my test store and it was working fine but my customer tells me that the orders are not arriving at the POS.

It says the order is OPEN nPzD5Ov6rT4Q2C69TkKSvcb67haZY

This is what I send to the API:

And in the Create Payment call I use as the amount-money.amount the output that I get from the Create order net_amount_due_money.amount

net_amount_due_money": {
“amount”: 200,

Could it be because the net_amount_due_money.amount I sent from create orders does not include the Tip added?

The strange thing is that I cannot see the request code on the logs:

What’s the full body of the CreatePayment request? I don’t see it in the API logs for some reason. :slight_smile:

Thanks for your reply @Bryan-Square , for some reason the request also does not show up on my end.

Are you still calling PayOrder with the order_id? What APIs are you calling and in what order? Also all the information in the order and payment request don’t need to be redacted. All the information is safe to share and makes de-buging much easier.

Could you provide the API call your making to CreatePayment? All of your other API calls look fine except that one. Is there anything different about that API call? :slight_smile:

Thanks for your reply :slight_smile:

I’m calling the following APIs:

1) Create order https://connect.squareup.com/v2/orders


2) Create Payment https://connect.squareup.com/v2/payments


The strange thing:
It worked for this order ID when I tested it and it arrived to the POS: 5wjlNsygV2oB7DkQnULGUNDsRgSZY and TTgiZNebIcEHo0naGjvI4JvDF49YY (this last one was done at 2023-09-11 21:48:10 GMT-4)

But when I tested it with the client’s real life locations it was not working (order ID
nPzD5Ov6rT4Q2C69TkKSvcb67haZY - the payment request appears empty here as well


)

When I search for that order nPzD5Ov6rT4Q2C69TkKSvcb67haZY in the API Logs I don’t see a call to CreatePayment with the order_id. It looks like its not being correctly passed to a payment request. Are you validating that the body of the CreatePayment request is a valid body. :slight_smile: