So the story goes, Omar went searching far and wide for a reason as to why his Dwolla code was not working. On every try the output is
{"Result":"Failure","Message":"Invalid application credentials."}
My key, secret and destinationId are all correct (triple checked) and the only suggestion from the internets was to make sure that the sent body was JSON encoded..which it is. I've searched stack, read the dev docs and Googled for a few hours only to come up with more confusion and a headache. Here is my code:
$body= '{
"Key": "'.$key.'",
"Secret": "'.$secret.'",
"PurchaseOrder": {
"DestinationId": ".$destinationId.",
"Discount": 0,
"OrderItems": [ {
"Description": "Description #1",
"Name": "Item #1",
"Price": 4,
"Quantity": 1
}, {
"Description": "Description #2",
"Name": "Item #2",
"Price": 2,
"Quantity": 2
} ],
"Shipping":2,
"Tax": 0,
"Total": 10,
"Notes": "A note on this order",
"Test" : "true",
"orderId" : 1,
"callback" : "https://test.com/library/payments.php" ,
"redirect" : "https://test.com/library/payments.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($body) . "\r\n",
'content' => $body,
),
)
));
And who ever can help me find a solution gets a virtual cookie and a high five. Thanks guys!