Skip to main content
Under Reviewv0.1.0-alpha

Payments Module

The Payments module orchestrates transaction flows with external payment gateways, handles callbacks/webhooks, maintains audit state of payment intents, and manages administrative tasks such as listing and refunds.


Overview

The payments subsystem provides abstraction over multiple third-party payment providers (e.g., Stripe, PayPal, PayHere). It facilitates:

  • Payment Intents: Initiating payments for pending customer orders.
  • Provider Callbacks: Processing asynchronous webhooks or return URLs to verify transaction results.
  • Admin Actions: Refunding successful transactions and listing execution history.
  • Event-Driven Workflows: Publishing payment.succeeded or payment.failed to notify downstream services (Inventory, Orders).

Architecture


API Routes

Customer Endpoints

MethodRouteDescriptionAuth
POST/payments/intentCreates a transaction intent with a specified/default providerYes (Customer)
POST/payments/callback/:providerReceives status callbacks/webhooks from the payment gatewayNo (Public)

Admin Endpoints

MethodRouteDescriptionAuth
GET/admin/paymentsLists all payment logs/transactionsYes (Admin)
POST/admin/payments/refundInitiates a refund for a specific paid orderYes (Admin)

Data Model

StatusDescription
pendingIntent created, awaiting completion
succeededSuccessfully captured
failedFailed to capture
refundedRefunded by admin

Key Flows

Create Payment Intent

Process Payment Callback (Webhook)

Admin Refund


Event Subscriptions

EventTriggerConsumers
payment.succeededConfirmation succeedsOrders module (mark paid), Inventory (finalize reservations)
payment.failedPayment failsInventory (release reservations)