Search code examples
braintree

BrainTree: get all customer's payment methods


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?


Solution

  • 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);
    });