无效的总误差与Dwolla服务器到服务器验证方法 [英] Invalid Total error with Dwolla Server to Server checkout method

查看:148
本文介绍了无效的总误差与Dwolla服务器到服务器验证方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继文档为Dwolla的服务器到服务器的方法,以及做一个POST请求的URL中的文档在体内以下JSON数据:

I'm following the docs for Dwolla for the Server to Server method, and making a post request to the URL in the docs with the following json data in the body:

{
   "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
}

不幸的是,虽然数据看起来有效的对我来说,他们的服务器与错误信息响应:

Unfortunately, while the data seems valid to me, their server is responding with the error message:

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

虽然该错误告诉我,问题是,合计是低于$ 1,很显然不是。

While the error tells me that the problem is that the "Total" is less than $1, it very clearly isn't.

- 更多信息

下面是我使用,使请求的PHP:

Here's the php I'm using to make the request:

$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),
    ),
)));

当我赞扬了内容类型,我得到无效的应用程序凭证的错误。

When I commend out the Content-Type, I get "Invalid Application Credentials" as the error.

推荐答案

这可能不是完全清楚从的服务器到服务器的请求文档,但送货,税收和共有的参数,都应该被嵌套在范围内的PurchaseOrder对象参数。所以,要想让您的要求的工作,你需要改变这些参数的位置,因为这样的:

It might not be completely clear from the server-to-server request docs, but the "Shipping", "Tax", and "Total" parameters, should all be nested within the "PurchaseOrder" object parameter. So, to get your request to work, you'll need to change the position of those parameters, as such:

{
   "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
}

这篇关于无效的总误差与Dwolla服务器到服务器验证方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆