Skip to content

agendaedu/webhook-handler

Repository files navigation

Pagar.me Webhook Handler - Interview Challenge

A Ruby on Rails API that handles pagar.me webhooks with PostgreSQL database.

Setup with Docker Compose (Recommended)

  1. Start the services:
docker-compose up

This will start both the PostgreSQL database and the Rails application. The database will be created and migrated automatically.

Manual Setup (Alternative)

  1. Start PostgreSQL database:
docker-compose up -d db
  1. Install dependencies:
bundle install
  1. Setup database:
rails db:create
rails db:migrate
  1. Seed some test data:
rails db:seed
  1. Start the server:
rails server

API Endpoints

  • POST /webhooks/pagar_me - Handles pagar.me webhooks
  • GET /clients/:id/balance - Returns client balance

Testing the API

Post a webhook event

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
        }
      }]
    }
  }'

Get client balance

curl -X GET http://localhost:3000/clients/1/balance \
  -H "Content-Type: application/json"

About

Pagar.me Webhook Handler - Interview Challenge

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published