Skip to content

Instantly share code, notes, and snippets.

@billforward-alex
Created March 4, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billforward-alex/0cee8034839cc4295eab to your computer and use it in GitHub Desktop.
Save billforward-alex/0cee8034839cc4295eab to your computer and use it in GitHub Desktop.
Get Default Payment Method
BillForward.Account.getByID('ACC-81674A80-3B2D-4327-8C24-994720BA')
.then(function(account) {
// you might want to take a peek at the account
// console.log(account.toString());
// get relevant payment method:
var paymentMethod =_.findWhere(account.paymentMethods, {'defaultPaymentMethod': true});
if (paymentMethod === undefined) throw new Error("No default payment method found for this account. Of course it is still possible that this account can pay via credit or 'offline payments'.");
// the SDK seems to have an unserialization problem; we need to manually tell JavaScript that this JSON is a BillForward.PaymentMethod:
var _paymentMethod = new BillForward.PaymentMethod(paymentMethod);
})
.done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment