Last active
August 29, 2015 14:07
-
-
Save qcom/cc16c1eec449ce90e99f to your computer and use it in GitHub Desktop.
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
async.waterfall([ | |
soap.createClient.bind(null, process.cwd() + '/util/usaepay.wsdl'), | |
function(client, cb) { | |
client.runSale(args, cb); | |
}, | |
function(result, body, cb) { | |
if (result.runSaleReturn.ResultCode.$value === 'E') { | |
return new Error('failed to process'); | |
} else if (result.runSaleReturn.ResultCode.$value === 'A') { | |
return cb(null, result); | |
} else { | |
return cb('declined'); | |
} | |
function(result, cb) { | |
app.get('db').verifyAd(result.runSaleReturn.RefNum.$value, req.session.user.id, cb); | |
}, | |
function(result, cb) { | |
sendMail(req.session.user.email, | |
app.get('transporter'), | |
details.service_type, | |
mixin(result, { price : details.price }), | |
cb); | |
} | |
], function(err, result) { | |
if (err === 'declined') { | |
res.render('declined'); | |
} else if (err) { | |
next(err); | |
} else { | |
res.render('authorized'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With promises this would look like (I'm assuming here):