[SOLVED] Receiving money from my users not working


(Finn) #1

I tried to essentially do this, but am running into a lot of issues. Multiple code (at least in the PHP examples) snippets refer to non-existent variables or functions, but I’ve kind of bumbled along by reading through the client code (finding things like FundingsourceApi objects have no function get_account_funding_sources, but do have a function getAccountFundingSources). Anyway, I’ve constructed an object to send to /transfer, but I keep getting back 400 errors (which appear to mean the body is incorrect). This is the PHP I am using to construct the body:

  $transfer_request = array(
    '_links' => array(
      'source' => array(
        'href' => $settings['api']['endpoint']."/funding-sources/".$source
      ),
      'destination' => array(
        'href' => $settings['api']['endpoint']."/funding-sources/".$destination
      )
    ),
    'amount' => array(
      'currency' => $currency,
      'value' => number_format($amount, 2)
    )
  );

And this is what it looks like when i do json_encode($transfer_request):

{
    "_links": {
        "source": {
            "href": "https:\/\/api-uat.dwolla.com\/funding-sources\/e662f5a9-4e6e-46c5-9ec4-3e47917eef0d"
        },
        "destination": {
            "href": "https:\/\/api-uat.dwolla.com\/funding-sources\/7b8ea69f-b5d9-4940-822b-95df58c41e33"
        }
    },
    "amount": {
        "currency": "USD",
        "value": "187.03"
    }
}

What am I doing wrong?


(Finn) #2

Welp, dug into the client code some more, realized I could get the actual error out of the exception, solved my issues.


(Spencer Hunter) #3

@finn Great, let us know if you run into any other issues! Following up to your last post, if you get a 400 with a code of ValidationError we should provide additional information in the _embedded object. Specifically, path is a JSON pointer to the attribute that is invalid.

{
    "code": "ValidationError",
    "description": "Validation error(s) present. See embedded errors list for more details.",
    "message": "Validation error(s) present. See embedded errors list for more details.",
    "_embedded": {
        "errors": [
            {
                "code": "Required",
                "message": "FirstName is required.",
                "path": "/firstName",
            }
        ]
    }
}