Kevin_Lott
(Kevin Lott)
February 6, 2024, 12:41am
1
We use to get friendly error messages back from Dwolla Swagger when the customer entered the incorrect amounts, in the last few days we are now seeing the following error:
[400] Error connecting to the API (https://api-sandbox.dwolla.com/funding-sources/7d8a7fd9-bede-4060-84ce-fac9c5b159d5/micro-deposits )
We do use the try/catch method and this is the message that is received. Any advice on how we can get it to say “Incorrect Amounts” like it used to?
Thanks!
shreya
(Shreya | Developer Advocate @ Dwolla)
February 6, 2024, 3:58pm
2
Hi @Kevin_Lott ,
We might be able to provide some pointers – could you share any relevant code from your app related to the microdeposits verification call?
Kevin_Lott
(Kevin Lott)
February 6, 2024, 4:18pm
3
Sure!
public function account_funding_source_verify($id, $deposit_1, $deposit_2)
{
$fundingSourceUrl = DWOLLA_API . ‘funding-sources/’ . $id;
$fsApi = new DwollaSwagger\FundingsourcesApi($this->apiClient);
$fsApi->microDeposits([
'amount1' => [
'value' => $deposit_1,
'currency' => 'USD'
],
'amount2' => [
'value' => $deposit_2,
'currency' => 'USD'
]],
$fundingSourceUrl
);
return $fsApi;
}
shreya
(Shreya | Developer Advocate @ Dwolla)
February 6, 2024, 7:20pm
4
Thanks, @Kevin_Lott !
We could catch the error message and return that whenever an exception occurs. Here’s a slightly modified code you could try:
public function account_funding_source_verify($id, $deposit_1, $deposit_2)
{
$fundingSourceUrl = DWOLLA_API . 'funding-sources/' . $id;
$fsApi = new DwollaSwagger\FundingsourcesApi($this->apiClient);
try {
$response = $fsApi->microDeposits([
'amount1' => [
'value' => $deposit_1,
'currency' => 'USD'
],
'amount2' => [
'value' => $deposit_2,
'currency' => 'USD'
]
], $fundingSourceUrl);
return $response;
} catch (Exception $e) {
// Handle the exception here
return $e->getResponseBody();
}
}
In this modified code:
We wrap the API call inside a try block.
If an exception occurs during the API call, it will be caught by the catch block.
Inside the catch block, we return the response body of the exception using the getResponseBody() method.
If no exception occurs, we return the response from the API call as usual.
Kevin_Lott
(Kevin Lott)
February 6, 2024, 9:32pm
5
Thank you for the reply, we do wrap the call with a try catch and have been using $e->getMessage() which use to return the Wrong Amounts. the getResponseBody() does contain the nested errors:
{“code”:“ValidationError”,“message”:“Validation error(s) present. See embedded errors list for more details.”,“_embedded”:{“errors”:[{“code”:“Invalid”,“message”:“Wrong amount(s).”,“path”:“”,“_links”:{}}]}}
system
(system)
Closed
February 5, 2025, 12:41am
6
This topic was automatically closed after 365 days. New replies are no longer allowed.