A Ruby on Rails API that handles pagar.me webhooks with PostgreSQL database.
- Start the services:
docker-compose upThis will start both the PostgreSQL database and the Rails application. The database will be created and migrated automatically.
- Start PostgreSQL database:
docker-compose up -d db- Install dependencies:
bundle install- Setup database:
rails db:create
rails db:migrate- Seed some test data:
rails db:seed- Start the server:
rails serverPOST /webhooks/pagar_me- Handles pagar.me webhooksGET /clients/:id/balance- Returns client balance
curl -X POST http://localhost:3000/webhooks/pagar_me \
-H "Content-Type: application/json" \
-d '{
"id": "hook_test_1",
"type": "order.paid",
"data": {
"customer": {
"email": "test@example.com"
},
"charges": [{
"last_transaction": {
"amount": 10000
}
}]
}
}'curl -X GET http://localhost:3000/clients/1/balance \
-H "Content-Type: application/json"