@eventcatalog/create-eventcatalog 4.3.12-beta.1 → 4.3.13
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/Catalog/systems/product-catalog-system/services/ProductAPI/commands/CreateProduct/examples/index.mdx +194 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/DeleteProduct/examples/index.mdx +161 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/UpdateProduct/examples/index.mdx +182 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductCreated/examples/index.mdx +227 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductDeleted/examples/index.mdx +175 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductUpdated/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/queries/GetProduct/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/search-system/services/SearchAPI/queries/SearchProducts/examples/index.mdx +369 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/RegisterCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/UpdateCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerRegistered/examples/index.mdx +201 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerUpdated/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/queries/GetCustomer/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/commands/AuthenticateCustomer/examples/index.mdx +198 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/events/CustomerAuthenticated/examples/index.mdx +276 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentCreated/examples/index.mdx +184 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentDelivered/examples/index.mdx +173 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/commands/ReleaseInventory/examples/index.mdx +246 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryReserved/examples/index.mdx +227 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryUnavailable/examples/index.mdx +229 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/queries/GetStockLevel/examples/index.mdx +186 -0
- package/templates/default/domains/Fulfilment/systems/shipping-system/services/CarrierAdapter/commands/CreateShipment/examples/index.mdx +206 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/PickingWorker/events/OrderPacked/examples/index.mdx +172 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/WarehouseService/events/OrderReadyForShipping/examples/index.mdx +208 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/AuthorizePayment/examples/index.mdx +179 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/ReserveInventory/examples/index.mdx +215 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CancelOrder/examples/index.mdx +163 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CreateOrder/examples/index.mdx +246 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCancelled/examples/index.mdx +267 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCompleted/examples/index.mdx +171 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCreated/examples/index.mdx +190 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/queries/GetOrder/examples/index.mdx +343 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckFailed/examples/index.mdx +271 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckPassed/examples/index.mdx +173 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/PaymentRequested/examples/index.mdx +191 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/RefundRequested/examples/index.mdx +194 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentSucceeded/examples/index.mdx +190 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/RefundProcessed/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/RatingAggregator/events/rating-updated/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/flag-review/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/submit-review/examples/index.mdx +195 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/vote-review-helpful/examples/index.mdx +178 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-flagged/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-helpful-voted/examples/index.mdx +177 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-submitted/examples/index.mdx +194 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/queries/get-product-reviews/examples/index.mdx +259 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-published/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-rejected/examples/index.mdx +178 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/AddItemToCart/examples/index.mdx +171 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/CheckoutCart/examples/index.mdx +168 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/RemoveItemFromCart/examples/index.mdx +170 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/events/CartCheckedOut/examples/index.mdx +275 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/commands/CalculateDiscount/examples/index.mdx +207 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/events/DiscountCalculated/examples/index.mdx +190 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Request a full refund for a cancelled order
|
|
6
|
+
|
|
7
|
+
The customer cancels their T-shirt and cap order before it is dispatched. The PaymentWorker publishes `RefundRequested` so Stripe returns the full charge.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `refundId` identifies this refund; `paymentId` is the original charge being refunded.
|
|
12
|
+
- `orderId` is included so the refund can be traced back to the cancelled order.
|
|
13
|
+
- `amount` matches the original charge, in pence.
|
|
14
|
+
- `reason` is free text recorded for support and reporting.
|
|
15
|
+
|
|
16
|
+
The refund is **4,298 pence (£42.98)**, the full amount of the original payment.
|
|
17
|
+
|
|
18
|
+
### Using this example
|
|
19
|
+
|
|
20
|
+
Consumers should refund `amount` against `paymentId` and reply with a `RefundProcessed` event that carries the same `refundId`.
|
|
21
|
+
|
|
22
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the RefundRequested schema. The package names and publish methods are illustrative.
|
|
23
|
+
|
|
24
|
+
</Column>
|
|
25
|
+
|
|
26
|
+
<Column>
|
|
27
|
+
|
|
28
|
+
<CodeGroup dropdown>
|
|
29
|
+
|
|
30
|
+
```typescript publish-refund-requested.ts
|
|
31
|
+
import { EventsClient } from '@acme/events';
|
|
32
|
+
import type { RefundRequested } from './schemas/refund-requested';
|
|
33
|
+
|
|
34
|
+
const client = new EventsClient({
|
|
35
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const event: RefundRequested = {
|
|
39
|
+
refundId: 'b5e477d7-f910-43f5-a371-e9f3f53cfaa2',
|
|
40
|
+
paymentId: '586e57ab-77a9-406a-945d-4619c76a582e',
|
|
41
|
+
orderId: '971b5a4b-6885-405c-899b-5e0f428016c1',
|
|
42
|
+
amount: 4298,
|
|
43
|
+
currency: 'GBP',
|
|
44
|
+
reason: 'Order cancelled by customer before dispatch',
|
|
45
|
+
requestedAt: '2026-09-11T14:05:10Z',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await client.publish('RefundRequested', event);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```python publish_refund_requested.py
|
|
52
|
+
import os
|
|
53
|
+
from acme_events import EventsClient
|
|
54
|
+
|
|
55
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
56
|
+
|
|
57
|
+
event = {
|
|
58
|
+
"refundId": "b5e477d7-f910-43f5-a371-e9f3f53cfaa2",
|
|
59
|
+
"paymentId": "586e57ab-77a9-406a-945d-4619c76a582e",
|
|
60
|
+
"orderId": "971b5a4b-6885-405c-899b-5e0f428016c1",
|
|
61
|
+
"amount": 4298,
|
|
62
|
+
"currency": "GBP",
|
|
63
|
+
"reason": "Order cancelled by customer before dispatch",
|
|
64
|
+
"requestedAt": "2026-09-11T14:05:10Z",
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
client.publish("RefundRequested", event)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```java PublishRefundRequested.java
|
|
71
|
+
import com.acme.events.EventsClient;
|
|
72
|
+
import java.util.Map;
|
|
73
|
+
|
|
74
|
+
public class PublishRefundRequested {
|
|
75
|
+
public static void main(String[] args) {
|
|
76
|
+
var client = new EventsClient(
|
|
77
|
+
System.getenv("ACME_API_KEY")
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
var event = Map.of(
|
|
81
|
+
"refundId", "b5e477d7-f910-43f5-a371-e9f3f53cfaa2",
|
|
82
|
+
"paymentId", "586e57ab-77a9-406a-945d-4619c76a582e",
|
|
83
|
+
"orderId", "971b5a4b-6885-405c-899b-5e0f428016c1",
|
|
84
|
+
"amount", 4298,
|
|
85
|
+
"currency", "GBP",
|
|
86
|
+
"reason", "Order cancelled by customer before dispatch",
|
|
87
|
+
"requestedAt", "2026-09-11T14:05:10Z"
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
client.publish("RefundRequested", event);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
</CodeGroup>
|
|
96
|
+
|
|
97
|
+
</Column>
|
|
98
|
+
|
|
99
|
+
</Columns>
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
<Columns cols={2}>
|
|
104
|
+
|
|
105
|
+
<Column>
|
|
106
|
+
|
|
107
|
+
## 2. Request a partial refund for a returned item
|
|
108
|
+
|
|
109
|
+
The guest shopper returns one of the three hoodies. The PaymentWorker publishes `RefundRequested` for that item only, using just the required fields.
|
|
110
|
+
|
|
111
|
+
### Payload details
|
|
112
|
+
|
|
113
|
+
- `paymentId` is the original €164.97 charge; only part of it is refunded.
|
|
114
|
+
- `amount` is one hoodie at €54.99, in cents.
|
|
115
|
+
- `orderId` and `reason` are optional and omitted here.
|
|
116
|
+
|
|
117
|
+
The refund is **5,499 cents (€54.99)**, leaving 10,998 cents (€109.98) charged.
|
|
118
|
+
|
|
119
|
+
### Using this example
|
|
120
|
+
|
|
121
|
+
Use this payload to check that consumers support partial refunds, where `amount` is less than the original charge.
|
|
122
|
+
|
|
123
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the RefundRequested schema. The package names and publish methods are illustrative.
|
|
124
|
+
|
|
125
|
+
</Column>
|
|
126
|
+
|
|
127
|
+
<Column>
|
|
128
|
+
|
|
129
|
+
<CodeGroup dropdown>
|
|
130
|
+
|
|
131
|
+
```typescript publish-refund-requested.ts
|
|
132
|
+
import { EventsClient } from '@acme/events';
|
|
133
|
+
import type { RefundRequested } from './schemas/refund-requested';
|
|
134
|
+
|
|
135
|
+
const client = new EventsClient({
|
|
136
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
const event: RefundRequested = {
|
|
140
|
+
refundId: 'f57e3268-60d1-4b1d-96e9-c27d47992d47',
|
|
141
|
+
paymentId: '41651c3f-fa8e-40fc-a217-a83929d15081',
|
|
142
|
+
amount: 5499,
|
|
143
|
+
currency: 'EUR',
|
|
144
|
+
requestedAt: '2026-09-21T09:40:00Z',
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
await client.publish('RefundRequested', event);
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```python publish_refund_requested.py
|
|
151
|
+
import os
|
|
152
|
+
from acme_events import EventsClient
|
|
153
|
+
|
|
154
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
155
|
+
|
|
156
|
+
event = {
|
|
157
|
+
"refundId": "f57e3268-60d1-4b1d-96e9-c27d47992d47",
|
|
158
|
+
"paymentId": "41651c3f-fa8e-40fc-a217-a83929d15081",
|
|
159
|
+
"amount": 5499,
|
|
160
|
+
"currency": "EUR",
|
|
161
|
+
"requestedAt": "2026-09-21T09:40:00Z",
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
client.publish("RefundRequested", event)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```java PublishRefundRequested.java
|
|
168
|
+
import com.acme.events.EventsClient;
|
|
169
|
+
import java.util.Map;
|
|
170
|
+
|
|
171
|
+
public class PublishRefundRequested {
|
|
172
|
+
public static void main(String[] args) {
|
|
173
|
+
var client = new EventsClient(
|
|
174
|
+
System.getenv("ACME_API_KEY")
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
var event = Map.of(
|
|
178
|
+
"refundId", "f57e3268-60d1-4b1d-96e9-c27d47992d47",
|
|
179
|
+
"paymentId", "41651c3f-fa8e-40fc-a217-a83929d15081",
|
|
180
|
+
"amount", 5499,
|
|
181
|
+
"currency", "EUR",
|
|
182
|
+
"requestedAt", "2026-09-21T09:40:00Z"
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
client.publish("RefundRequested", event);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
</CodeGroup>
|
|
191
|
+
|
|
192
|
+
</Column>
|
|
193
|
+
|
|
194
|
+
</Columns>
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Report a declined card
|
|
6
|
+
|
|
7
|
+
The customer's bank declines the card for a hoodie order. The StripeWebhookEndpoint publishes `PaymentFailed` and the PaymentWorker records the payment as failed, which leads to the order being cancelled.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reason` is `CARD_DECLINED`: the issuing bank refused the charge.
|
|
12
|
+
- `paymentId` and `orderId` identify the failed payment and its order.
|
|
13
|
+
- `failedAt` is when Stripe reported the failure.
|
|
14
|
+
|
|
15
|
+
### Using this example
|
|
16
|
+
|
|
17
|
+
Consumers should mark the payment as failed and start cancelling `orderId`. The customer can be asked to try another card.
|
|
18
|
+
|
|
19
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the PaymentFailed schema. The package names and publish methods are illustrative.
|
|
20
|
+
|
|
21
|
+
</Column>
|
|
22
|
+
|
|
23
|
+
<Column>
|
|
24
|
+
|
|
25
|
+
<CodeGroup dropdown>
|
|
26
|
+
|
|
27
|
+
```typescript publish-payment-failed.ts
|
|
28
|
+
import { EventsClient } from '@acme/events';
|
|
29
|
+
import type { PaymentFailed } from './schemas/payment-failed';
|
|
30
|
+
|
|
31
|
+
const client = new EventsClient({
|
|
32
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const event: PaymentFailed = {
|
|
36
|
+
paymentId: '428dc169-43a6-479d-9661-5b07984cb556',
|
|
37
|
+
orderId: '2d7ef31b-211a-4dbc-898a-0b095e7b909c',
|
|
38
|
+
reason: 'CARD_DECLINED',
|
|
39
|
+
failedAt: '2026-09-16T02:47:20Z',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
await client.publish('PaymentFailed', event);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python publish_payment_failed.py
|
|
46
|
+
import os
|
|
47
|
+
from acme_events import EventsClient
|
|
48
|
+
|
|
49
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
50
|
+
|
|
51
|
+
event = {
|
|
52
|
+
"paymentId": "428dc169-43a6-479d-9661-5b07984cb556",
|
|
53
|
+
"orderId": "2d7ef31b-211a-4dbc-898a-0b095e7b909c",
|
|
54
|
+
"reason": "CARD_DECLINED",
|
|
55
|
+
"failedAt": "2026-09-16T02:47:20Z",
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
client.publish("PaymentFailed", event)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```java PublishPaymentFailed.java
|
|
62
|
+
import com.acme.events.EventsClient;
|
|
63
|
+
import java.util.Map;
|
|
64
|
+
|
|
65
|
+
public class PublishPaymentFailed {
|
|
66
|
+
public static void main(String[] args) {
|
|
67
|
+
var client = new EventsClient(
|
|
68
|
+
System.getenv("ACME_API_KEY")
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
var event = Map.of(
|
|
72
|
+
"paymentId", "428dc169-43a6-479d-9661-5b07984cb556",
|
|
73
|
+
"orderId", "2d7ef31b-211a-4dbc-898a-0b095e7b909c",
|
|
74
|
+
"reason", "CARD_DECLINED",
|
|
75
|
+
"failedAt", "2026-09-16T02:47:20Z"
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
client.publish("PaymentFailed", event);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
</CodeGroup>
|
|
84
|
+
|
|
85
|
+
</Column>
|
|
86
|
+
|
|
87
|
+
</Columns>
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
<Columns cols={2}>
|
|
92
|
+
|
|
93
|
+
<Column>
|
|
94
|
+
|
|
95
|
+
## 2. Report an expired card
|
|
96
|
+
|
|
97
|
+
A customer pays for a cap with a saved card that has expired. Stripe rejects the charge and the StripeWebhookEndpoint publishes `PaymentFailed`.
|
|
98
|
+
|
|
99
|
+
### Payload details
|
|
100
|
+
|
|
101
|
+
- `reason` is `EXPIRED_CARD`: the card's expiry date has passed.
|
|
102
|
+
- This is caused by the customer's card details, so retrying the same card will not help.
|
|
103
|
+
|
|
104
|
+
### Using this example
|
|
105
|
+
|
|
106
|
+
Use this payload to check that consumers prompt the customer to update their card rather than retrying.
|
|
107
|
+
|
|
108
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the PaymentFailed schema. The package names and publish methods are illustrative.
|
|
109
|
+
|
|
110
|
+
</Column>
|
|
111
|
+
|
|
112
|
+
<Column>
|
|
113
|
+
|
|
114
|
+
<CodeGroup dropdown>
|
|
115
|
+
|
|
116
|
+
```typescript publish-payment-failed.ts
|
|
117
|
+
import { EventsClient } from '@acme/events';
|
|
118
|
+
import type { PaymentFailed } from './schemas/payment-failed';
|
|
119
|
+
|
|
120
|
+
const client = new EventsClient({
|
|
121
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const event: PaymentFailed = {
|
|
125
|
+
paymentId: 'dfdffee1-3e4d-4fa3-b86e-ebe0cd93ca60',
|
|
126
|
+
orderId: '76d60366-d78a-4e10-b1ad-832445febfa1',
|
|
127
|
+
reason: 'EXPIRED_CARD',
|
|
128
|
+
failedAt: '2026-09-17T11:20:09Z',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
await client.publish('PaymentFailed', event);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```python publish_payment_failed.py
|
|
135
|
+
import os
|
|
136
|
+
from acme_events import EventsClient
|
|
137
|
+
|
|
138
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
139
|
+
|
|
140
|
+
event = {
|
|
141
|
+
"paymentId": "dfdffee1-3e4d-4fa3-b86e-ebe0cd93ca60",
|
|
142
|
+
"orderId": "76d60366-d78a-4e10-b1ad-832445febfa1",
|
|
143
|
+
"reason": "EXPIRED_CARD",
|
|
144
|
+
"failedAt": "2026-09-17T11:20:09Z",
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
client.publish("PaymentFailed", event)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```java PublishPaymentFailed.java
|
|
151
|
+
import com.acme.events.EventsClient;
|
|
152
|
+
import java.util.Map;
|
|
153
|
+
|
|
154
|
+
public class PublishPaymentFailed {
|
|
155
|
+
public static void main(String[] args) {
|
|
156
|
+
var client = new EventsClient(
|
|
157
|
+
System.getenv("ACME_API_KEY")
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
var event = Map.of(
|
|
161
|
+
"paymentId", "dfdffee1-3e4d-4fa3-b86e-ebe0cd93ca60",
|
|
162
|
+
"orderId", "76d60366-d78a-4e10-b1ad-832445febfa1",
|
|
163
|
+
"reason", "EXPIRED_CARD",
|
|
164
|
+
"failedAt", "2026-09-17T11:20:09Z"
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
client.publish("PaymentFailed", event);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
</CodeGroup>
|
|
173
|
+
|
|
174
|
+
</Column>
|
|
175
|
+
|
|
176
|
+
</Columns>
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
<Columns cols={2}>
|
|
181
|
+
|
|
182
|
+
<Column>
|
|
183
|
+
|
|
184
|
+
## 3. Report a processing error
|
|
185
|
+
|
|
186
|
+
Stripe has a temporary problem while charging a T-shirt order. The StripeWebhookEndpoint publishes `PaymentFailed` even though the card itself is fine.
|
|
187
|
+
|
|
188
|
+
### Payload details
|
|
189
|
+
|
|
190
|
+
- `reason` is `PROCESSING_ERROR`: the failure is on the processor side, not the customer's card.
|
|
191
|
+
- This is the only reason in the schema where a retry may succeed.
|
|
192
|
+
|
|
193
|
+
### Using this example
|
|
194
|
+
|
|
195
|
+
Use this payload to test retry handling: consumers may retry the charge before cancelling the order.
|
|
196
|
+
|
|
197
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the PaymentFailed schema. The package names and publish methods are illustrative.
|
|
198
|
+
|
|
199
|
+
</Column>
|
|
200
|
+
|
|
201
|
+
<Column>
|
|
202
|
+
|
|
203
|
+
<CodeGroup dropdown>
|
|
204
|
+
|
|
205
|
+
```typescript publish-payment-failed.ts
|
|
206
|
+
import { EventsClient } from '@acme/events';
|
|
207
|
+
import type { PaymentFailed } from './schemas/payment-failed';
|
|
208
|
+
|
|
209
|
+
const client = new EventsClient({
|
|
210
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const event: PaymentFailed = {
|
|
214
|
+
paymentId: '0c3b8e41-5a7f-4d26-9e18-b4f2a6d09c75',
|
|
215
|
+
orderId: '99027891-075d-4561-91f8-da95f34e4a57',
|
|
216
|
+
reason: 'PROCESSING_ERROR',
|
|
217
|
+
failedAt: '2026-09-18T16:55:48Z',
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
await client.publish('PaymentFailed', event);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
```python publish_payment_failed.py
|
|
224
|
+
import os
|
|
225
|
+
from acme_events import EventsClient
|
|
226
|
+
|
|
227
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
228
|
+
|
|
229
|
+
event = {
|
|
230
|
+
"paymentId": "0c3b8e41-5a7f-4d26-9e18-b4f2a6d09c75",
|
|
231
|
+
"orderId": "99027891-075d-4561-91f8-da95f34e4a57",
|
|
232
|
+
"reason": "PROCESSING_ERROR",
|
|
233
|
+
"failedAt": "2026-09-18T16:55:48Z",
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
client.publish("PaymentFailed", event)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```java PublishPaymentFailed.java
|
|
240
|
+
import com.acme.events.EventsClient;
|
|
241
|
+
import java.util.Map;
|
|
242
|
+
|
|
243
|
+
public class PublishPaymentFailed {
|
|
244
|
+
public static void main(String[] args) {
|
|
245
|
+
var client = new EventsClient(
|
|
246
|
+
System.getenv("ACME_API_KEY")
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
var event = Map.of(
|
|
250
|
+
"paymentId", "0c3b8e41-5a7f-4d26-9e18-b4f2a6d09c75",
|
|
251
|
+
"orderId", "99027891-075d-4561-91f8-da95f34e4a57",
|
|
252
|
+
"reason", "PROCESSING_ERROR",
|
|
253
|
+
"failedAt", "2026-09-18T16:55:48Z"
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
client.publish("PaymentFailed", event);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
</CodeGroup>
|
|
262
|
+
|
|
263
|
+
</Column>
|
|
264
|
+
|
|
265
|
+
</Columns>
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Confirm a card charge with a Stripe reference
|
|
6
|
+
|
|
7
|
+
Stripe charges the card for the T-shirt and cap order. The StripeWebhookEndpoint publishes `PaymentSucceeded` and the PaymentWorker records the payment as succeeded.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `paymentId` and `orderId` match the original `PaymentRequested` event.
|
|
12
|
+
- `amount` and `currency` are what Stripe actually charged, in pence.
|
|
13
|
+
- `processorReference` is Stripe's charge ID, kept for reconciliation and refunds.
|
|
14
|
+
|
|
15
|
+
The customer was charged **4,298 pence (£42.98)**.
|
|
16
|
+
|
|
17
|
+
### Using this example
|
|
18
|
+
|
|
19
|
+
Consumers should check that `amount` and `currency` match the requested charge before marking the payment as succeeded.
|
|
20
|
+
|
|
21
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the PaymentSucceeded schema. The package names and publish methods are illustrative.
|
|
22
|
+
|
|
23
|
+
</Column>
|
|
24
|
+
|
|
25
|
+
<Column>
|
|
26
|
+
|
|
27
|
+
<CodeGroup dropdown>
|
|
28
|
+
|
|
29
|
+
```typescript publish-payment-succeeded.ts
|
|
30
|
+
import { EventsClient } from '@acme/events';
|
|
31
|
+
import type { PaymentSucceeded } from './schemas/payment-succeeded';
|
|
32
|
+
|
|
33
|
+
const client = new EventsClient({
|
|
34
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const event: PaymentSucceeded = {
|
|
38
|
+
paymentId: '586e57ab-77a9-406a-945d-4619c76a582e',
|
|
39
|
+
orderId: '971b5a4b-6885-405c-899b-5e0f428016c1',
|
|
40
|
+
amount: 4298,
|
|
41
|
+
currency: 'GBP',
|
|
42
|
+
processorReference: 'ch_3PqL8x2eZvKYlo2C1a9bR4tD',
|
|
43
|
+
succeededAt: '2026-09-11T08:12:52Z',
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
await client.publish('PaymentSucceeded', event);
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```python publish_payment_succeeded.py
|
|
50
|
+
import os
|
|
51
|
+
from acme_events import EventsClient
|
|
52
|
+
|
|
53
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
54
|
+
|
|
55
|
+
event = {
|
|
56
|
+
"paymentId": "586e57ab-77a9-406a-945d-4619c76a582e",
|
|
57
|
+
"orderId": "971b5a4b-6885-405c-899b-5e0f428016c1",
|
|
58
|
+
"amount": 4298,
|
|
59
|
+
"currency": "GBP",
|
|
60
|
+
"processorReference": "ch_3PqL8x2eZvKYlo2C1a9bR4tD",
|
|
61
|
+
"succeededAt": "2026-09-11T08:12:52Z",
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
client.publish("PaymentSucceeded", event)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```java PublishPaymentSucceeded.java
|
|
68
|
+
import com.acme.events.EventsClient;
|
|
69
|
+
import java.util.Map;
|
|
70
|
+
|
|
71
|
+
public class PublishPaymentSucceeded {
|
|
72
|
+
public static void main(String[] args) {
|
|
73
|
+
var client = new EventsClient(
|
|
74
|
+
System.getenv("ACME_API_KEY")
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
var event = Map.of(
|
|
78
|
+
"paymentId", "586e57ab-77a9-406a-945d-4619c76a582e",
|
|
79
|
+
"orderId", "971b5a4b-6885-405c-899b-5e0f428016c1",
|
|
80
|
+
"amount", 4298,
|
|
81
|
+
"currency", "GBP",
|
|
82
|
+
"processorReference", "ch_3PqL8x2eZvKYlo2C1a9bR4tD",
|
|
83
|
+
"succeededAt", "2026-09-11T08:12:52Z"
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
client.publish("PaymentSucceeded", event);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
</CodeGroup>
|
|
92
|
+
|
|
93
|
+
</Column>
|
|
94
|
+
|
|
95
|
+
</Columns>
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
<Columns cols={2}>
|
|
100
|
+
|
|
101
|
+
<Column>
|
|
102
|
+
|
|
103
|
+
## 2. Confirm a charge without a processor reference
|
|
104
|
+
|
|
105
|
+
Stripe confirms the guest hoodie payment. The webhook arrives without a charge ID, so only the required fields are published.
|
|
106
|
+
|
|
107
|
+
### Payload details
|
|
108
|
+
|
|
109
|
+
- `processorReference` is optional and omitted here.
|
|
110
|
+
- `amount` is three hoodies at €54.99 each, in cents.
|
|
111
|
+
- `currency` is `EUR`.
|
|
112
|
+
|
|
113
|
+
The customer was charged **16,497 cents (€164.97)**.
|
|
114
|
+
|
|
115
|
+
### Using this example
|
|
116
|
+
|
|
117
|
+
Use this payload to check that the PaymentWorker records the payment even when `processorReference` is missing.
|
|
118
|
+
|
|
119
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the PaymentSucceeded schema. The package names and publish methods are illustrative.
|
|
120
|
+
|
|
121
|
+
</Column>
|
|
122
|
+
|
|
123
|
+
<Column>
|
|
124
|
+
|
|
125
|
+
<CodeGroup dropdown>
|
|
126
|
+
|
|
127
|
+
```typescript publish-payment-succeeded.ts
|
|
128
|
+
import { EventsClient } from '@acme/events';
|
|
129
|
+
import type { PaymentSucceeded } from './schemas/payment-succeeded';
|
|
130
|
+
|
|
131
|
+
const client = new EventsClient({
|
|
132
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const event: PaymentSucceeded = {
|
|
136
|
+
paymentId: '41651c3f-fa8e-40fc-a217-a83929d15081',
|
|
137
|
+
orderId: 'e39a80be-526e-4009-a22a-40c847cff088',
|
|
138
|
+
amount: 16497,
|
|
139
|
+
currency: 'EUR',
|
|
140
|
+
succeededAt: '2026-09-14T19:03:34Z',
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
await client.publish('PaymentSucceeded', event);
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```python publish_payment_succeeded.py
|
|
147
|
+
import os
|
|
148
|
+
from acme_events import EventsClient
|
|
149
|
+
|
|
150
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
151
|
+
|
|
152
|
+
event = {
|
|
153
|
+
"paymentId": "41651c3f-fa8e-40fc-a217-a83929d15081",
|
|
154
|
+
"orderId": "e39a80be-526e-4009-a22a-40c847cff088",
|
|
155
|
+
"amount": 16497,
|
|
156
|
+
"currency": "EUR",
|
|
157
|
+
"succeededAt": "2026-09-14T19:03:34Z",
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
client.publish("PaymentSucceeded", event)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```java PublishPaymentSucceeded.java
|
|
164
|
+
import com.acme.events.EventsClient;
|
|
165
|
+
import java.util.Map;
|
|
166
|
+
|
|
167
|
+
public class PublishPaymentSucceeded {
|
|
168
|
+
public static void main(String[] args) {
|
|
169
|
+
var client = new EventsClient(
|
|
170
|
+
System.getenv("ACME_API_KEY")
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
var event = Map.of(
|
|
174
|
+
"paymentId", "41651c3f-fa8e-40fc-a217-a83929d15081",
|
|
175
|
+
"orderId", "e39a80be-526e-4009-a22a-40c847cff088",
|
|
176
|
+
"amount", 16497,
|
|
177
|
+
"currency", "EUR",
|
|
178
|
+
"succeededAt", "2026-09-14T19:03:34Z"
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
client.publish("PaymentSucceeded", event);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
</CodeGroup>
|
|
187
|
+
|
|
188
|
+
</Column>
|
|
189
|
+
|
|
190
|
+
</Columns>
|