Skip to main content

Payment Approve / Reject

Discord buttons for admin approval or rejection of P2P payments.

Source: src/data/payment/payment.command.ts

Button custom IDs

PatternTypeDescription
payment:approve:<paymentId>ButtonAdmin approves the payment
payment:reject:<paymentId>ButtonAdmin clicks to open reject-reason modal
payment:reject-modal:<paymentId>Modal submitAdmin submits rejection reason

Approve flow

  1. Admin sees the approval embed posted to the admin channel.
  2. Admin clicks Approve.
  3. Bot checks admin role via isAdmin.
  4. Bot calls PaymentService.confirmPayment(ctx, paymentId, adminUserId).
  5. Bot replies with an ephemeral "Payment confirmed" message.
  6. Bot posts a thread/channel message: Payment for order \ORD-XXX` confirmed by @admin`.

Reject flow

  1. Admin clicks Reject.
  2. Bot checks admin role, then opens the rejection reason modal.
  3. Admin submits a reason (3–500 characters).
  4. Bot calls PaymentService.rejectPayment(ctx, paymentId, adminUserId, reason).
  5. Bot replies with an ephemeral "Payment rejected" message.
  6. Bot posts a thread/channel message with the reason.

Permission requirement

Both flows call isAdmin(tenantId, memberRoleIds) before proceeding. Unauthorized users receive an ephemeral error.

Wiring

The handlers are registered in discord-command-router.ts via the paymentCommands dependency:

createDiscordCommandRouter({
// ...
paymentCommands: {
paymentService,
sendThreadMessage, // optional — omit if thread posting not needed
},
})