【问题标题】:Creating a customer in BrainTree with a credit card使用信用卡在 BrainTree 中创建客户
【发布时间】:2015-05-12 10:03:09
【问题描述】:

我正在阅读有关创建客户的文档。我需要使用信用卡和 cvc 编号创建一个,但出现错误,我不知道如何创建它。

我显示我的代码

if(user.local.subscription == undefined){
            //creamos cliente
            gateway.customer.create({
                creditCard : {
                    number : cardnumber,
                    expirationDate : "12/15"
                }
            }, function (err, result) {
                if(err){
                    //return res.status(500).json({ error : "Error creating customer"});
                    console.log(err);
                }
                console.log(result);
                /*user.subscription = result;
                userId = result.customer.id;*/

            });
        }

【问题讨论】:

    标签: node.js braintree


    【解决方案1】:
    var braintree = require("braintree");
    
    var gateway = braintree.connect({
      environment: braintree.Environment.Sandbox,
      merchantId: "your sanboxmerchant",
      publicKey: "your sandbox public key",
      privateKey: "sandbox privatekey"
    });
    
    gateway.customer.create({
                    creditCard : {
                cardholder_name : 'james bliz',
                        number : "4111111111111111",
                cvv : '123',
                        expirationDate : "12/17"
                    }
                }, function (err, result) {
                    if(err){
                        //return res.status(500).json({ error : "Error creating customer"});
                        console.log(err);
                    }
                    console.log(result);
                    /*user.subscription = result;
                    userId = result.customer.id;*/
    
                });
    

    答案应该是这样的

    { customer: 
       { id: '29931379',
         merchantId: 'qn5442rvm794nc6q',
         firstName: null,
         lastName: null,
         company: null,
         email: null,
         phone: null,
         fax: null,
         website: null,
         createdAt: '2015-05-12T10:33:41Z',
         updatedAt: '2015-05-12T10:33:42Z',
         customFields: '',
         creditCards: [ [Object] ],
         addresses: [],
         paymentMethods: [ [Object] ] },
      success: true }
    

    从中获取必填字段,我认为您只需要来自结果对象的客户 ID。

    【讨论】:

      猜你喜欢
      • 2016-12-14
      • 2015-01-15
      • 1970-01-01
      • 2017-09-08
      • 2015-03-23
      • 1970-01-01
      • 2014-10-12
      • 1970-01-01
      • 2014-09-19
      相关资源
      最近更新 更多