Docs Menu
Docs Home
/ /
Atlas Architecture Center
/ / /

Payments Modernization Solution Accelerator

Learn how to build an operational data layer (ODL) to unlock siloed payment data to power modern applications.

Today's payment industry changes quickly, and businesses are working to offer secure and easy-to-use payment solutions. This need is driven by factors like new regulations, customer expectations, and market competition. Financial services organizations can use MongoDB to modernize their payment systems.

This solution showcases how you can use MongoDB to build an ODL. You can deploy an ODL on top of legacy systems to modernize your architecture without the difficulty and risk that comes with fully replacing the legacy systems.

Several factors are pushing the modernization of payment systems:

  • Real-time payments: Customers and businesses expect payments to be processed immediately.

  • Regulatory changes: New laws and regulations, like PSD2 in Europe, encourage more open and flexible payment systems.

  • Customer expectations: People want payment processes to be smooth and integrated across different platforms.

  • Open banking: Open banking makes the financial sector more competitive and innovative, allowing for the development of new payment services.

  • Competition: Fintech startups offer new payment solutions, challenging traditional financial institutions to update their systems.

Updating payment systems is challenging due to:

  • Complex systems: Payment systems involve many different parties and regulations, making changes complicated.

  • Old technology: Outdated systems slow down innovation and make it difficult to meet current standards.

  • High costs: Upgrading old systems can be expensive and time-consuming.

  • Technical debt: Previous shortcuts in system design can limit future growth and adaptability.

In this example solution, you can learn how you can use MongoDB to modernize payment systems.

Businesses are embracing the following strategies when updating their systems:

  • Domain-driven design: By aligning system development with business needs, domain-driven design ensures that technology changes serve business goals.

  • Microservices architecture: By transitioning from a monolithic architecture to a microservices architecture, you can update and scale your system more efficiently.

The following MongoDB features support payment modernization efforts:

  • Flexible document model: MongoDB's document model allows you to incorporate new payment types and data structures, ensuring that your system can evolve with the market.

  • Operational data layer: MongoDB introduces a unified data layer that simplifies access to data across various services, which is crucial for building integrated payment solutions.

  • Support for best practices: MongoDB equips businesses with the tools they need to follow industry best practices, such as secure transactions and real-time analytics.

The diagram below details the architecture used by this payment solution. To learn more about how it works with MongoDB, visit our Real-Time Payments page.

Payments Solution Architecture Diagram

Figure 1. Payments solution architecture diagram

This solution focuses on the relationships between entities like User Accounts, Transactions, Bank Accounts, and Payment Methods. It includes data attributes and detailed information for each entity.

A microservices architecture breaks large monolithic applications into smaller pieces. It allows for faster development, modularity, flexibility and scalability, resilience, organizational alignment, and reduction in cost.

The microservices architecture used in this solution is broken into the following services:

  • User Management

  • Transaction Processing

  • Transaction History

  • Account Reconciliation

  • Payment Verification

  • Reporting

  • Notifications

This service facilitates user and account interactions. The diagram below shows the flow for account creation.

The diagram involves the following entities:

  • Data entities: User Account, Payment Method, Bank Account

  • Permissions: Read/Write on User Account, Payment Method, and Bank Account

  • Inputs: User details, Payment method details, Bank account details

  • Outputs: User account creation confirmation, Payment method addition confirmation, Bank account addition confirmation

Account Creation Flow

Figure 2. Account creation flow

You can see an application of this flow in this GitHub repository.

This service manages transaction-related operations, such as initiating, completing, or refunding a transaction. In the diagram below, you can see the main flow for initiating a transaction.

This diagram involves the following entities:

  • Data entities: Transaction, Bank Account

  • Permissions: Read/Write on Transaction, Read on Bank Account

  • Inputs: Transaction details, like amount, sender, and receiver

  • Outputs: Transaction status update, like pending, completed, or failed

You can see an application of this flow in this GitHub repository.

Transaction Flow

Figure 3. Transaction flow

This microservice is also responsible for managing external provider transactions. For example, the solution includes a demo of a user getting a PayPal payment. MongoDB's flexible schema allows for variation in the documents that represent transactions.

The diagram below shows the process for the mock PayPal transaction.

External Transaction Flow

Figure 4. External transaction flow

This service deals with transaction logging and archival. It involves the following entities:

  • Data Entities: Transaction History, User Account

  • Permissions: Read on Transaction History, Read on User Account

  • Inputs: User account number

  • Outputs: Transaction history data

You can see an application of these entities in this GitHub repository.

This services verifies that the account details are up-to-date. It involves the following entities:

  • Data entities: Bank Account, Transaction

  • Permissions: Read/Write on Bank Account, Read on Transaction

  • Inputs: Transaction details, Bank account details

  • Outputs: Reconciliation status, Adjusted account balances

You can see an application of these entities in this GitHub repository.

This service processes a transaction initiation. The diagram below shows the payment-processing steps, starting from when the service reacts to a payment and ending when it notifies the user about whether the payment was approved or rejected.

This service involves the following entities:

  • Data entities: Transaction, User Account, Bank Account

  • Permissions: Read on Transaction, Read on User Account, Read on Bank Account

  • Inputs: Transaction details, User account number, Bank account details

  • Outputs: Verification status (success or failure)

Payment Processing Flow

Figure 5. Payment processing flow

You can see an application of these entities in this GitHub repository.

To create a view of your payment data, you can use MongoDB Charts.

This involves the following entities:

  • Data entities: Transaction History, User Account

  • Permissions: Read on Transaction History, Read on User Account

  • Inputs: User account number, Report criteria (date range, transaction type)

  • Outputs: Generated financial reports

This services uses MongoDB Change Streams to notify the user of any changes.

This involves the following entities:

  • Data entities: User Account, Transaction

  • Permissions: Read on User Account, Read on Transaction

  • Inputs: User account details, Transaction details

  • Outputs: Notifications and alerts to users

You can see an application of these entities in this GitHub repository.

The following document structures and microservices form the backbone of the MongoDB-based payment solution, ensuring scalability, security, and efficient data management.

Documents in the users collection have the following structure:

{
"_id": ObjectId,
"username": String,
"email": String,
"password": String, // hashed
"linkedAccounts": [
{
"accountId": String,
"accountType": String,
"externalDetails": {
"apiEndpoint": String,
"accessKey": String,
"additionalInfo": String
}
}
], "recentTransactions": [
{
"transactionId": String,
"date": Date,
"amount": Number,
"type": String, // e.g., 'debit', 'credit'
"status": String // e.g., 'completed', 'pending'
}
]
}

Documents in the accounts collection have the following structure:

{
"_id": ObjectId,
"userId": ObjectId,
"accountNumber": String, // Encrypted
"accountType": String,
"balance": Number,
"limitations": {
"withdrawalLimit": Number,
"transferLimit": Number,
"otherLimitations": String
},
"securityTags": [String],
"encryptedDetails": String
}

Documents in the transactions collection have the following structure:

{
"_id": ObjectId,
"account_id": ObjectId,
"amount": Number,
"date": Date,
"type": String, // e.g., 'debit', 'credit'
"status": String, // e.g., 'completed', 'pending', 'refund'
"details": String, // Encrypted if sensitive
"referenceData": {
"sender": { ... },
"receiver": { ... },
"steps": [{ ... }],
"relatedTransactions": [{ ... }],
"notes": String,
"reportingTags": [String]
}
}

Documents in the notifications collection have the following structure:

{
"_id": ObjectId,
"relatedEntityId": ObjectId,
"userIds": [ObjectId],
"message": String,
"createdAt": Date,
"statuses": [
{
"userId": ObjectId,
"status": String // e.g., 'unread', 'read'
}
]
}

The code for this tutorial can be found in this GitHub repository. To get started, follow the README instructions.

The tutorial uses the following features in the different services:

  • Indexing and scalability

  • JSON schema validation

  • Permission and data segregation

  • Auditing

  • Apache Kafka source: Use Kafka to stream notifications to external systems and users.

  • Change streams: Change streams capture notifications, which are then pushed by Websockets.

  • Atlas Charts: Use Atlas Charts to preprocess and visualize your data.

If you use this solution, account for the following considerations:

  • Security and compliance: Adhere to GDPR, PCI DSS, and other financial regulations.

  • Scalability and performance: Ensure efficient query processing and data handling.

  • Audit and logging: Comprehensive logging for payments to support audits.

  • Backup and recovery: Robust plan for data recovery using MongoDB Atlas.

  • Pavel Duchovny, Developer Relations, MongoDB

  • Shiv Pullepu, Industry Solutions, MongoDB

  • Raj Jain, Solutions Architect, MongoDB

  • Jack Yallop, Industry Marketing, MongoDB

Back

Unified Interface for RAG Applications

On this page