Payment Service
The payment service consists of the bounded contexts Payment, PaymentInformation and PaymentMethod.
It is responsible for handling the payment process and managing Users payment information. It is part of the order and return saga, where it captures the payments for Orders or refunds the payment after an Return.
It is not a payment provider but simulates communicating with one via the Simulation Service.
Domain Model
REST API
The service provides a REST API which is used by the external payment provider to inform about payment status changes.
Technology Stack
- Language: TypeScript
- Framework: NestJS
- GraphQL Library: @nestjs/graphql with @nestjs/apollo (code first)
- Database: MongoDB
- Entity Management: Mongoose
Events
This section lists events that are defined or used by the payment service.
Published Events
payment/payment/payment-enabled
This event is published when all steps necessary to be able to process a payment were successfully completed. It indicates, that other services can continue the order saga.
{
order: Order;
}
payment/payment/payment-processed
This event is published when the full payment amount was successfully captured.
{
order: Order;
}
payment/payment/payment-failed
This event is published when the payment fails finally after its retries.
{
order: Order,
}
Subscribed Events
- user/user/created: Used to create default payment Methods for each user when created.
- discount/order/validation-succeeded: Used to start the payment process after the previous steps finished successfully.