Meteor-Dwolla Bulk create customer accounts

41 views Asked by At

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.”}

Code:

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
    })
);
1

There are 1 answers

0
Rashmi On

Somehow bulk customers account creation is failing, may be this is creating continues calls at dwolla and it is unable to handle this much big number, may be one request starts processing and another one is reaching like wise, so finally I am settling for individual "ADD" button for each customer and calling create dwolla customer api on click event.