Created
March 2, 2015 15:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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