Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 无法调用方法';创建';未定义的_Meteor_Balanced Payments - Fatal编程技术网

Meteor 无法调用方法';创建';未定义的

Meteor 无法调用方法';创建';未定义的,meteor,balanced-payments,Meteor,Balanced Payments,下面是我从控制台服务器端得到的信息 I20140516-21:27:12.142(0)?此页上有一个错误。无法调用未定义的方法“create” 我没有找到一个很好的理由来解释为什么没有定义这个方法。我已经从Atmosphere加载了balanced payments生产包,其中包括balanced.js文件和到服务器的api导出。这里的任何帮助都是感激的 这是我的events.js文件 Template.CheckFormSubmit.events({ 'submit form': fu

下面是我从控制台服务器端得到的信息

I20140516-21:27:12.142(0)?此页上有一个错误。无法调用未定义的方法“create”

我没有找到一个很好的理由来解释为什么没有定义这个方法。我已经从Atmosphere加载了balanced payments生产包,其中包括balanced.js文件和到服务器的api导出。这里的任何帮助都是感激的

这是我的events.js文件

Template.CheckFormSubmit.events({
    'submit form': function (e, tmpl) {
        e.preventDefault();
        var recurringStatus = $(e.target).find('[name=is_recurring]').is(':checked');
        var checkForm = {
            name: $(e.target).find('[name=name]').val(),
            account_number: $(e.target).find('[name=account_number]').val(),
            routing_number: $(e.target).find('[name=routing_number]').val(),
            recurring: { is_recurring: recurringStatus },
            created_at: new Date
        }
        checkForm._id = Donations.insert(checkForm);

            Meteor.call("addCustomer", checkForm, function(error, result) {
                console.log(error);
                console.log(result);
                // Successful tokenization
            if(result.status_code === 201 && result.href) {
                // Send to your backend
                jQuery.post(responseTarget, {
                    uri: result.href
                }, function(r) {
                    // Check your backend result
                    if(r.status === 201) {
                        // Your successful logic here from backend
                    } else {
                        // Your failure logic here from backend
                    }
                });
            } else {
                // Failed to tokenize, your error logic here
            }

            // Debuging, just displays the tokenization result in a pretty div
            $('#response .panel-body pre').html(JSON.stringify(result, false, 4));
            $('#response').slideDown(300);
            });

        var form = tmpl.find('form');
        //form.reset();
        //Will need to add route to receipt page here.
        //Something like this maybe - Router.go('receiptPage', checkForm);
    },
    'click [name=is_recurring]': function (e, tmpl) {
      var id = this._id;
      console.log($id);
      var isRecuring = tmpl.find('input').checked;

      Donations.update({_id: id}, {
        $set: { 'recurring.is_recurring': true }
        });
    }
});
这是我的Methods.js文件

function getCustomer(req, callback) {
    try {
        balanced.marketplace.customers.create(req, callback);
        console.log(req.links.customers.bank_accounts);
    }
    catch (error){
        var error = "There was an error on this page. " + error.message;
        console.log(error);
    }
}

var wrappedGetCustomer = Meteor._wrapAsync(getCustomer);

Meteor.methods({
    addCustomer: function(formData) {
        try {
            console.log(formData);
            return wrappedGetCustomer(formData);
        }
        catch (error) {
            var error = "There was an error on this page." + error.message;
            console.log(error);
        }
    }
});

我需要平衡运行。配置('APIKEYHERE');首先,然后运行平衡代码

什么是平衡、市场、客户、创建?我在函数
getCustomer
balanced.marketplace.customer.create中看不到它的任何引用。该方法可以作为balanced API的一部分调用balanced’应该(我相信)可以从服务器端的任何地方调用。仅供参考:balanced使用承诺,因此您的创建行应该读作
balanced.marketplace.customers.create(req)。然后(callback)
另请参见:我认为我不能在meteor中使用.then,因为它是同步运行的。请参阅本文。我认为Stripe必须与之相似,因为它也使用承诺。我以与上面提到的stackoverflow文章相同的方式格式化了另一个函数,我得到了另一个错误<代码>[TypeError:Object[Object Promise]没有方法“应用”]