使用信用卡在BrainTree中创建客户

时间:2023-01-09 19:40:21

I'm reading the docs about creating a customer. I need to create one with a credit card, a cvc number but I get an error and I don't know how I must create it.

我正在阅读有关创建客户的文档。我需要创建一个信用卡,一个cvc号码,但我收到一个错误,我不知道我必须如何创建它。

I show my code

我展示了我的代码

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;*/

            });
        }

1 个解决方案

#1


3  

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;*/

            });

the answer should be somthing like this

答案应该是这样的

{ 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 }

take the required field from it i think you will need only the customer id from tha result object.

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

#1


3  

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;*/

            });

the answer should be somthing like this

答案应该是这样的

{ 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 }

take the required field from it i think you will need only the customer id from tha result object.

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