Skip to content

feat: Add payment API for fake Algora#4

Open
buildingvibes wants to merge 1 commit intotscircuit:mainfrom
buildingvibes:add-payment-api
Open

feat: Add payment API for fake Algora#4
buildingvibes wants to merge 1 commit intotscircuit:mainfrom
buildingvibes:add-payment-api

Conversation

@buildingvibes
Copy link
Copy Markdown

@buildingvibes buildingvibes commented Feb 10, 2026

Summary

Implements a complete payment API for simulating bounty payments in fake Algora. This provides a mock payment system for testing bounty payment workflows.

Fixes #1

Features

Payment Management:

  • Create payments with recipient, amount, and optional bounty metadata
  • List payments with optional filters (recipient, status)
  • Get payment by ID
  • Complete/mark payments as successful

Database Schema:

  • Added Payment model with fields:
    • payment_id: Unique identifier (auto-generated)
    • recipient: User receiving the payment
    • amount: Payment amount (positive number)
    • currency: Currency code (default: USD)
    • status: pending | completed | failed
    • bounty_id: Optional bounty identifier
    • issue_number: Optional GitHub issue number
    • repository: Optional repository name
    • created_at: Timestamp of creation
    • completed_at: Timestamp of completion

API Endpoints

POST /payments/create

Create a new payment.

Request:

{
  "recipient": "user123",
  "amount": 100,
  "currency": "USD",
  "bounty_id": "bounty_456",
  "issue_number": 123,
  "repository": "tscircuit/test-repo"
}

Response:

{
  "payment": {
    "payment_id": "pay_0",
    "recipient": "user123",
    "amount": 100,
    "currency": "USD",
    "status": "pending",
    "bounty_id": "bounty_456",
    "issue_number": 123,
    "repository": "tscircuit/test-repo",
    "created_at": "2026-02-09T18:00:00.000Z"
  }
}

GET /payments/list

List all payments with optional filters.

Query Parameters:

  • recipient (optional): Filter by recipient
  • status (optional): Filter by status (pending, completed, failed)

Response:

{
  "payments": [ ... ]
}

GET /payments/get

Get a specific payment by ID.

Query Parameters:

  • payment_id (required): Payment ID

Response:

{
  "payment": { ... }
}

POST /payments/complete

Mark a payment as completed.

Request:

{
  "payment_id": "pay_0"
}

Response:

{
  "ok": true
}

Testing

Comprehensive test coverage for all endpoints:

  • Payment creation with all fields
  • Payment creation with minimal fields
  • Listing all payments
  • Filtering payments by recipient
  • Completing payments and verifying status changes

Test Results:

bun test v1.3.9 (cf6cdbbb)

 7 pass
 0 fail
 20 expect() calls
Ran 7 tests across 5 files. [92.00ms]

Implementation Details

  • Uses Zustand for state management
  • Follows existing code patterns (winterspec, zod validation)
  • Auto-incrementing payment IDs
  • ISO timestamp generation for created_at and completed_at
  • Type-safe implementation with TypeScript and Zod schemas

/claim #1

Implements a complete payment API for simulating bounty payments. The API includes:

**Features:**
- Create payments with recipient, amount, and optional bounty metadata
- List payments with optional filters (recipient, status)
- Get payment by ID
- Complete/mark payments as successful

**Database Schema:**
- Added `Payment` model with fields: payment_id, recipient, amount, currency, status, bounty_id, issue_number, repository, timestamps
- Payment status: pending, completed, failed

**API Endpoints:**
- POST /payments/create - Create a new payment
- GET /payments/list - List all payments with optional filters
- GET /payments/get - Get a specific payment by ID
- POST /payments/complete - Mark a payment as completed

**Testing:**
- Comprehensive test coverage for all endpoints
- Tests verify creation, listing, filtering, and completion workflows
- All 7 tests passing

/claim tscircuit#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bootstrap w/ API for sending payment

1 participant