我正在阅读有关创建客户的文档。我需要用信用卡,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;*/
});
}
答案 0 :(得分: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;*/
});
答案应该是这样的事情
{ 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。