Skip to content

Instantly share code, notes, and snippets.

@LeoNero
Last active September 28, 2017 19:53
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 LeoNero/649f9168dc0470b3a35aef24503c3e44 to your computer and use it in GitHub Desktop.
Save LeoNero/649f9168dc0470b3a35aef24503c3e44 to your computer and use it in GitHub Desktop.
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')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment