Last active
September 28, 2017 19:53
-
-
Save LeoNero/649f9168dc0470b3a35aef24503c3e44 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
const express = require('express') | |
const bodyParser = require('body-parser') | |
const methodOverride = require('method-override') | |
const axios = require('axios') | |
const app = express() | |
app.use(bodyParser.urlencoded({ extended: false })) | |
app.use(bodyParser.json()) | |
app.use(methodOverride()) | |
app.post('/comprar', (req, res) => { | |
console.log(JSON.stringify(req.body, null, 4)) | |
const { token_id, amount } = req.body | |
const api_key = 'suaapikeyaqui' | |
const url = `https://api.pagar.me/1/transactions/${token_id}/capture` | |
axios | |
.post(url, { | |
amount, | |
api_key, | |
}) | |
.then(console.log) | |
.catch(console.log) | |
}) | |
app.listen(3000, () => { | |
console.log('Vc iniciou o server') | |
}); |
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
:D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment