Dwolla - Bulk create customer accounts


#1

Hi All,

Requirement here is I wants to add number of customers on dwolla in one shot. By running dwolla create customer in loop. But things is some customer addition is failing with error,

Error: {“code”:“ServerError”,“message”:“A server error occurred. Error ID: 6188070b-8a1b-4d94-90a5-eb1333d3cd9e.”}

	const client = new dwolla.Client({
  key         : dwollaCredentials.appKey,
  secret      : dwollaCredentials.appSecret,
  environment : 'sandbox' // optional - defaults to production
});

client.auth.client()
  .then(Meteor.bindEnvironment(function(appToken) {

	var spaceProviders = getListofSpaceProvidersWithNoDwollaAcc();
	console.log(spaceProviders.length);

  	for(var i = 0 ; i<spaceProviders.length ; i++){

		var spaceProviderId   = spaceProviders[i].id;
		var routingNumberUser = spaceProviders[i].routingNo;
		var accountNumberUser = spaceProviders[i].accountNumber;
		var bankName          = spaceProviders[i].firstName+' '+spaceProviders[i].lastName+' Bank';

		if(spaceProviders[i]){

		  	var requestBody = {
			  firstName : spaceProviders[i].firstName,
			  lastName  : spaceProviders[i].lastName,
			  email     : spaceProviders[i].email
			};

			console.log('requestBody: ',requestBody);

			appToken
				  .post('customers', requestBody)
				  .then( 

					  	(res)=> {
					  	var dwollaLocation = res.headers.get('location');	
					  	return Promise.resolve(dwollaLocation);
					   }

				  )
				  .then(
				  		Meteor.bindEnvironment((dloc) =>{ 	
				  				console.log("dloc"+i+' '+dloc);
				  				return Promise.resolve(dloc);
				  			})
				  	)
				  .catch(error => console.log("Handled Exceptions user",i+' - '+error));
			}


  	}//i

  })
  );

Thanks in advance!