2012-03-01 50 views
0

我正在关注的docs为Dwolla的服务器到服务器的方法,并作出POST请求的URL中的文档与体内以下JSON数据:无效的总误差与Dwolla服务器到服务器验证方法

{ 
    "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), 
    ), 
))); 

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

回答

0

server-to-server request docs可能不完全清楚,但“运输”,“税”和“总计”参数都应嵌套在“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 
}