additionalFees PHP assistance


(Eric Davis) #1

Let me explain what I’m trying to do here. A customer pays $40 to a restaurant. The restaurant, for being part of the site, is charged $1.75 per transaction. The $1.75 fee is then split between four people. I made the facilitator fee 0 so I could have control over where the $1.75 goes. But, in my case, the additionalFees is returning that 500 error. Any clue? Here’s the latest snippet:

$params = array(
‘facilitatorAmount’ => 0,
‘additionalFees’ => array(
array(
‘destination’ => $restRecruitDID,
‘amount’ => ‘0.25’
),
array(
‘destination’ => $custRecruitDID,
‘amount’ => ‘0.25’
),
array(
‘destination’ => $custRecruitRecruitDID,
‘amount’ => ‘0.25’
),
array(
‘destination’ => $testMojobidID,
‘amount’ => $mojoAmt
)
)
);

$transactionId = $Dwolla->send($pinEntry, $restDwollaID, $bidTotal, $params);

It keeps coming back with this error:
Error: Request failed. Server responded with: 500

If I remove $params from the send function all is right with the world but, of course, that’s not what my intention is. I’m a bit of a noob with this so I’m sure someone out there knows exactly what the issue is.

Thanks!


(David Stancu) #2

Hello @hellomrdavis!

From what I see here, it appears that your call to the library is invalid. Let’s take a look and see why. Here’s our function prototype:

public function send($pin = false, $destinationId = false, $amount = false, $destinationType = 'Dwolla', $notes = '', $facilitatorAmount = NULL, $assumeCosts = false, $fundsSource = 'balance', $additionalFees = FALSE, $assumeAdditionalFees = FALSE);

Your function call is:

$transactionId = $Dwolla->send($pinEntry, $restDwollaID, $bidTotal, $params);

This equates to setting destinationType to an array, which would cause an invalid request.


The appropriate way to do what you wish to do is the following:

  • Make a variable that contains just the array of additional fees, for example:
$addFees = array(
array(
'destination' => $restRecruitDID, 
'amount' => '0.25'
),
array(
'destination' => $custRecruitDID, 
'amount' => '0.25'
),
array(
'destination' => $custRecruitRecruitDID, 
'amount' => '0.25'
),
array(
'destination' => $testMojobidID, 
'amount' => $mojoAmt
)
);
  • Call the send function as so:
$transactionId = $Dwolla->send($pinEntry, $restDwollaID, $bidTotal, 'Dwolla', 'Your notes here.', 0, false, 'balance', $addFees);

This should work. Let me know if you run into any other troubles.

Cheers,

David


(Eric Davis) #3

Great! Now we’re getting somewhere. I ran into this error now though:
Invalid facilitator user.

But I can’t find a reference to that error in the documentation.


(David Stancu) #4

@hellomrdavis,

Can you verify the Dwolla ID of the user(s) which are to receive the facilitator fee funds (or paste them here if you’re comfortable doing so)?

David


(Eric Davis) #5

Sure thing. There are all test Sandbox accounts I created…

$restRecruitDID = “812-147-9108”;
$custRecruitDID = “812-193-8878”;
$custRecruitRecruitDID = “812-171-6431”;
$testMojobidID = “812-188-4501”;
$restDwollaID = “812-146-5374”;


(Eric Davis) #6

I also checked and I do have Facilitator Fees enabled for my test application. Can’t see what the issue is and we were to start testing today.


(David Stancu) #7

@hellomrdavis,

I think I’ve figured it out! Can you please do the following change to your additional fees array? The key value for the destination ID in your array is destination, however, the API expects it to be destinationId.

Here is the correct array:

$addFees = array(
array(
'destinationId' => $restRecruitDID, 
'amount' => '0.25'
),
array(
'destinationId' => $custRecruitDID, 
'amount' => '0.25'
),
array(
'destinationId' => $custRecruitRecruitDID, 
'amount' => '0.25'
),
array(
'destinationId' => $testMojobidID, 
'amount' => $mojoAmt
)
);

The specification for this endpoint can be found here.

Try this out and let me know! :smiley:

David


(Eric Davis) #8

And there we go! I appreciate all the help. I actually used the “destinationId” in earlier code. Go figure.


(Cory Anderson) #9