Dwolla integration for mass payout

We are working on Dwolla ACH Mass Payout first time. Facing lots of challenges after reading API documents. We have created account on dwolla site and sandbox site.

I have a few questions that I need answered to help me finish the setup

  1. In API for Mass Payouts, we found that there is a source object and under items array, there may be multiple destinations.
    We could not see anything specific in source and destination which uniquely identifies our funding-source and our client to whom we have to pay.

  2. There is a continuous use of idempotency key in all apis. But we believe that this key is a simple random key and down’t idenitfy our customer uniquely. Is this correct understanding?
    If yes, then how to tell system to transfer $1.00 to a particular customer?

  3. Do we need to create customers in every transaction? Or if customers need to create only once?
    What would happen if I try to create a duplicate customer?

Is there any live example of entire process of

  1. Authorization
  2. Create Customers
  3. Add bank details of customers
  4. Handle duplicate customers
  5. Make payments to all our customers in single transactions.

Any help would be appreciated.
Thanks

I guess you should ask these questions in a Dwolla forum/repo

I did it already. Just trying my luck here. Thanks

@divyanidhin did you find out anything new - looking at Dwolla to see if it will simplify something I am working on.

Any information you uncovered would be good to know.

Thanks

@drollins I’m following https://developers.dwolla.com/guides/send-money/ but the problem I’m facing now is that how to handle this if the customer is already created. It shows email ID already exists and throws error.
Will update when I find any solution to that.

I think you might have to get a list of funding sources - that list should contain all currently defined parties in you account that you have to choose from for transfer purposes.

At least that’s what I’m getting from reading their docs.

Actually I’m trying to call Meteor.users.update function inside .then but according to my understanding since .then is a non meteor function, its not accepting meteor function. Thats what I’m facing

.then is an indication that this library uses Promises. Meteor has first-class Promise support built in. However, I’m not familiar with Dwolla, and without some of the code you’re having difficulty with, I’m unable to help.

.then is part of Javascript promises - you might want to checkout https://developers.google.com/web/fundamentals/primers/promises https://developers.google.com/web/fundamentals/primers/promises

This is my code:

appToken
.post('customers', requestBody)
.then(function(res) {
	var dwollaLocation = res.headers.get('location');
	return Promise.resolve(dwollaLocation);		  	
 })
 .then(
	dloc => { 				  					 
		Meteor.users.update(
			{'_id': spID },
			{
			$set:{
			    "dwollaLocation" :  dloc,
			} //End of set
			}, function(err,result){
				if(err){
				   console.log("Error occured during client update of dwolla location");
				}else{
					console.log("Successful Update of Dwolla Location!");
				}
							      		
			}
		 );
	}
	)
				  	
 .catch(error => console.log("Handled Exceptions error "));

And I’m getting this error
Unhandled rejection Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

Thanks for that - could you please edit your post and wrap your code in lines with triple-backticks, like this:

```
your
code
here
```

Thanks @drollins, I’m implementing this. lets see

I tried doing this also

appToken
	.post('customers', requestBody)
	.then(function(res) {
	    var dwollaLocation = res.headers.get('location');
	   return Promise.resolve(dwollaLocation);		  	
	})
     .then(
	Meteor.bindEnvironment((dloc) => {
            Meteor.users.update(
		{'_id': 'zdfoiTXCCdE8XiCgN' },
		{
		  $set:{
			"dwollaLocation" :  dloc,
		} //End of set
	        }, function(err,result){
		   if(err){
			console.log("Error occured during client update of dwolla location");
		  }else{
			console.log("Successful Update of Dwolla Location!");
		}      		
	     }
	  );	      
      }))
    .catch(error => console.log("Handled Exceptions error "));

But still getting the same error

OK, I’ve confirmed that dwolla does use Promises. I’ve refactored the snippet you posted and come up with this:

const someFunction = async () => {
  // somewhere up here you define appToken and requestBody
  try {
    const res = await appToken.post('customers', requestBody);
    const dloc = await res.headers.get('location');
    try {
      Meteor.users.update(
        { '_id': spID },
        {
          $set: {
            'dwollaLocation': dloc,
          } //End of set
        });
      console.log('Successful Update of Dwolla Location!');
    } catch (error) {
      console.log('Error occured during client update of dwolla location');
    }
  } catch (error) {
    console.log('Handled Exceptions error ', error);
  }
}

(You didn’t show where appToken and requestBody came from).

If this is a Meteor method, you’d define it with:

Meteor.methods({
  async myMethod() {
    // somewhere up here you define appToken and requestBody
    try {
      const res = await appToken.post('customers', requestBody);
      const dloc = await res.headers.get('location');
      try {
        Meteor.users.update(
          { '_id': spID },
          {
            $set: {
              'dwollaLocation': dloc,
            } //End of set
          });
        console.log('Successful Update of Dwolla Location!');
      } catch (error) {
        console.log('Error occured during client update of dwolla location');
      }
    } catch (error) {
      console.log('Handled Exceptions error ', error);
    }
  },
});