Сначала я создал заказ и выполнил поиск заказа. В приведенной ниже строке показаны подробности заказа из ответа.
Далее я использовал Проводники API для платежей-> CreatePayment: https://developer.squareup.com/reference/square/payments-api/create-payment/explorer
Я положил в свою песочницу Access Token вверху.
Что касается другой введенной мной информации, пожалуйста, обратитесь к строке запроса:
curl https://connect.squareup.com/v2/payments \
-X POST \
-H 'Content-Type: application/json' \
-H 'Square-Version: 2020-01-22' \
-H 'Authorization: Bearer {{access_token}}' \
-d '{
"source_id": "cnon:CBASEBbXLsTfPIy04J18kMjfbRo",
"idempotency_key": "5e42534d06257",
"location_id": "DWK1VQ391ZARF",
"order_id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"amount_money": {
"amount": 3649,
"currency": "USD"
}
}'
Вот подробности заказа:
{
"id": "fQZM8ekWkcAo7fRRBvUj2G2pY5EZY",
"location_id": "DWK1VQ391ZARF",
"line_items": [
{
"uid": "iLVwmNInonSV2Twc9G84fD",
"catalog_object_id": "B57CGCIAGUTLBQMAMEEI5WBC",
"quantity": "1",
"name": "Athletic Heather Pullover Hooded Sweatshirt",
"variation_name": "X-Large",
"base_price_money": {
"amount": 2699,
"currency": "USD"
},
"taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 2699,
"currency": "USD"
},
"total_tax_money": {
"amount": 243,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 2942,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 2699,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"tax_uid": "f9euLpXOOEWKd2bV7AgOdD",
"applied_money": {
"amount": 243,
"currency": "USD"
}
}
]
},
{
"uid": "dQS0tXEW46ERhQlLdPAxgC",
"catalog_object_id": "PY7V64HVFKSE6O7SW6RBQZ7U",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Small Print",
"base_price_money": {
"amount": 300,
"currency": "USD"
},
"taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 300,
"currency": "USD"
},
"total_tax_money": {
"amount": 27,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 327,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 300,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"tax_uid": "RAD93NhnUa9E6XBy7NYWG",
"applied_money": {
"amount": 27,
"currency": "USD"
}
}
]
},
{
"uid": "mIae9M46tMvTCpzgNvyNW",
"catalog_object_id": "Q4OPKIJ2BMG5LY35SUMHFG7S",
"quantity": "1",
"name": "2nd Amendment",
"variation_name": "Large",
"base_price_money": {
"amount": 0,
"currency": "USD"
},
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"gross_sales_money": {
"amount": 0,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 0,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 0,
"currency": "USD"
},
"applied_taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"tax_uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"applied_money": {
"amount": 0,
"currency": "USD"
}
}
]
},
{
"uid": "w3HK68X6MEpXHIxQDyTZ5",
"quantity": "1",
"name": "Shipping",
"base_price_money": {
"amount": 380,
"currency": "USD"
},
"gross_sales_money": {
"amount": 380,
"currency": "USD"
},
"total_tax_money": {
"amount": 0,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 380,
"currency": "USD"
},
"variation_total_price_money": {
"amount": 380,
"currency": "USD"
}
}
],
"taxes": [
{
"uid": "IFLJKtYmIiEvXTLZ5FLaJD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 0,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "RAD93NhnUa9E6XBy7NYWG",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 27,
"currency": "USD"
},
"scope": "LINE_ITEM"
},
{
"uid": "f9euLpXOOEWKd2bV7AgOdD",
"name": "Sales Tax",
"percentage": "9.0",
"type": "ADDITIVE",
"applied_money": {
"amount": 243,
"currency": "USD"
},
"scope": "LINE_ITEM"
}
],
"created_at": "2020-02-11T07:46:54.962Z",
"updated_at": "2020-02-11T07:46:54.962Z",
"state": "OPEN",
"version": 1,
"total_tax_money": {
"amount": 270,
"currency": "USD"
},
"total_discount_money": {
"amount": 0,
"currency": "USD"
},
"total_tip_money": {
"amount": 0,
"currency": "USD"
},
"total_money": {
"amount": 3649,
"currency": "USD"
},
"total_service_charge_money": {
"amount": 0,
"currency": "USD"
},
"net_amounts": {
"total_money": {
"amount": 3649,
"currency": "USD"
},
"tax_money": {
"amount": 270,
"currency": "USD"
},
"discount_money": {
"amount": 0,
"currency": "USD"
},
"tip_money": {
"amount": 0,
"currency": "USD"
},
"service_charge_money": {
"amount": 0,
"currency": "USD"
}
},
"source": {
"name": "Sandbox for sq0idp-0WcmbRcdTbsMGg5UjGvifQ"
}
}
Обратите внимание, что order_id и location_id совпадают с тем, что в деталях заказа. Также совпадает сумма, введенная в запросе на создание платежа, и total_money в реквизитах заказа: 3649.
Так почему же я получаю следующий ответ на запрос на создание платежа?
cache-control: no-cache
content-length: 136
content-type: application/json
date: Tue, 11 Feb 2020 07:48:48 GMT
square-version: 2020-01-22
{
"errors": [
{
"code": "BAD_REQUEST",
"detail": "The payment total does not match the order total.",
"category": "INVALID_REQUEST_ERROR"
}
]
}
Использование Square API v2.