Skip to content

feat: add PingPay subscription payment integration#130

Draft
petersalomonsen wants to merge 2 commits into
mainfrom
feat/pingpay-subscriptions
Draft

feat: add PingPay subscription payment integration#130
petersalomonsen wants to merge 2 commits into
mainfrom
feat/pingpay-subscriptions

Conversation

@petersalomonsen

Copy link
Copy Markdown
Collaborator

Summary

  • Add PingPay integration for treasury subscription payments
  • Users can pay in any token, Trezu receives USDC
  • Upfront payment model (3, 6, or 12 month plans)

Changes

Backend (Rust)

  • Database migration: Tables for plans, subscriptions, payments, invoices
  • PingPay client: API client for checkout session creation
  • API endpoints:
    • GET /api/subscriptions/plans - List available plans
    • GET /api/subscriptions/status - Check subscription status
    • POST /api/subscriptions/checkout - Create checkout session
    • GET /api/subscriptions/callback - Handle payment redirect
  • Environment variables: PingPay API configuration

Documentation

  • Implementation plan in docs/implementation-plans/pingpay-subscription-integration.md

Still TODO

  • Mock PingPay service for sandbox testing
  • Frontend subscription tab in settings
  • Invoice generation
  • Tests
  • Get PingPay API key and configure dashboard

Test plan

  1. Run migrations: sqlx migrate run
  2. Start backend with PingPay env vars
  3. Test endpoints:
    • GET /api/subscriptions/plans returns 3 plans
    • GET /api/subscriptions/status?account_id=test.near returns status
    • POST /api/subscriptions/checkout creates session (requires API key)

Related

🤖 Generated with Claude Code

Integrate PingPay for treasury subscription payments, allowing users to
pay in any token while Trezu receives USDC.

Backend implementation includes:
- Database migration for subscription tables (plans, subscriptions,
  payments, invoices)
- PingPay client for checkout session creation
- API endpoints: plans, status, checkout, callback
- Environment variables for PingPay configuration

API Endpoints:
- GET /api/subscriptions/plans - List available plans (3m, 6m, 12m)
- GET /api/subscriptions/status - Check treasury subscription status
- POST /api/subscriptions/checkout - Create PingPay checkout session
- GET /api/subscriptions/callback - Handle payment redirect

Closes #120

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- `txStatus` - `SUCCESS` | `FAILED` | `REFUNDED`
- `depositAddress` - Transaction reference

## Database Schema

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bit sad that we didt clarify and both doing own ways haha

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe - I am only in draft mode. I was going to check with you. I think I will adjust to your schema, but I just had to have something to play with while waiting

- Fix response structs to match actual PingPay API (amount is object,
  recipient is object with address, not flat strings)
- Fix double /api in URL construction for PingPay client
- Fix callback URLs to route through backend before redirecting to
  frontend (PingPay → backend callback → frontend success/cancel)
- Add BACKEND_URL env var for constructing PingPay callback URLs
- Update implementation plan with verified API responses, remaining
  frontend/mock/invoice/test work documented in detail

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate pingpay.io for payments

2 participants