Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Square API-付款总额与订单总额不匹配。是的_Api_Payment_Orders_Square - Fatal编程技术网

Square API-付款总额与订单总额不匹配。是的

Square API-付款总额与订单总额不匹配。是的,api,payment,orders,square,Api,Payment,Orders,Square,首先,我创建了一个订单并进行了订单搜索,下面的字符串显示了响应中的订单详细信息 接下来,我使用API Explorer进行支付->创建支付: 我把我的沙盒访问令牌放在顶部 至于我输入的其他信息,请参考请求字符串: curl https://connect.squareup.com/v2/payments \ -X POST \ -H 'Content-Type: application/json' \ -H 'Square-Version: 2020-01-22' \ -H '

首先,我创建了一个订单并进行了订单搜索,下面的字符串显示了响应中的订单详细信息

接下来,我使用API Explorer进行支付->创建支付:

我把我的沙盒访问令牌放在顶部

至于我输入的其他信息,请参考请求字符串:

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"
      }
    }
请注意,订单id和位置id都与订单详细信息中的内容相匹配。同样匹配的是创建付款请求中输入的金额和订单详细信息中的总金额: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。

首先,请尽快撤销您的访问令牌。您刚刚与世界共享了它,这意味着任何人都可以通过API访问您的帐户。一旦我看到实际问题,我将继续跟进。看起来您在沙箱中创建了订单,但试图在生产中创建付款。看来这个错误可能会更好,我会把这个传给我们的订单团队。但是,您必须为两个调用使用相同的环境。这是一个伪访问令牌。而且,对于两个环境,输入的访问令牌是相同的。沙盒在这两个服务器上都被选中。@sjosey发现它给了我这个错误,但当我返回并对订单ID执行batchRetrieveOrders时,它显示了付款信息。因此,它成功地添加了付款,但仍然给了我错误。