2012-03-01 48 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 
}