Meteor-Dwolla Bulk创建客户帐户

时间:2018-01-24 05:57:24

标签: meteor dwolla

这里的要求是我想一次性在dwolla上添加一些客户。通过运行dwolla创建客户循环。但事情是某些客户的添加失败并出现错误,

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

1 个答案:

答案 0 :(得分:0)

以某种方式批量客户帐户创建失败,可能这是在dwolla创建继续调用并且它无法处理这么大的数字,可能是一个请求开始处理而另一个请求就像明智一样,所以最后我解决了为每个客户提供单独的“ADD”按钮,并在点击事件中调用create dwolla customer api。