I am trying out Braintree in sandbox mode using the Drop-in feature.
I am creating a Client token using an existing customerID
. But when I make transaction.sale
call with this customerId
and the option storeInVault = true
it gives error the following error:
Sale Customer ID has already been taken.
As per the documentation it should update the customer with the payment nonce.
Here is the code:
gateway.transaction.sale({
amount: '10.00',
paymentMethodNonce: nonceFromTheClient, // Generated nonce passed from client
customer: {
id: 232057823, //this customer exist in the vault
email : user.emails[0].address
},
options: {
submitForSettlement: true,
storeInVault: true
//storeInVaultOnSuccess: true
}
}, function (err, result) {
if (err) {
console.log(err);
} else {
if (result.success) {
return result.success;
} else {
console.log('ERR Sale '+result.message);
return result.success;
}
}
});
I'm using Meteor with the package patrickml:braintree
.
You look to be using the Braintree Transaction Sale API Call, in which you have included the storeInVault: true option. What this is doing is creating a transaction with the included payment method nonce and attempting to create a customer id of 232057823, which is why you are encountering that error.
If your goal is to simply update an existing customer, you'd want to use the Customer Update API call.