Last active
August 29, 2015 14:06
-
-
Save rootedsoftware/e7ad49f80fdf9dc3905f to your computer and use it in GitHub Desktop.
Balanced function
This file contains 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
debit_order: function (data, order, paymentObject) { | |
logger.info("Inside debit_order."); | |
var debit; | |
debit = extractFromPromise(balanced.get(order).debit_from(paymentObject, ({ "amount": data.paymentInformation[0].total_amount * 100, | |
"appears_on_statement_as": "Trash Mountain"}))); | |
var bank_account = extractFromPromise(balanced.get(Meteor.settings.devBankAccount)); | |
var credit; | |
credit = extractFromPromise(balanced.get(order).credit_to(bank_account, 103)); | |
//add debit response from Balanced to the database | |
var debitReponse = Donate.update(data._id, {$set: { | |
'debit.type': debit.type, | |
'debit.customer': debit.links.customer, | |
'debit.total_amount': debit.amount / 100, | |
'debit.id': debit.id, | |
'debit.status': debit.status, | |
'card_holds.id': debit.links.card_hold | |
}}); | |
console.log("Finished balanced order debit"); | |
return debit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment