Last active
April 27, 2017 16:22
-
-
Save turboza/72c1affbeb38700e03c4c7809d67875c to your computer and use it in GitHub Desktop.
Sample of charging card using Node.js express
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
const omise = require('omise')({ | |
secretKey: 'skey_test_...', | |
}); | |
app.post('/pay', function(req, res) { | |
const tokenId = req.body.tokenId, | |
omise.charges.create({ | |
description: 'Charge for order ID: 888', | |
amount: '100000', // 1,000 Baht | |
currency: 'thb', | |
card: tokenId | |
}, function(err, resp) { | |
if (resp.paid) { | |
// Success | |
} else { | |
// Handle failure here | |
throw resp.failure_code; | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment