user10108817
user10108817

Reputation: 285

Braintree / Javascript: how to get transaction data (card and address) to prefill for customers with previous transactions?

I am using Braintree's Hosted Fields and Javascript. I am successfully able to do a successful signup and sending a payment nonce however I am unable to figure out how to have a user who already has a subscription in the Braintree portal to show up with their information preloaded in the Braintree Hosted Fields already (address, part of credit card, etc).

Upvotes: 0

Views: 690

Answers (1)

turaco
turaco

Reputation: 86

The only address field in Hosted Fields is the postal code. You may need to build a custom form to populate the additional address values.

You can grab Vault data from your server using a payment method lookup. Then you can prefill the data in Hosted Fields.

Here is an example that shows how to use prefilled values for the expiration date:

var storedCreditCardInformation = {   
  // get this info from your server with a payment method lookup   
  month: '09',   
  year: '2017' 
}; 

braintree.hostedFields.create({   
  client: clientInstance,   
  fields: {     
    expirationMonth: {       
      selector: '#expiration-month',       
      prefill: storedCreditCardInformation.month     
    },     
    expirationYear: {       
      selector: '#expiration-year',       
      prefill: storedCreditCardInformation.year     
    }   
  } 
}, 
callback);

Full Disclosure: I work at Braintree. For additional questions, please feel free to contact Braintree Support [email protected].

Upvotes: 1

Related Questions