Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BrainTree: get all customer's payment methods

Tags:

braintree

There is a way to get a list of all cards:

gateway.creditCard.expiringBetween(year1900, year2100, function (err, result) {...})

and then call paymentMethod.find for each individual card. But I would like to get all payment methods associated with a customer, in one call, is this possible?

like image 349
punund Avatar asked Mar 18 '23 00:03

punund


2 Answers

I work at Braintree. If you have more questions, you can always get in touch with our support team.

A customer is serialized with all of its payment methods.

So, get the customer and then get the credit cards and paypal accounts from it:

gateway.customer.find("theCustomerId", function(err, customer) {
    var payment_methods = customer.creditCards.concat(customer.paypalAccounts);
});
like image 143
agf Avatar answered May 14 '23 15:05

agf


I figured that. gateway.customer.find returns an object with property creditCards, just wasn't obvious from the documentation.

like image 22
punund Avatar answered May 14 '23 13:05

punund