Skip to content

luanlopez/payment-gateway-in-rust

Repository files navigation

Payment Gateway

A Rust-based payment gateway service with PostgreSQL database.

Prerequisites

  • Docker
  • Docker Compose

Quick Start

  1. Start the services:

    docker-compose up -d
  2. Wait for PostgreSQL to be ready and run migrations:

    ./scripts/setup.sh
  3. Build and run the application:

    docker-compose up app

Development

Local Development with Docker

  1. Start only PostgreSQL:

    docker-compose up -d postgres
  2. Set environment variables:

    export DATABASE_URL=postgresql://postgres:postgres@localhost:5432/payment_gateway
  3. Run migrations:

    ./scripts/setup.sh
  4. Build and run locally:

    cargo run

Database Schema

The application uses the following table structure:

CREATE TABLE payments (
    id VARCHAR(255) PRIMARY KEY,
    amount DECIMAL(10,2) NOT NULL,
    status VARCHAR(50) NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE NOT NULL,
    updated_at TIMESTAMP WITH TIME ZONE NOT NULL
);

API Endpoints

  • POST /payments - Create a new payment
  • GET /payments/{id} - Get payment by ID
  • PUT /payments/{id}/status - Update payment status

Environment Variables

  • DATABASE_URL - PostgreSQL connection string
  • PORT - Application port (default: 8080)

Stopping Services

docker-compose down

To remove volumes as well:

docker-compose down -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published