# goride-app/goride-payment architecture

> Architecture diagram of the GitHub repository goride-app/goride-payment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/goride-app/goride-payment
- Repository: https://github.com/goride-app/goride-payment

## Overview

GoRide Payment accepts trusted trip-completion events, then lets riders select card payment and pay after the trip through saved demo cards or PayHere sandbox checkout. Verified provider notices commit paid state, in-app confirmation, email receipt, and driver notification together; riders and drivers can then read their respective results. The map also includes card management, receipt resend, status, and driver notification delivery. Relationships are cited to the README where the sampled source does not show the runtime call; unsampled implementation details are not inferred.

Main entry points: [`src/GoRide.Payment/Verification/PaymentVerificationService.cs`](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Verification/PaymentVerificationService.cs) (Notice verification), [`src/GoRide.Payment/Controllers/PaymentsController.cs`](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/PaymentsController.cs) (Payment API), [`src/GoRide.Payment/Checkout/TripCompletionService.cs`](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/TripCompletionService.cs) (Trip completion), [`src/GoRide.Payment/Data/PaymentStore.cs`](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Data/PaymentStore.cs) (Payment records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and identity"]
  node_api["Payment API"]
  node_cards_api["Card API<br/>[CardsController.cs]"]
  node_driver_api["Driver feed API"]
  node_identity["Identity session"]
  node_trip_events["Trip event intake"]
  node_event_consumer["Trip event consumer"]
end

subgraph group_trip["Trip and payment"]
  node_completion["Trip completion"]
  node_payment_data[("Payment records<br/>[PaymentStore.cs]")]
  node_payment_rules["Payment rules<br/>[PaymentRules.cs]"]
  node_card_service["Saved cards<br/>[CardService.cs]"]
  node_card_payment["Demo card charge"]
  node_card_store[("Card storage<br/>[CardStore.cs]")]
  node_card_attempts[("Card attempts")]
  node_payment_record["Payment model<br/>[PaymentRecord.cs]"]
  node_trip_event["Completion event model"]
  node_demo_cards["Demo card data<br/>[DemoCards.cs]"]
  node_status["Payment status"]
end

subgraph group_provider["Checkout and verification"]
  node_checkout["PayHere checkout<br/>[CheckoutService.cs]"]
  node_checkout_store[("Checkout orders<br/>[CheckoutStore.cs]")]
  node_verification_api["Provider notice API"]
  node_verification["Notice verification"]
  node_verification_store[("Verification records")]
end

subgraph group_outcomes["Payment outcomes"]
  node_confirmation["In-app confirmation"]
  node_confirmation_store[("Confirmation records")]
  node_receipt_service["Receipt access<br/>[ReceiptService.cs]"]
  node_receipt_store[("Receipt outbox<br/>[ReceiptStore.cs]")]
  node_receipt_dispatch["Receipt delivery"]
  node_driver_notifications[("Driver notifications")]
end

node_rider(("Rider app"))
node_driver(("Driver app"))
node_trip_service(("Trip service"))
node_payhere{{"PayHere sandbox"}}
node_brevo{{"Brevo email"}}

node_trip_service -->|"posts completion"| node_trip_events
node_trip_events -->|"records trip"| node_completion
node_completion -->|"saves fare"| node_payment_data
node_rider -->|"requests payment"| node_api
node_api -->|"authenticates rider"| node_identity
node_api -->|"opens checkout"| node_checkout
node_checkout -->|"stores order"| node_checkout_store
node_checkout -->|"returns signed form"| node_payhere
node_payhere -->|"sends notice"| node_verification_api
node_verification_api -->|"verifies notice"| node_verification
node_verification -->|"records outcome"| node_verification_store
node_verification -->|"commits paid state"| node_payment_data
node_verification -->|"creates confirmation"| node_confirmation_store
node_verification -->|"creates outbox entry"| node_receipt_store
node_verification -->|"creates snapshot"| node_driver_notifications
node_rider -->|"manages cards"| node_cards_api
node_cards_api -->|"requests card action"| node_card_service
node_card_service -.->|"stores card"| node_card_store
node_card_payment -.->|"records attempts"| node_card_attempts
node_card_payment -.->|"charges saved card"| node_payment_data
node_rider -->|"views confirmation"| node_confirmation
node_rider -->|"views or resends"| node_receipt_service
node_receipt_dispatch -.->|"claims receipt"| node_receipt_store
node_receipt_dispatch -->|"sends email"| node_brevo
node_driver -->|"reads feed"| node_driver_api
node_driver_api -->|"reads notifications"| node_driver_notifications
node_api -.->|"reads status"| node_status
node_event_consumer -->|"processes event"| node_completion
node_payment_data -->|"persists model"| node_payment_record
node_completion -->|"validates completion"| node_payment_rules
node_card_service -->|"uses test data"| node_demo_cards

click node_api "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/PaymentsController.cs"
click node_cards_api "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/CardsController.cs"
click node_driver_api "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/DriverNotificationsController.cs"
click node_identity "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Auth/IdentitySessionHandler.cs"
click node_trip_events "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/TripEventsController.cs"
click node_completion "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/TripCompletionService.cs"
click node_payment_data "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Data/PaymentStore.cs"
click node_payment_rules "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Services/PaymentRules.cs"
click node_card_service "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardService.cs"
click node_card_payment "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardPaymentService.cs"
click node_card_store "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardStore.cs"
click node_card_attempts "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardAttemptStore.cs"
click node_checkout "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/CheckoutService.cs"
click node_checkout_store "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/CheckoutStore.cs"
click node_verification_api "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/ProviderNotificationsController.cs"
click node_verification "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Verification/PaymentVerificationService.cs"
click node_verification_store "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Verification/VerificationStore.cs"
click node_confirmation "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Confirmation/ConfirmationService.cs"
click node_confirmation_store "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Confirmation/ConfirmationStore.cs"
click node_receipt_service "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptService.cs"
click node_receipt_store "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptStore.cs"
click node_receipt_dispatch "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptDispatcher.cs"
click node_driver_notifications "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/DriverNotifications/DriverNotificationStore.cs"
click node_event_consumer "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Events/TripEventConsumer.cs"
click node_payment_record "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Models/PaymentRecord.cs"
click node_trip_event "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Models/TripCompletedEvent.cs"
click node_demo_cards "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/DemoCards.cs"
click node_status "https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Services/PaymentStatusService.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_cards_api,node_driver_api,node_identity,node_trip_events,node_event_consumer toneBlue
class node_completion,node_payment_data,node_payment_rules,node_card_service,node_card_payment,node_card_store,node_card_attempts,node_payment_record,node_trip_event,node_demo_cards,node_status toneAmber
class node_checkout,node_checkout_store,node_verification_api,node_verification,node_verification_store toneMint
class node_confirmation,node_confirmation_store,node_receipt_service,node_receipt_store,node_receipt_dispatch,node_driver_notifications toneRose
class node_rider,node_driver,node_trip_service,node_payhere,node_brevo toneIndigo
```

## Components

### API and identity

- [Payment API](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/PaymentsController.cs): `src/GoRide.Payment/Controllers/PaymentsController.cs`
- [Card API](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/CardsController.cs): `src/GoRide.Payment/Controllers/CardsController.cs`
- [Driver feed API](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/DriverNotificationsController.cs): `src/GoRide.Payment/Controllers/DriverNotificationsController.cs`
- [Identity session](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Auth/IdentitySessionHandler.cs): `src/GoRide.Payment/Auth/IdentitySessionHandler.cs`
- [Trip event intake](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/TripEventsController.cs): `src/GoRide.Payment/Controllers/TripEventsController.cs`
- [Trip event consumer](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Events/TripEventConsumer.cs): `src/GoRide.Payment/Events/TripEventConsumer.cs`

### Trip and payment

- [Trip completion](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/TripCompletionService.cs): `src/GoRide.Payment/Checkout/TripCompletionService.cs`
- [Payment records](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Data/PaymentStore.cs): `src/GoRide.Payment/Data/PaymentStore.cs`
- [Payment rules](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Services/PaymentRules.cs): `src/GoRide.Payment/Services/PaymentRules.cs`
- [Saved cards](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardService.cs): `src/GoRide.Payment/Cards/CardService.cs`
- [Demo card charge](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardPaymentService.cs): `src/GoRide.Payment/Cards/CardPaymentService.cs`
- [Card storage](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardStore.cs): `src/GoRide.Payment/Cards/CardStore.cs`
- [Card attempts](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/CardAttemptStore.cs): `src/GoRide.Payment/Cards/CardAttemptStore.cs`
- [Payment model](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Models/PaymentRecord.cs): `src/GoRide.Payment/Models/PaymentRecord.cs`
- [Completion event model](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Models/TripCompletedEvent.cs): `src/GoRide.Payment/Models/TripCompletedEvent.cs`
- [Demo card data](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Cards/DemoCards.cs): `src/GoRide.Payment/Cards/DemoCards.cs`
- [Payment status](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Services/PaymentStatusService.cs): `src/GoRide.Payment/Services/PaymentStatusService.cs`

### Checkout and verification

- [PayHere checkout](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/CheckoutService.cs): `src/GoRide.Payment/Checkout/CheckoutService.cs`
- [Checkout orders](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Checkout/CheckoutStore.cs): `src/GoRide.Payment/Checkout/CheckoutStore.cs`
- [Provider notice API](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Controllers/ProviderNotificationsController.cs): `src/GoRide.Payment/Controllers/ProviderNotificationsController.cs`
- [Notice verification](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Verification/PaymentVerificationService.cs): `src/GoRide.Payment/Verification/PaymentVerificationService.cs`
- [Verification records](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Verification/VerificationStore.cs): `src/GoRide.Payment/Verification/VerificationStore.cs`

### Payment outcomes

- [In-app confirmation](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Confirmation/ConfirmationService.cs): `src/GoRide.Payment/Confirmation/ConfirmationService.cs`
- [Confirmation records](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Confirmation/ConfirmationStore.cs): `src/GoRide.Payment/Confirmation/ConfirmationStore.cs`
- [Receipt access](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptService.cs): `src/GoRide.Payment/Receipts/ReceiptService.cs`
- [Receipt outbox](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptStore.cs): `src/GoRide.Payment/Receipts/ReceiptStore.cs`
- [Receipt delivery](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/Receipts/ReceiptDispatcher.cs): `src/GoRide.Payment/Receipts/ReceiptDispatcher.cs`
- [Driver notifications](https://github.com/goride-app/goride-payment/blob/dev/src/GoRide.Payment/DriverNotifications/DriverNotificationStore.cs): `src/GoRide.Payment/DriverNotifications/DriverNotificationStore.cs`

### Other components

- **Rider app**
- **Driver app**
- **Trip service**
- **PayHere sandbox**
- **Brevo email**

## Connections

- Trip service → Trip event intake: posts completion (evidence: `README.md`)
- Trip event intake → Trip completion: records trip (evidence: `src/GoRide.Payment/Controllers/TripEventsController.cs`)
- Trip completion → Payment records: saves fare (evidence: `src/GoRide.Payment/Checkout/TripCompletionService.cs`)
- Rider app → Payment API: requests payment (evidence: `README.md`)
- Payment API → Identity session: authenticates rider (evidence: `README.md`)
- Payment API → PayHere checkout: opens checkout (evidence: `README.md`)
- PayHere checkout → Checkout orders: stores order (evidence: `src/GoRide.Payment/Checkout/CheckoutService.cs`)
- PayHere checkout → PayHere sandbox: returns signed form (evidence: `README.md`)
- PayHere sandbox → Provider notice API: sends notice (evidence: `README.md`)
- Provider notice API → Notice verification: verifies notice (evidence: `src/GoRide.Payment/Controllers/ProviderNotificationsController.cs`)
- Notice verification → Verification records: records outcome (evidence: `src/GoRide.Payment/Verification/PaymentVerificationService.cs`)
- Notice verification → Payment records: commits paid state
- Notice verification → Confirmation records: creates confirmation
- Notice verification → Receipt outbox: creates outbox entry
- Notice verification → Driver notifications: creates snapshot
- Rider app → Card API: manages cards (evidence: `README.md`)
- Card API → Saved cards: requests card action (evidence: `src/GoRide.Payment/Controllers/CardsController.cs`)
- Saved cards → Card storage: stores card (evidence: `src/GoRide.Payment/Cards/CardService.cs`)
- Demo card charge → Card attempts: records attempts (evidence: `src/GoRide.Payment/Cards/CardPaymentService.cs`)
- Demo card charge → Payment records: charges saved card (evidence: `src/GoRide.Payment/Cards/CardPaymentService.cs`)
- Rider app → In-app confirmation: views confirmation (evidence: `README.md`)
- Rider app → Receipt access: views or resends (evidence: `README.md`)
- Receipt delivery → Receipt outbox: claims receipt (evidence: `src/GoRide.Payment/Receipts/ReceiptDispatcher.cs`)
- Receipt delivery → Brevo email: sends email (evidence: `README.md`)
- Driver app → Driver feed API: reads feed (evidence: `README.md`)
- Driver feed API → Driver notifications: reads notifications (evidence: `src/GoRide.Payment/Controllers/DriverNotificationsController.cs`)
- Payment API → Payment status: reads status (evidence: `src/GoRide.Payment/Controllers/PaymentsController.cs`)
- Trip event consumer → Trip completion: processes event (evidence: `src/GoRide.Payment/Events/TripEventConsumer.cs`)
- Payment records → Payment model: persists model (evidence: `src/GoRide.Payment/Data/PaymentStore.cs`)
- Trip completion → Payment rules: validates completion (evidence: `src/GoRide.Payment/Checkout/TripCompletionService.cs`)
- Saved cards → Demo card data: uses test data (evidence: `src/GoRide.Payment/Cards/CardService.cs`)
