I am using Braintree hosted fields to process payments, however I am having issues locating or finding example in how to submit existing payment methods for customers. Using the braintree_customer_id I can retrieve customer information including the creditCards array that contains the last4 digits, cardType, token and other information. Since I am using using hosted fields, the javascript I have used looks something like:
braintree.setup("<?= $clientToken ?>", 'custom', {
id: 'my-form',
hostedFields: {
styles: {
'input': {
'font-family': '"Helvetica Neue", Helvetica, Arial, sans-serif',
'font-size': '14px',
},
'::-moz-placeholder': { 'color': '#999' },
':-ms-input-placeholder': { 'color': '#999' },
'::-webkit-input-placeholder': { 'color': '#999' },
},
number: {
selector: '#hosted-fields-number',
placeholder: 'Credit Card Number'
},onFieldEvent: handleFieldEvent,
cvv: {
selector: '#hosted-fields-cvv',
placeholder: 'CVV'
},
expirationDate: {
selector: '#hosted-fields-expiration',
placeholder: 'Expiration Date'
}
}, onPaymentMethodReceived: function (obj) {
var nonce = obj.nonce;
console.log(obj);
if(nonce){
final_checkout(nonce);
}
},
onError: function (){
alert('wrong details');
}
});
How do i obtain a payment method nonce needed to be able to execute my payment process? The below example is using hosted fields, how do I handle existing customers using the customer_id and token?