Life ConnectLife Connect
Table of contents
Architecture
Services
Swagger Docs
GitHub
Table of contents
Architecture
Services
Swagger Docs
GitHub

Payment Creation Strategy Feature Documentation

Overview

This document provides a detailed overview of the payment creation strategy feature in the application. The feature allows the application to handle different types of payment creation processes (e.g., manual payments, direct debit payments) through a flexible and extensible strategy pattern.

Feature Context

The payment creation feature is designed to support multiple payment origins, such as manual payments and direct debit payments. Each payment origin has its own specific process for creating and handling payments. By using a strategy pattern, the application can dynamically select and execute the appropriate payment creation strategy based on the payment origin.

Components

PaymentCreationStrategyFactory

Purpose

The PaymentCreationStrategyFactory is responsible for managing and providing the correct payment creation strategy based on the payment origin. It ensures that the right strategy is used for creating different types of payments.

ManualPaymentCreationStrategy

Purpose

The ManualPaymentCreationStrategy handles the creation of manual payments. This strategy is used when a payment is initiated manually by a user or an admin.

Key Responsibilities

  • Create a manual payment and set its origin to manual.
  • Ensure that manual payments are not booked automatically.

DirectDebitPaymentCreationStrategy

Purpose

The DirectDebitPaymentCreationStrategy handles the creation of direct debit payments. This strategy is used when a payment is processed through direct debit.

Key Responsibilities

  • Fetch the direct debit report and build the payment from it.
  • Ensure that direct debit payments are booked automatically.

PaymentService

Purpose

The PaymentService manages the overall payment creation process. It uses the PaymentCreationStrategyFactory to determine the correct strategy and execute it.

PaymentController

Purpose

The PaymentController provides the API endpoint for creating payments. It interacts with the PaymentService to handle the payment creation logic.

ContractsFunctions

Purpose

The ContractsFunctions listens for direct debit processed messages and triggers the creation of direct debit payments. It ensures that payments are created automatically when direct debits are processed.

Usage Flow

  1. API Request: A payment creation request is made via the PaymentController endpoint.
  2. Service Layer: The request is passed to the PaymentService, which determines the appropriate strategy based on the payment origin.
  3. Strategy Execution: The selected strategy (manual or direct debit) creates the payment.
  4. Payment Enrichment and Saving: The payment is enriched with additional data and saved. If the payment requires automatic booking, the booking process is triggered.
  5. Response: The created payment is returned to the client as the response to the API request.

Gherkin Features

Feature: Create Manual Payment

Feature: Create Manual Payment
  As a user
  I want to create a manual payment
  So that I can manually process payments

  Scenario: Successful manual payment creation
    Given I have a valid manual payment request
    When I send the request to the PaymentController
    Then the payment should be created using the ManualPaymentCreationStrategy
    And the payment should not be booked automatically
    And I should receive a confirmation response

Feature: Create Direct Debit Payment

Feature: Create Direct Debit Payment
As a system
I want to create a direct debit payment
So that I can process direct debit payments automatically

Scenario: Successful direct debit payment creation
Given a direct debit processed message is received
When the ContractsFunctions handles the message
Then the payment should be created using the DirectDebitPaymentCreationStrategy
And the payment should be booked automatically
And the payment should be saved and enriched

PlantUML Diagram

sequence_diagram

Edit this page
Last Updated:
Contributors: gregory