@eventcatalog/create-eventcatalog 3.0.10 → 3.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/default/domains/Orders/entities/CartItem/index.mdx +121 -0
- package/templates/default/domains/Orders/entities/Customer/index.mdx +57 -0
- package/templates/default/domains/Orders/entities/Order/index.mdx +96 -0
- package/templates/default/domains/Orders/entities/OrderItem/index.mdx +59 -0
- package/templates/default/domains/Orders/entities/ShoppingCart/index.mdx +148 -0
- package/templates/default/domains/Orders/index.mdx +13 -0
- package/templates/default/domains/Payment/entities/Address/index.mdx +162 -0
- package/templates/default/domains/Payment/entities/Invoice/index.mdx +89 -0
- package/templates/default/domains/Payment/entities/Payment/index.mdx +137 -0
- package/templates/default/domains/Payment/entities/PaymentMethod/index.mdx +77 -0
- package/templates/default/domains/Payment/entities/Transaction/index.mdx +77 -0
- package/templates/default/domains/Payment/index.mdx +17 -1
- package/templates/default/domains/Payment/services/FraudDetectionService/events/FraudCheckCompleted/index.mdx +48 -0
- package/templates/default/domains/Payment/services/FraudDetectionService/events/FraudCheckCompleted/schema.json +44 -0
- package/templates/default/domains/Payment/services/FraudDetectionService/index.mdx +59 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/commands/ProcessPayment/index.mdx +72 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/commands/ProcessPayment/schema.json +58 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/events/PaymentFailed/index.mdx +60 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/events/PaymentFailed/schema.json +68 -0
- package/templates/default/domains/Payment/services/PaymentGatewayService/index.mdx +78 -0
- package/templates/default/domains/ProductCatalog/entities/Category/index.mdx +124 -0
- package/templates/default/domains/ProductCatalog/entities/Inventory/index.mdx +116 -0
- package/templates/default/domains/ProductCatalog/entities/Product/index.mdx +115 -0
- package/templates/default/domains/ProductCatalog/entities/Review/index.mdx +154 -0
- package/templates/default/domains/ProductCatalog/index.mdx +74 -0
- package/templates/default/domains/Subscriptions/entities/BillingProfile/index.mdx +68 -0
- package/templates/default/domains/Subscriptions/entities/SubscriptionPeriod/index.mdx +73 -0
- package/templates/default/domains/Subscriptions/index.mdx +13 -2
- package/templates/default/domains/Subscriptions/services/BillingService/events/SubscriptionPaymentDue/index.mdx +60 -0
- package/templates/default/domains/Subscriptions/services/BillingService/events/SubscriptionPaymentDue/schema.json +54 -0
- package/templates/default/domains/Subscriptions/services/BillingService/index.mdx +86 -0
- package/templates/default/domains/Subscriptions/services/PlanManagementService/index.mdx +93 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Invoice
|
|
3
|
+
name: Invoice
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: invoiceId
|
|
6
|
+
summary: Represents a bill issued to a customer, detailing charges for products or services.
|
|
7
|
+
|
|
8
|
+
properties:
|
|
9
|
+
- name: invoiceId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for the invoice.
|
|
13
|
+
- name: customerId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
description: Identifier of the customer being invoiced
|
|
17
|
+
references: Customer
|
|
18
|
+
relationType: hasOne
|
|
19
|
+
- name: orderId # Optional, if invoice is directly tied to a single order
|
|
20
|
+
type: UUID
|
|
21
|
+
required: false
|
|
22
|
+
description: Identifier of the associated order, if applicable.
|
|
23
|
+
- name: subscriptionId # Optional, if invoice is for a subscription period
|
|
24
|
+
type: UUID
|
|
25
|
+
required: false
|
|
26
|
+
description: Identifier of the associated subscription, if applicable.
|
|
27
|
+
- name: invoiceNumber
|
|
28
|
+
type: string
|
|
29
|
+
required: true
|
|
30
|
+
description: Human-readable, sequential identifier for the invoice (may have specific format).
|
|
31
|
+
- name: issueDate
|
|
32
|
+
type: Date
|
|
33
|
+
required: true
|
|
34
|
+
description: Date the invoice was generated and issued.
|
|
35
|
+
- name: dueDate
|
|
36
|
+
type: Date
|
|
37
|
+
required: true
|
|
38
|
+
description: Date by which the payment for the invoice is due.
|
|
39
|
+
- name: totalAmount
|
|
40
|
+
type: decimal
|
|
41
|
+
required: true
|
|
42
|
+
description: The total amount due on the invoice.
|
|
43
|
+
- name: currency
|
|
44
|
+
type: string # ISO 4217 code
|
|
45
|
+
required: true
|
|
46
|
+
description: Currency of the invoice amount.
|
|
47
|
+
- name: status
|
|
48
|
+
type: string # (e.g., Draft, Sent, Paid, Overdue, Void)
|
|
49
|
+
required: true
|
|
50
|
+
description: Current status of the invoice.
|
|
51
|
+
- name: billingAddressId # Address used for this specific invoice
|
|
52
|
+
type: UUID
|
|
53
|
+
required: true
|
|
54
|
+
description: Identifier for the billing address used on this invoice.
|
|
55
|
+
- name: lineItems
|
|
56
|
+
type: array
|
|
57
|
+
items:
|
|
58
|
+
type: InvoiceLineItem # Assuming a value object or separate entity for line items
|
|
59
|
+
required: true
|
|
60
|
+
description: List of individual items or services being charged on the invoice.
|
|
61
|
+
- name: createdAt
|
|
62
|
+
type: DateTime
|
|
63
|
+
required: true
|
|
64
|
+
description: Timestamp when the invoice record was created.
|
|
65
|
+
- name: paidAt # Timestamp when payment was confirmed
|
|
66
|
+
type: DateTime
|
|
67
|
+
required: false
|
|
68
|
+
description: Timestamp when the invoice was marked as paid.
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Overview
|
|
72
|
+
|
|
73
|
+
The Invoice entity represents a formal request for payment issued by the business to a customer. It details the products, services, quantities, prices, taxes, and total amount due, along with payment terms.
|
|
74
|
+
|
|
75
|
+
### Entity Properties
|
|
76
|
+
<EntityPropertiesTable />
|
|
77
|
+
|
|
78
|
+
## Relationships
|
|
79
|
+
|
|
80
|
+
* **Customer:** An invoice is issued to one `Customer`.
|
|
81
|
+
* **Order/Subscription:** An invoice may be related to one or more `Order`s or a specific `Subscription` period.
|
|
82
|
+
* **Payment:** An invoice is settled by one or more `Payment` transactions.
|
|
83
|
+
* **InvoiceLineItem:** An invoice contains multiple `InvoiceLineItem`s detailing the charges.
|
|
84
|
+
* **BillingProfile:** Invoice generation often uses details from the customer's `BillingProfile`.
|
|
85
|
+
|
|
86
|
+
## Examples
|
|
87
|
+
|
|
88
|
+
* Invoice #INV-00123 issued to Jane Doe for her monthly subscription renewal, due in 15 days.
|
|
89
|
+
* Invoice #INV-00124 issued to Acme Corp for consulting services rendered in the previous month, status Paid.
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Payment
|
|
3
|
+
name: Payment
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: paymentId
|
|
6
|
+
aggregateRoot: true
|
|
7
|
+
summary: Represents payment transactions for orders in the e-commerce system.
|
|
8
|
+
properties:
|
|
9
|
+
- name: paymentId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for the payment
|
|
13
|
+
- name: orderId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
description: Order this payment is associated with
|
|
17
|
+
references: Order
|
|
18
|
+
referencesIdentifier: orderId
|
|
19
|
+
relationType: hasOne
|
|
20
|
+
- name: customerId
|
|
21
|
+
type: UUID
|
|
22
|
+
required: true
|
|
23
|
+
description: Customer who made the payment
|
|
24
|
+
references: Customer
|
|
25
|
+
referencesIdentifier: customerId
|
|
26
|
+
relationType: hasOne
|
|
27
|
+
- name: amount
|
|
28
|
+
type: decimal
|
|
29
|
+
required: true
|
|
30
|
+
description: Payment amount
|
|
31
|
+
- name: currency
|
|
32
|
+
type: string
|
|
33
|
+
required: true
|
|
34
|
+
description: Currency code (e.g., USD, EUR, GBP)
|
|
35
|
+
- name: paymentMethod
|
|
36
|
+
type: string
|
|
37
|
+
required: true
|
|
38
|
+
description: Payment method used
|
|
39
|
+
enum: ['credit_card', 'debit_card', 'paypal', 'stripe', 'bank_transfer', 'apple_pay', 'google_pay']
|
|
40
|
+
- name: paymentMethodDetails
|
|
41
|
+
type: object
|
|
42
|
+
required: false
|
|
43
|
+
description: Additional payment method specific details
|
|
44
|
+
properties:
|
|
45
|
+
- name: cardLast4
|
|
46
|
+
type: string
|
|
47
|
+
description: Last 4 digits of card number
|
|
48
|
+
- name: cardType
|
|
49
|
+
type: string
|
|
50
|
+
description: Card type (Visa, MasterCard, etc.)
|
|
51
|
+
- name: expiryMonth
|
|
52
|
+
type: integer
|
|
53
|
+
description: Card expiry month
|
|
54
|
+
- name: expiryYear
|
|
55
|
+
type: integer
|
|
56
|
+
description: Card expiry year
|
|
57
|
+
- name: status
|
|
58
|
+
type: string
|
|
59
|
+
required: true
|
|
60
|
+
description: Current payment status
|
|
61
|
+
enum: ['pending', 'processing', 'completed', 'failed', 'cancelled', 'refunded', 'partially_refunded']
|
|
62
|
+
- name: transactionId
|
|
63
|
+
type: string
|
|
64
|
+
required: false
|
|
65
|
+
description: External payment processor transaction ID
|
|
66
|
+
- name: gatewayResponse
|
|
67
|
+
type: object
|
|
68
|
+
required: false
|
|
69
|
+
description: Raw response from payment gateway
|
|
70
|
+
- name: billingAddress
|
|
71
|
+
type: Address
|
|
72
|
+
required: true
|
|
73
|
+
description: Billing address for the payment
|
|
74
|
+
references: Address
|
|
75
|
+
referencesIdentifier: addressId
|
|
76
|
+
relationType: hasOne
|
|
77
|
+
- name: processedAt
|
|
78
|
+
type: DateTime
|
|
79
|
+
required: false
|
|
80
|
+
description: Date and time when payment was processed
|
|
81
|
+
- name: failureReason
|
|
82
|
+
type: string
|
|
83
|
+
required: false
|
|
84
|
+
description: Reason for payment failure if applicable
|
|
85
|
+
- name: refunds
|
|
86
|
+
type: array
|
|
87
|
+
items:
|
|
88
|
+
type: PaymentRefund
|
|
89
|
+
required: false
|
|
90
|
+
description: Refunds associated with this payment
|
|
91
|
+
- name: createdAt
|
|
92
|
+
type: DateTime
|
|
93
|
+
required: true
|
|
94
|
+
description: Date and time when the payment record was created
|
|
95
|
+
- name: updatedAt
|
|
96
|
+
type: DateTime
|
|
97
|
+
required: false
|
|
98
|
+
description: Date and time when the payment record was last updated
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## Overview
|
|
102
|
+
|
|
103
|
+
The Payment entity manages all payment transactions in the e-commerce system. It tracks payment details, status, and relationships with orders and customers, supporting various payment methods and refund scenarios.
|
|
104
|
+
|
|
105
|
+
### Entity Properties
|
|
106
|
+
<EntityPropertiesTable />
|
|
107
|
+
|
|
108
|
+
## Relationships
|
|
109
|
+
|
|
110
|
+
* **Order:** Each payment belongs to one `Order` (identified by `orderId`).
|
|
111
|
+
* **Customer:** Each payment is made by one `Customer` (identified by `customerId`).
|
|
112
|
+
* **Address:** Each payment has a billing `Address` (identified by `billingAddress`).
|
|
113
|
+
* **PaymentRefund:** A payment can have multiple `PaymentRefund` entities for partial or full refunds.
|
|
114
|
+
|
|
115
|
+
## Payment States
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
pending → processing → completed
|
|
119
|
+
↓ ↓ ↓
|
|
120
|
+
cancelled failed refunded/partially_refunded
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Examples
|
|
124
|
+
|
|
125
|
+
* **Payment #1:** $299.99 credit card payment for Order #12345, completed successfully.
|
|
126
|
+
* **Payment #2:** $150.00 PayPal payment for Order #67890, failed due to insufficient funds.
|
|
127
|
+
* **Payment #3:** $500.00 bank transfer, completed with $50.00 partial refund.
|
|
128
|
+
|
|
129
|
+
## Business Rules
|
|
130
|
+
|
|
131
|
+
* Payment amount must match the order total
|
|
132
|
+
* Payment status transitions must follow valid state machine
|
|
133
|
+
* Failed payments should include failure reason
|
|
134
|
+
* Completed payments cannot be cancelled
|
|
135
|
+
* Refunds cannot exceed the original payment amount
|
|
136
|
+
* Payment method details are encrypted and PCI compliant
|
|
137
|
+
* Transaction IDs from payment gateways must be stored for reconciliation
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: PaymentMethod
|
|
3
|
+
name: PaymentMethod
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: paymentMethodId
|
|
6
|
+
summary: Represents a payment instrument a customer can use, like a credit card or bank account.
|
|
7
|
+
|
|
8
|
+
properties:
|
|
9
|
+
- name: paymentMethodId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for the payment method.
|
|
13
|
+
- name: customerId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
description: Identifier of the customer who owns this payment method.
|
|
17
|
+
references: Customer
|
|
18
|
+
relationType: hasOne
|
|
19
|
+
- name: type
|
|
20
|
+
type: string # (e.g., CreditCard, BankAccount, PayPal, ApplePay)
|
|
21
|
+
required: true
|
|
22
|
+
description: The type of payment method.
|
|
23
|
+
- name: details # Contains type-specific details (masked, tokenized)
|
|
24
|
+
type: object
|
|
25
|
+
required: true
|
|
26
|
+
description: Contains type-specific, often sensitive details (e.g., last 4 digits of card, card brand, bank name, account type, token). **Never store raw PANs or sensitive data.**
|
|
27
|
+
# Example structure for CreditCard:
|
|
28
|
+
# details:
|
|
29
|
+
# brand: "Visa"
|
|
30
|
+
# last4: "1234"
|
|
31
|
+
# expiryMonth: 12
|
|
32
|
+
# expiryYear: 2025
|
|
33
|
+
# cardholderName: "Jane Doe"
|
|
34
|
+
# gatewayToken: "tok_abc123xyz"
|
|
35
|
+
- name: isDefault
|
|
36
|
+
type: boolean
|
|
37
|
+
required: true
|
|
38
|
+
description: Indicates if this is the customer's default payment method.
|
|
39
|
+
- name: billingAddressId # Link to the billing address associated with this method
|
|
40
|
+
type: UUID
|
|
41
|
+
required: true
|
|
42
|
+
description: Identifier for the billing address verified for this payment method.
|
|
43
|
+
- name: status
|
|
44
|
+
type: string # (e.g., Active, Expired, Invalid, Removed)
|
|
45
|
+
required: true
|
|
46
|
+
description: Current status of the payment method.
|
|
47
|
+
- name: createdAt
|
|
48
|
+
type: DateTime
|
|
49
|
+
required: true
|
|
50
|
+
description: Timestamp when the payment method was added.
|
|
51
|
+
- name: updatedAt
|
|
52
|
+
type: DateTime
|
|
53
|
+
required: true
|
|
54
|
+
description: Timestamp when the payment method was last updated.
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Overview
|
|
58
|
+
|
|
59
|
+
The PaymentMethod entity represents a specific payment instrument registered by a customer, such as a credit card or a linked bank account. It stores necessary (non-sensitive) details required to initiate payments and links to the associated customer and billing address.
|
|
60
|
+
|
|
61
|
+
**Security Note:** Sensitive details like full card numbers or bank account numbers should **never** be stored directly. Rely on tokenization provided by payment gateways.
|
|
62
|
+
|
|
63
|
+
### Entity Properties
|
|
64
|
+
<EntityPropertiesTable />
|
|
65
|
+
|
|
66
|
+
## Relationships
|
|
67
|
+
|
|
68
|
+
* **Customer:** A payment method belongs to one `Customer`.
|
|
69
|
+
* **Address:** Linked to a specific billing `Address`.
|
|
70
|
+
* **Payment:** Used to make `Payment` transactions.
|
|
71
|
+
* **Subscription:** May be designated as the payment method for a `Subscription`.
|
|
72
|
+
|
|
73
|
+
## Examples
|
|
74
|
+
|
|
75
|
+
* Jane Doe's default Visa card ending in 1234, expiring 12/2025, status Active.
|
|
76
|
+
* John Smith's linked bank account (Chase, Checking), status Active.
|
|
77
|
+
* An old MasterCard ending in 5678 belonging to Jane Doe, status Expired.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Transaction
|
|
3
|
+
name: Transaction
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
identifier: transactionId
|
|
6
|
+
summary: Represents a low-level interaction with a payment gateway or processor (e.g., authorize, capture, refund, void).
|
|
7
|
+
|
|
8
|
+
properties:
|
|
9
|
+
- name: transactionId
|
|
10
|
+
type: UUID
|
|
11
|
+
required: true
|
|
12
|
+
description: Unique identifier for this specific gateway transaction.
|
|
13
|
+
- name: paymentId
|
|
14
|
+
type: UUID
|
|
15
|
+
required: true
|
|
16
|
+
references: Payment
|
|
17
|
+
relationType: hasOne
|
|
18
|
+
description: Identifier of the parent Payment this transaction belongs to.
|
|
19
|
+
- name: type
|
|
20
|
+
type: string # (e.g., Authorize, Capture, Sale, Refund, Void, Verify)
|
|
21
|
+
required: true
|
|
22
|
+
description: The type of operation performed with the payment gateway.
|
|
23
|
+
- name: gatewayReferenceId
|
|
24
|
+
type: string
|
|
25
|
+
required: true
|
|
26
|
+
description: Unique transaction ID provided by the external payment gateway.
|
|
27
|
+
- name: amount
|
|
28
|
+
type: decimal
|
|
29
|
+
required: true
|
|
30
|
+
description: The amount associated with this specific transaction operation.
|
|
31
|
+
- name: currency
|
|
32
|
+
type: string # ISO 4217 code
|
|
33
|
+
required: true
|
|
34
|
+
description: Currency of the transaction amount.
|
|
35
|
+
- name: status
|
|
36
|
+
type: string # (e.g., Success, Failure, Pending)
|
|
37
|
+
required: true
|
|
38
|
+
description: Status reported by the gateway for this specific operation.
|
|
39
|
+
- name: responseCode # Gateway-specific code
|
|
40
|
+
type: string
|
|
41
|
+
required: false
|
|
42
|
+
description: Response code returned by the payment gateway.
|
|
43
|
+
- name: responseMessage # Gateway-specific message
|
|
44
|
+
type: string
|
|
45
|
+
required: false
|
|
46
|
+
description: Detailed message or reason returned by the gateway.
|
|
47
|
+
- name: processedAt
|
|
48
|
+
type: DateTime
|
|
49
|
+
required: true
|
|
50
|
+
description: Timestamp when the transaction was processed by the gateway.
|
|
51
|
+
- name: rawRequest # Optional, for debugging - consider security implications
|
|
52
|
+
type: text
|
|
53
|
+
required: false
|
|
54
|
+
description: Raw request payload sent to the gateway (use with caution).
|
|
55
|
+
- name: rawResponse # Optional, for debugging - consider security implications
|
|
56
|
+
type: text
|
|
57
|
+
required: false
|
|
58
|
+
description: Raw response payload received from the gateway (use with caution).
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Overview
|
|
62
|
+
|
|
63
|
+
The Transaction entity logs the individual interactions with an external payment processor (like Stripe, PayPal, Adyen) that occur as part of processing a `Payment`. This provides a detailed audit trail of gateway operations, including authorizations, captures, refunds, and any associated success or failure responses.
|
|
64
|
+
|
|
65
|
+
### Entity Properties
|
|
66
|
+
<EntityPropertiesTable />
|
|
67
|
+
|
|
68
|
+
## Relationships
|
|
69
|
+
|
|
70
|
+
* **Payment:** A transaction is part of one `Payment`.
|
|
71
|
+
|
|
72
|
+
## Examples
|
|
73
|
+
|
|
74
|
+
* **Authorization Success:** Type: Authorize, PaymentID: PAY-98765, GatewayRef: auth_abc, Amount: $19.99, Status: Success.
|
|
75
|
+
* **Capture Success:** Type: Capture, PaymentID: PAY-98765, GatewayRef: ch_def, Amount: $19.99, Status: Success (following the authorization).
|
|
76
|
+
* **Authorization Failure:** Type: Authorize, PaymentID: PAY-98766, GatewayRef: auth_ghi, Amount: $50.00, Status: Failure, ResponseCode: 'declined', ResponseMessage: 'Insufficient Funds'.
|
|
77
|
+
* **Refund Success:** Type: Refund, PaymentID: PAY-98760, GatewayRef: re_jkl, Amount: $25.00, Status: Success.
|
|
@@ -9,6 +9,16 @@ owners:
|
|
|
9
9
|
services:
|
|
10
10
|
- id: PaymentService
|
|
11
11
|
version: 0.0.1
|
|
12
|
+
- id: FraudDetectionService
|
|
13
|
+
version: 0.0.1
|
|
14
|
+
- id: PaymentGatewayService
|
|
15
|
+
version: 0.0.1
|
|
16
|
+
entities:
|
|
17
|
+
- id: Invoice
|
|
18
|
+
- id: Payment
|
|
19
|
+
- id: PaymentMethod
|
|
20
|
+
- id: Transaction
|
|
21
|
+
- id: Address
|
|
12
22
|
badges:
|
|
13
23
|
- content: Payment Domain
|
|
14
24
|
backgroundColor: blue
|
|
@@ -19,6 +29,12 @@ badges:
|
|
|
19
29
|
|
|
20
30
|
The Payment Domain encompasses all services and components related to handling financial transactions within the system. It is responsible for managing payments, transactions, billing, and financial records. The domain ensures secure, reliable, and efficient processing of all payment-related activities
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
### Architecture for the Payment domain
|
|
23
33
|
|
|
24
34
|
<NodeGraph />
|
|
35
|
+
|
|
36
|
+
### Entity Map
|
|
37
|
+
|
|
38
|
+
A visualization of the entities in the Payment domain. Here you can see the relationships between the entities and how they are used in the domain.
|
|
39
|
+
|
|
40
|
+
<EntityMap id="Payment" />
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: FraudCheckCompleted
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Fraud Check Completed
|
|
5
|
+
summary: Emitted when a fraud check has been completed for a transaction
|
|
6
|
+
tags:
|
|
7
|
+
- payment
|
|
8
|
+
- fraud
|
|
9
|
+
- security
|
|
10
|
+
badges:
|
|
11
|
+
- content: New
|
|
12
|
+
backgroundColor: green
|
|
13
|
+
textColor: white
|
|
14
|
+
schemaPath: schema.json
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
import Footer from '@catalog/components/footer.astro'
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
The `FraudCheckCompleted` event is emitted when the fraud detection service has completed its analysis of a payment transaction. This event contains the risk assessment results and recommendations.
|
|
22
|
+
|
|
23
|
+
## Schema
|
|
24
|
+
|
|
25
|
+
<SchemaViewer title="FraudCheckCompleted Schema" schemaPath={frontmatter.schemaPath} />
|
|
26
|
+
|
|
27
|
+
## Event Details
|
|
28
|
+
|
|
29
|
+
- **Risk Score**: A numerical score from 0-100 indicating fraud risk
|
|
30
|
+
- **Decision**: APPROVED, DECLINED, or MANUAL_REVIEW
|
|
31
|
+
- **Reasons**: Array of reasons for the decision
|
|
32
|
+
- **Confidence**: Confidence level of the fraud detection
|
|
33
|
+
|
|
34
|
+
## Example Payload
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"transactionId": "txn_1234567890",
|
|
39
|
+
"paymentId": "pay_9876543210",
|
|
40
|
+
"riskScore": 25,
|
|
41
|
+
"decision": "APPROVED",
|
|
42
|
+
"reasons": ["Low risk merchant", "Customer history positive"],
|
|
43
|
+
"confidence": 0.92,
|
|
44
|
+
"timestamp": "2024-01-15T10:30:00Z"
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
<Footer />
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"transactionId": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "Unique identifier for the transaction"
|
|
8
|
+
},
|
|
9
|
+
"paymentId": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "Unique identifier for the payment"
|
|
12
|
+
},
|
|
13
|
+
"riskScore": {
|
|
14
|
+
"type": "number",
|
|
15
|
+
"minimum": 0,
|
|
16
|
+
"maximum": 100,
|
|
17
|
+
"description": "Risk score from 0-100"
|
|
18
|
+
},
|
|
19
|
+
"decision": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": ["APPROVED", "DECLINED", "MANUAL_REVIEW"],
|
|
22
|
+
"description": "Fraud check decision"
|
|
23
|
+
},
|
|
24
|
+
"reasons": {
|
|
25
|
+
"type": "array",
|
|
26
|
+
"items": {
|
|
27
|
+
"type": "string"
|
|
28
|
+
},
|
|
29
|
+
"description": "Reasons for the decision"
|
|
30
|
+
},
|
|
31
|
+
"confidence": {
|
|
32
|
+
"type": "number",
|
|
33
|
+
"minimum": 0,
|
|
34
|
+
"maximum": 1,
|
|
35
|
+
"description": "Confidence level of the decision"
|
|
36
|
+
},
|
|
37
|
+
"timestamp": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"format": "date-time",
|
|
40
|
+
"description": "When the fraud check was completed"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"required": ["transactionId", "paymentId", "riskScore", "decision", "timestamp"]
|
|
44
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: FraudDetectionService
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Fraud Detection Service
|
|
5
|
+
summary: Analyzes payment transactions for fraudulent activity and risk assessment
|
|
6
|
+
repository:
|
|
7
|
+
url: https://github.com/eventcatalog/fraud-detection-service
|
|
8
|
+
receives:
|
|
9
|
+
- id: PaymentInitiated
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
- id: PaymentProcessed
|
|
12
|
+
version: 0.0.1
|
|
13
|
+
- id: SubscriptionPaymentDue
|
|
14
|
+
version: 0.0.1
|
|
15
|
+
sends:
|
|
16
|
+
- id: FraudCheckCompleted
|
|
17
|
+
version: 0.0.1
|
|
18
|
+
- id: FraudDetected
|
|
19
|
+
version: 0.0.1
|
|
20
|
+
- id: RiskScoreCalculated
|
|
21
|
+
version: 0.0.1
|
|
22
|
+
owners:
|
|
23
|
+
- riskTeam
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
import Footer from '@catalog/components/footer.astro'
|
|
27
|
+
|
|
28
|
+
## Overview
|
|
29
|
+
|
|
30
|
+
The Fraud Detection Service is responsible for analyzing payment transactions in real-time to detect potential fraudulent activity. It uses machine learning models and rule-based systems to assess risk and prevent financial losses.
|
|
31
|
+
|
|
32
|
+
## Key Features
|
|
33
|
+
|
|
34
|
+
- **Real-time Transaction Analysis**: Analyzes transactions as they occur
|
|
35
|
+
- **Machine Learning Models**: Uses ML to identify suspicious patterns
|
|
36
|
+
- **Risk Scoring**: Calculates risk scores for each transaction
|
|
37
|
+
- **Automated Blocking**: Can automatically block high-risk transactions
|
|
38
|
+
- **Manual Review Queue**: Flags medium-risk transactions for manual review
|
|
39
|
+
|
|
40
|
+
## API Endpoints
|
|
41
|
+
|
|
42
|
+
### REST API
|
|
43
|
+
- `POST /api/fraud/check` - Submit transaction for fraud check
|
|
44
|
+
- `GET /api/fraud/risk-score/{transactionId}` - Get risk score for transaction
|
|
45
|
+
- `PUT /api/fraud/override/{transactionId}` - Manual override of fraud decision
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
fraud_detection:
|
|
51
|
+
risk_thresholds:
|
|
52
|
+
high: 80
|
|
53
|
+
medium: 50
|
|
54
|
+
low: 20
|
|
55
|
+
auto_block_threshold: 90
|
|
56
|
+
ml_model_version: "2.3.1"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
<Footer />
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ProcessPayment
|
|
3
|
+
version: 0.0.1
|
|
4
|
+
name: Process Payment
|
|
5
|
+
summary: Command to process a payment through the payment gateway
|
|
6
|
+
tags:
|
|
7
|
+
- payment
|
|
8
|
+
- command
|
|
9
|
+
- cross-domain
|
|
10
|
+
badges:
|
|
11
|
+
- content: Command
|
|
12
|
+
backgroundColor: blue
|
|
13
|
+
textColor: white
|
|
14
|
+
schemaPath: schema.json
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
import Footer from '@catalog/components/footer.astro'
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
|
|
21
|
+
The `ProcessPayment` command is used to initiate payment processing through the payment gateway. This command can be triggered by various sources including the Billing Service for subscription payments.
|
|
22
|
+
|
|
23
|
+
## Command Sources
|
|
24
|
+
|
|
25
|
+
This command can be triggered by:
|
|
26
|
+
- **BillingService** (Subscriptions Domain) - For recurring subscription payments
|
|
27
|
+
- **OrdersService** (Orders Domain) - For one-time order payments
|
|
28
|
+
- **PaymentService** (Payment Domain) - For payment retries
|
|
29
|
+
|
|
30
|
+
## Command Flow
|
|
31
|
+
|
|
32
|
+
```mermaid
|
|
33
|
+
sequenceDiagram
|
|
34
|
+
participant BS as BillingService
|
|
35
|
+
participant PGS as PaymentGatewayService
|
|
36
|
+
participant FDS as FraudDetectionService
|
|
37
|
+
participant EXT as External Gateway
|
|
38
|
+
|
|
39
|
+
BS->>PGS: ProcessPayment
|
|
40
|
+
PGS->>FDS: Check Fraud
|
|
41
|
+
FDS-->>PGS: Risk Assessment
|
|
42
|
+
PGS->>EXT: Process Payment
|
|
43
|
+
EXT-->>PGS: Payment Result
|
|
44
|
+
PGS-->>BS: PaymentProcessed/Failed
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Schema
|
|
48
|
+
|
|
49
|
+
<SchemaViewer title="ProcessPayment Schema" schemaPath={frontmatter.schemaPath} />
|
|
50
|
+
|
|
51
|
+
## Example Request
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"paymentId": "pay_123456",
|
|
56
|
+
"amount": 49.99,
|
|
57
|
+
"currency": "USD",
|
|
58
|
+
"paymentMethod": {
|
|
59
|
+
"type": "card",
|
|
60
|
+
"token": "tok_visa_4242"
|
|
61
|
+
},
|
|
62
|
+
"metadata": {
|
|
63
|
+
"subscriptionId": "sub_ABC123",
|
|
64
|
+
"invoiceId": "inv_123456",
|
|
65
|
+
"customerId": "cust_XYZ789"
|
|
66
|
+
},
|
|
67
|
+
"idempotencyKey": "sub_ABC123_2024_02",
|
|
68
|
+
"captureImmediately": true
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
<Footer />
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"paymentId": {
|
|
6
|
+
"type": "string",
|
|
7
|
+
"description": "Unique identifier for this payment"
|
|
8
|
+
},
|
|
9
|
+
"amount": {
|
|
10
|
+
"type": "number",
|
|
11
|
+
"description": "Payment amount"
|
|
12
|
+
},
|
|
13
|
+
"currency": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "Currency code (ISO 4217)"
|
|
16
|
+
},
|
|
17
|
+
"paymentMethod": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"type": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"enum": ["card", "bank_transfer", "paypal", "digital_wallet"]
|
|
23
|
+
},
|
|
24
|
+
"token": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "Payment method token"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"required": ["type", "token"]
|
|
30
|
+
},
|
|
31
|
+
"metadata": {
|
|
32
|
+
"type": "object",
|
|
33
|
+
"properties": {
|
|
34
|
+
"subscriptionId": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"invoiceId": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"customerId": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"orderId": {
|
|
44
|
+
"type": "string"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"idempotencyKey": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "Key to prevent duplicate payments"
|
|
51
|
+
},
|
|
52
|
+
"captureImmediately": {
|
|
53
|
+
"type": "boolean",
|
|
54
|
+
"description": "Whether to capture payment immediately or just authorize"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": ["paymentId", "amount", "currency", "paymentMethod", "idempotencyKey"]
|
|
58
|
+
}
|