Skip to content

Instantly share code, notes, and snippets.

@turboza
Last active April 27, 2017 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save turboza/72c1affbeb38700e03c4c7809d67875c to your computer and use it in GitHub Desktop.
Save turboza/72c1affbeb38700e03c4c7809d67875c to your computer and use it in GitHub Desktop.
Sample of charging card using Node.js express
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