Payments Specification
Status: Canonical Last Updated: 2026-05-11 Source:Doc Status: Excellent | ✓ All 6 checks passedpackages/backend/convex/domains/payments.ts,packages/backend/convex/http/onepay.ts
Overview
OnePay handles payment processing for the booking system. Guests are redirected to OnePay for payment, which returns with a verified response that updates the reservation status. OnePay supports both card payments and virtual account (bank transfer) options.Related specs
- Tech Stack — External integration patterns
- Data Model — reservations, payments, notificationLogs tables
- Booking Flow — Checkout step integrates with payments
- Notifications — EMAIL_CONFIRMATION, WHATSAPP_CONFIRMATION after payment
- Admin Dashboard — Event payments view in admin
- User Stories — US-B01, US-B02 cover payment flow
Payment Flow
| Step | Description |
|---|---|
| 1. User on checkout page | Fills customer info, clicks “Pay Now” |
| 2. Create pending reservation | status: PENDING, paymentStatus: PENDING, bookingExpiresAt: now + 10 min |
| 3. Call OnePay API | Create payment URL with amount, order info, redirect user to OnePay |
| 4. User completes payment on OnePay | Success — redirect to /booking/[id]/confirmation; Fail — redirect to /booking/[id]/checkout?error=… |
| 5. Handle return | Verify OnePay signature, update reservation status, create payment record, send confirmation email |
OnePay Integration
Configuration
Environment variables (via npx convex env set):Payment URL Creation
Return URL Handling
Payment Status
| Status | Description | Action |
|---|---|---|
| PENDING | Awaiting payment | User redirected to OnePay |
| PAID | Payment successful | Confirmation sent |
| FAILED | Payment failed | Show error, allow retry |
| CANCELLED | User cancelled | Release seats |
| REFUND_PENDING | Refund requested | Admin processes |
| REFUNDED | Refund completed | Notify customer |
Virtual Account (Bank Transfer)
Flow
- User selects bank transfer
- System generates VA number
- User transfers to VA
- OnePay notifies on receipt
- Payment marked PAID
VA Number Display
Shown on checkout for bank transfer option.Payment Tracking
payments Table
Stores all OnePay transactions:- vpcMerchTxnRef: Unique reference
- vpcTransactionNo: OnePay transaction ID
- amount: VND amount
- status: PENDING | SUCCESS | FAILED
- card: Card type (Visa, Mastercard)
- cardNum: Last 4 digits
notificationLogs Table
Tracks delivery of confirmations:- EMAIL_CONFIRMATION
- WHATSAPP_CONFIRMATION
- EMAIL_ADMIN_NEW_BOOKING
Refund Flow
Implementation
The refund flow uses OnePay V2 API for asynchronous refund processing:Flow
- Admin opens reservation detail
- Clicks “Cancel & Refund”
cancelReservationmutation sets status toREFUND_PENDINGtriggerSepayRefundcallscreateOnePayRefund(OnePay V2 API)- OnePay processes refund asynchronously
- OnePay calls webhook with refund confirmation
- Webhook handler calls
confirmRefundmutation - Mutation sets status to
REFUNDED - Notification sent (email/cancellation)