Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save billforward-alex/20dc590180c5a95f7d8e to your computer and use it in GitHub Desktop.
Elect a payment method on account to be the 'default' payment method recruited by that account's subscriptions
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, {'gateway': 'stripe'});
// the SDK seems to have an unserialization problem; we need to manually tell JavaScript that this JSON is a BillForward.PaymentMethod:
_paymentMethod = new BillForward.PaymentMethod(paymentMethod);
// set as default payment method
_paymentMethod.defaultPaymentMethod = true;
// PUT changes to API
return _paymentMethod.save();
})
.done();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment