punund
punund

Reputation: 4421

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?

Upvotes: 6

Views: 3035

Answers (2)

agf
agf

Reputation: 176950

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

Upvotes: 9

punund
punund

Reputation: 4421

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

Upvotes: 2

Related Questions