【问题标题】:Invalid Total error with Dwolla Server to Server checkout methodDwolla 服务器到服务器结帐方法的无效总错误
【发布时间】:2012-03-20 07:47:12
【问题描述】:

我正在关注 Dwolla 的 docs 服务器到服务器方法,并在正文中使用以下 json 数据向文档中的 URL 发出发布请求:

{
   "Key":"Fake_Key",
   "Secret":"Fake_Secret",
   "PurchaseOrder":{
      "DestinationId":"Fake_Destination_id",
      "Discount":0,
      "OrderItems":[
      {
            "Description":"a product",
            "Name":"lol",
            "Price":19.99,
            "Quantity":20
         }
      ]
   },
   "Shipping":0,
   "Tax":0,
   "Total":399.8,
   "Test":true
}

不幸的是,虽然数据对我来说似乎有效,但他们的服务器正在响应错误消息:

{
    "Result":"Failure",
    "Message":"Total cannot be less than $1."
}

虽然错误告诉我问题在于“总计”小于 1 美元,但显然不是。

-- 更多信息

这是我用来发出请求的 php:

$result = file_get_contents('https://www.dwolla.com/payment/request', null, stream_context_create(array(
    'http' => array(
    'method' => 'POST',
    'header' => 'Content-Type: application/json' . "\r\n" .
        'Content-Length: ' . strlen(json_encode($body)) . "\r\n",
        'content' => json_encode($body),
    ),
)));

当我推荐 Content-Type 时,我得到“无效的应用程序凭据”作为错误。

【问题讨论】:

    标签: json api rest response dwolla


    【解决方案1】:

    server-to-server request docs 中可能无法完全清楚,但“Shipping”、“Tax”和“Total”参数应该都嵌套在“PurchaseOrder”对象参数中。因此,要使您的请求生效,您需要更改这些参数的位置,如下所示:

    {
       "Key":"Fake_Key",
       "Secret":"Fake_Secret",
       "PurchaseOrder":{
          "DestinationId":"Fake_Destination_id",
          "Discount":0,
          "OrderItems":[
          {
                "Description":"a product",
                "Name":"lol",
                "Price":19.99,
                "Quantity":20
             }
          ],
          "Shipping":0,
          "Tax":0,
          "Total":399.8
       },
       "Test":true
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-08
      • 2014-09-24
      • 2021-11-20
      • 2019-01-29
      • 2016-04-19
      相关资源
      最近更新 更多