1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
//! Payment log models: the traffic of one payment, that is the requests sent
//! to the payment provider, the webhooks the provider sent, and the webhooks
//! sent to the shop with every delivery attempt.
//!
//! Every body and header is masked by the API before it is returned.
use serde::Deserialize;
use serde_json::Value;
/// The traffic of a payment, oldest first, without payloads.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogsResponse {
/// The payment these entries belong to.
pub payment_id: String,
/// Whether requests to the payment provider and its webhooks are recorded
/// for this payment's merchant right now.
pub psp_traffic_recorded: bool,
/// `true` when the caller's role may not see processor details; provider
/// requests and provider webhooks are then left out.
pub processor_details_hidden: bool,
/// How many days provider requests are kept.
pub connector_call_retention_days: i32,
/// How many days provider webhooks are kept.
pub incoming_webhook_retention_days: i32,
/// Requests sent to the payment provider, oldest first.
#[serde(default)]
pub connector_calls: Vec<PaymentLogConnectorCall>,
/// `true` when there were more provider requests than were returned.
pub connector_calls_truncated: bool,
/// Webhooks the payment provider sent about this payment, oldest first.
#[serde(default)]
pub incoming_webhooks: Vec<PaymentLogIncomingWebhook>,
/// `true` when there were more provider webhooks than were returned.
pub incoming_webhooks_truncated: bool,
/// Webhooks sent to the shop about this payment and its refunds and
/// disputes, oldest first.
#[serde(default)]
pub outgoing_webhooks: Vec<PaymentLogOutgoingWebhook>,
/// `true` when there were more shop webhooks than were returned.
pub outgoing_webhooks_truncated: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One request sent to the payment provider.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogConnectorCall {
/// The identifier of this recorded request.
pub id: String,
/// ISO 8601 time the request was sent.
pub started_at: String,
/// The payment provider.
pub connector: String,
/// What the request did, such as `Authorize`, `Capture`, `PSync` or
/// `Execute` (a refund).
pub flow: String,
/// The HTTP method.
pub method: String,
/// The provider URL the request was sent to.
pub url: String,
/// The HTTP status the provider answered with. `0` when no answer
/// arrived.
pub status_code: i32,
/// How long the provider took to answer, in milliseconds.
pub latency_ms: i64,
/// The payment attempt the request was made for.
#[serde(default)]
pub attempt_id: Option<String>,
/// The refund the request was made for.
#[serde(default)]
pub refund_id: Option<String>,
/// The dispute the request was made for.
#[serde(default)]
pub dispute_id: Option<String>,
/// The API request that made this call.
pub request_id: String,
/// Whether the request went to the provider's test environment. `None`
/// when unknown.
#[serde(default)]
pub test_mode: Option<bool>,
/// `true` when the call recorded an error.
pub has_error: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One webhook the payment provider sent.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogIncomingWebhook {
/// The identifier of this recorded delivery.
pub event_id: String,
/// ISO 8601 time it was received.
pub received_at: String,
/// The payment provider.
pub connector: String,
/// The provider's identifier for the event.
#[serde(default)]
pub provider_event_id: Option<String>,
/// The provider's name for the event, such as
/// `payment_intent.succeeded`.
#[serde(default)]
pub provider_event_type: Option<String>,
/// The event the provider's event was understood as.
#[serde(default)]
pub mapped_event_type: Option<String>,
/// The kind of object the event was about.
#[serde(default)]
pub object_type: Option<String>,
/// The provider's identifier for that object.
#[serde(default)]
pub object_ref_id: Option<String>,
/// The payment attempt the event was matched to.
#[serde(default)]
pub resolved_attempt_id: Option<String>,
/// Whether the signature was verified. `None` when the delivery stopped
/// before verification.
#[serde(default)]
pub source_verified: Option<bool>,
/// What was done with it: `applied`, `ignored`, `duplicate`, `rejected`,
/// `dropped`, `error` or `unrecognised`.
pub outcome: String,
/// More about the outcome, where recorded.
#[serde(default)]
pub outcome_detail: Option<String>,
/// The HTTP status the provider was answered with.
pub response_status: i32,
/// How long the answer took, in milliseconds.
pub latency_ms: i32,
/// Whether the event came from the provider's test environment. `None`
/// when unknown.
#[serde(default)]
pub test_mode: Option<bool>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One webhook sent to the shop, with every delivery attempt.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogOutgoingWebhook {
/// The identifier of the first delivery, shared by every retry.
pub initial_attempt_id: String,
/// The event that was sent, e.g. `payment_succeeded`.
pub event_type: String,
/// The object the event was about: this payment, or one of its refunds
/// or disputes.
pub object_id: String,
/// ISO 8601 time the event was created.
pub created_at: String,
/// Whether one of the attempts was delivered. `None` while unknown.
#[serde(default)]
pub is_delivery_successful: Option<bool>,
/// Why delivery stopped: `endpoint_rejected`, `retries_exhausted` or
/// `no_webhook_url`.
#[serde(default)]
pub delivery_terminal_reason: Option<String>,
/// Whether the event was routed as a test-mode event. `None` when
/// unknown.
#[serde(default)]
pub test_mode: Option<bool>,
/// Every delivery attempt, oldest first.
#[serde(default)]
pub attempts: Vec<PaymentLogOutgoingAttempt>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One delivery attempt of a shop webhook, as listed.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogOutgoingAttempt {
/// The identifier of this attempt.
pub event_id: String,
/// ISO 8601 time the attempt was made.
pub created_at: String,
/// `initial_attempt`, `automatic_retry`, `manual_retry` or
/// `manual_trigger`.
#[serde(default)]
pub delivery_attempt: Option<String>,
/// Whether the shop's endpoint accepted it.
pub is_webhook_notified: bool,
/// The HTTP status the shop answered with. `None` when no answer
/// arrived.
#[serde(default)]
pub status_code: Option<i32>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One provider request of a payment, with its masked request, response and
/// error.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogConnectorCallDetail {
/// The request as listed.
pub call: PaymentLogConnectorCall,
/// The request body as sent, masked. A string when the body was not
/// JSON; `None` when nothing was recorded.
#[serde(default)]
pub request: Option<Value>,
/// The response body as received, masked. `None` when nothing was
/// recorded.
#[serde(default)]
pub response: Option<Value>,
/// The error recorded for the call, masked. `None` when there was none.
#[serde(default)]
pub error: Option<Value>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One provider webhook of a payment, with its masked headers and body.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogIncomingWebhookDetail {
/// The webhook as listed.
pub webhook: PaymentLogIncomingWebhook,
/// The headers as received, masked. Credential headers were removed
/// before storage; signature headers are kept.
#[serde(default)]
pub headers: Option<Value>,
/// The body as received, masked.
#[serde(default)]
pub body: Option<Value>,
/// Which secret verified the signature and whether the object matched.
/// Never the secret itself.
#[serde(default)]
pub verification_detail: Option<Value>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Every delivery attempt of one shop webhook, with request and response.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogOutgoingWebhookDetail {
/// The identifier of the first delivery, shared by every retry.
pub initial_attempt_id: String,
/// Every delivery attempt, oldest first.
#[serde(default)]
pub attempts: Vec<PaymentLogOutgoingDelivery>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One delivery attempt of a shop webhook, with what was sent and answered.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogOutgoingDelivery {
/// The identifier of this attempt.
pub event_id: String,
/// ISO 8601 time the attempt was made.
pub created_at: String,
/// `initial_attempt`, `automatic_retry`, `manual_retry` or
/// `manual_trigger`.
#[serde(default)]
pub delivery_attempt: Option<String>,
/// Whether the shop's endpoint accepted it.
pub is_webhook_notified: bool,
/// The headers sent.
#[serde(default)]
pub request_headers: Vec<PaymentLogHeader>,
/// The body sent, masked: parsed JSON where it is JSON, otherwise a
/// string.
#[serde(default)]
pub request_body: Option<Value>,
/// The HTTP status the shop answered with. `None` when no answer
/// arrived.
#[serde(default)]
pub response_status_code: Option<i32>,
/// The headers the shop answered with.
#[serde(default)]
pub response_headers: Vec<PaymentLogHeader>,
/// The body the shop answered with, masked. `None` when there was none.
#[serde(default)]
pub response_body: Option<Value>,
/// Why the delivery failed, when it did before an answer arrived.
#[serde(default)]
pub error_message: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One recorded HTTP header.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentLogHeader {
/// The header name.
pub name: String,
/// The header value, or a mask.
pub value: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}