Skip to content

Commit fccbaf8

Browse files
feat(s3): domain model — CollectionOrder aggregate, state machine, events, ports (STA-120)
Closes STA-120 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2c6d4af commit fccbaf8

30 files changed

Lines changed: 816 additions & 0 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.stablecoin.payments.onramp.domain.event;
2+
3+
import java.math.BigDecimal;
4+
import java.time.Instant;
5+
import java.util.UUID;
6+
7+
public record CollectionCompletedEvent(
8+
UUID collectionId,
9+
UUID paymentId,
10+
UUID correlationId,
11+
BigDecimal collectedAmount,
12+
String currency,
13+
String paymentRail,
14+
String psp,
15+
String pspReference,
16+
Instant collectedAt
17+
) {
18+
19+
public static final String TOPIC = "fiat.collected";
20+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.stablecoin.payments.onramp.domain.event;
2+
3+
import java.time.Instant;
4+
import java.util.UUID;
5+
6+
public record CollectionFailedEvent(
7+
UUID collectionId,
8+
UUID paymentId,
9+
UUID correlationId,
10+
String reason,
11+
String errorCode,
12+
Instant failedAt
13+
) {
14+
15+
public static final String TOPIC = "fiat.collection.failed";
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.stablecoin.payments.onramp.domain.event;
2+
3+
import java.math.BigDecimal;
4+
import java.time.Instant;
5+
import java.util.UUID;
6+
7+
public record CollectionInitiatedEvent(
8+
UUID collectionId,
9+
UUID paymentId,
10+
UUID correlationId,
11+
BigDecimal amount,
12+
String currency,
13+
String paymentRail,
14+
String psp,
15+
Instant initiatedAt
16+
) {
17+
18+
public static final String TOPIC = "fiat.collection.initiated";
19+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.stablecoin.payments.onramp.domain.event;
2+
3+
import java.math.BigDecimal;
4+
import java.time.Instant;
5+
import java.util.UUID;
6+
7+
public record RefundCompletedEvent(
8+
UUID refundId,
9+
UUID collectionId,
10+
UUID paymentId,
11+
BigDecimal refundAmount,
12+
String currency,
13+
String pspRefundRef,
14+
Instant completedAt
15+
) {
16+
17+
public static final String TOPIC = "fiat.refund.completed";
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.stablecoin.payments.onramp.domain.event;
2+
3+
import java.math.BigDecimal;
4+
import java.time.Instant;
5+
import java.util.UUID;
6+
7+
public record RefundInitiatedEvent(
8+
UUID refundId,
9+
UUID collectionId,
10+
UUID paymentId,
11+
BigDecimal refundAmount,
12+
String currency,
13+
String reason,
14+
Instant initiatedAt
15+
) {
16+
17+
public static final String TOPIC = "fiat.refund.initiated";
18+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.stablecoin.payments.onramp.domain.model;
2+
3+
public enum AccountType {
4+
IBAN,
5+
ACH_ROUTING,
6+
SORT_CODE,
7+
PIX_KEY
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.stablecoin.payments.onramp.domain.model;
2+
3+
public record BankAccount(
4+
String accountNumberHash,
5+
String bankCode,
6+
AccountType accountType,
7+
String country
8+
) {
9+
10+
public BankAccount {
11+
if (accountNumberHash == null || accountNumberHash.isBlank()) {
12+
throw new IllegalArgumentException("Account number hash is required");
13+
}
14+
if (bankCode == null || bankCode.isBlank()) {
15+
throw new IllegalArgumentException("Bank code is required");
16+
}
17+
if (accountType == null) {
18+
throw new IllegalArgumentException("Account type is required");
19+
}
20+
if (country == null || country.isBlank()) {
21+
throw new IllegalArgumentException("Country is required");
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)