Skip to content

Feature: Card Payment – Happy Path End-to-End (UI, Integration, Test, CI/CD) #2

Description

@neronguyen

User Story

As a merchant, I want to accept card payments from customers for their orders, so that I can receive payments and complete sales.

Acceptance Criteria (user/outcome focused; testable)

  1. Navigation & Input
    • Given the merchant is on PaymentEntryScreen, when they enter an amount and press "Next", then the app navigates to ReadCardScreen.
  2. Card Capture Simulation
    • Given the merchant is on ReadCardScreen, when the fake POS SDK is invoked, then it returns a card token within a short delay.
  3. Gateway Call & Success
    • Given a valid PaymentIntent and card token, when the app calls the fake Payment Gateway, then it receives a success response with a unique transactionId.
  4. Persistence
    • Given a successful gateway response, the payment intent in local DB is updated to COMPLETED and stores the transactionId.
  5. UI Feedback
    • After success, the UI displays a simple pop-up dialog that shows success and the transactionId (no dedicated result screen).
  6. Tests & CI
    • Unit tests verify the happy path flow (Repository + ViewModel) and the CI pipeline runs these tests successfully.

Implementation Tasks (developer-focused)

  • UI
    1. Add PaymentEntryScreen: amount input, validation (positive amount), card method auto-selected, and "Next" button to ReadCardScreen.
    2. Add ReadCardScreen: loading/reading state and invokes FakePosSdk.readCard(), triggers payment, shows simple pop-up dialog on success (transactionId).
  • Fake POS SDK
    3. Implement FakePosSdk.readCard() to resolve after a short delay and return a fake card token.
  • Fake Payment Gateway
    4. Implement FakePaymentGateway.charge(amount, idempotencyKey, cardToken) to always return success and a unique transactionId (handle idempotencyKey).
  • Repository & Domain
    5. PaymentRepository: createPaymentIntent(amount), startCardPayment(intentId) flow: load intent, call FakePosSdk, call FakePaymentGateway, update intent to COMPLETED and save transactionId.
  • ViewModels & State
    6. ViewModels for PaymentEntryScreen and ReadCardScreen to manage states and transitions.
  • Local DB
    7. Define/extend PaymentIntent entity: intentId, amount, status (PENDING/COMPLETED/FAILED), idempotencyKey, transactionId, lastError, createdAt, updatedAt.
  • Tests
    8. Unit test: happy path end-to-end using fakes. ViewModel tests: input -> navigation -> read -> success.
  • CI/CD
    9. Ensure unit tests run in pipeline; update pipeline to fail on regressions.

Out of Scope

  • Retry logic, timeouts, network error handling, or failure flows.
  • QR Payments and partial payments.
  • Real POS/Gateway integration and security/encryption.
  • Advanced/polished UI or dedicated result screen.

References

  • README and docs/diagrams for architecture context.

Note: This issue focuses on the happy path only. Failure and retry behaviors will be added in separate tickets later.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions