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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
//! The buyer blocklist: the buyers a merchant refuses to sell to again, and
//! the Stripe Radar value lists the blocklist can be copied to.
//!
//! An entry's identifiers (email, IP address, customer id, device id, card
//! fingerprint, card BIN, IP range) are personal data: `Debug` on the types
//! that carry them prints `<redacted>` in their place.
use std::fmt;
use serde::Deserialize;
use serde_json::Value;
/// `Some("<redacted>")` for a present value, `None` for an absent one, so
/// `Debug` still shows which identifiers an entry carries.
fn redact<T>(value: &Option<T>) -> Option<&'static str> {
value.as_ref().map(|_| "<redacted>")
}
/// The processor a blocked card fingerprint came from.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistCardSource {
/// The connector.
pub connector: String,
/// The connector account.
#[serde(default)]
pub merchant_connector_id: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The addresses an "all IPs" block took.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistIpSnapshot {
/// The addresses blocked by this call.
#[serde(default)]
pub blocked: Vec<String>,
/// The addresses another entry already blocked.
#[serde(default)]
pub already_blocked: Vec<String>,
/// Whether the candidates were cut at the limit.
pub truncated: bool,
/// How many candidates there were.
pub total: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for BuyerBlocklistIpSnapshot {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BuyerBlocklistIpSnapshot")
.field(
"blocked",
&format_args!("<{} redacted>", self.blocked.len()),
)
.field(
"already_blocked",
&format_args!("<{} redacted>", self.already_blocked.len()),
)
.field("truncated", &self.truncated)
.field("total", &self.total)
.finish_non_exhaustive()
}
}
/// One identifier's sync to one Radar value list.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarSyncItem {
/// `card_fingerprint`, `email`, `ip` or `card_bin`.
pub identifier: String,
/// The item's sync status.
pub status: String,
/// The Radar value list's alias.
pub value_list_alias: String,
/// The last sync error.
#[serde(default)]
pub last_error: Option<String>,
/// Sync attempts so far.
pub attempts: i64,
/// ISO 8601 last-update timestamp.
pub updated_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// An entry's sync to one Stripe connection.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarSyncConnection {
/// The Stripe connector account.
pub merchant_connector_id: String,
/// The connection's label.
#[serde(default)]
pub connector_label: Option<String>,
/// The connection's shop.
pub profile_id: String,
/// `live` or `sandbox`.
pub environment: String,
/// One item per synced identifier.
#[serde(default)]
pub items: Vec<RadarSyncItem>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Where an entry stands with Stripe Radar.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistRadarState {
/// Whether the caller's role hides processor names, so `connections` is
/// left empty.
pub processor_names_hidden: bool,
/// `shared`, `local_only`, `pending` or `failed`.
pub status: String,
/// The Stripe connections the entry syncs to.
#[serde(default)]
pub connections: Vec<RadarSyncConnection>,
/// Why the entry stays local, for a `local_only` status.
#[serde(default)]
pub local_only_reason: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A buyer blocklist entry.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistEntryResponse {
/// The entry's id.
pub id: String,
/// The blocked email address.
#[serde(default)]
pub email: Option<String>,
/// The blocked IP address.
#[serde(default)]
pub ip: Option<String>,
/// The blocked customer id.
#[serde(default)]
pub customer_id: Option<String>,
/// The blocked device id.
#[serde(default)]
pub device_id: Option<String>,
/// The entry's primary identifier kind, for example `email`, `ip`,
/// `ip_class` or `card_fingerprint`.
pub kind: String,
/// The primary identifier's value.
pub value: String,
/// The shop the entry blocks in, or `None` for every shop.
#[serde(default)]
pub profile_id: Option<String>,
/// The internal note.
#[serde(default)]
pub note: Option<String>,
/// When the entry expires, ISO 8601.
#[serde(default)]
pub expires_at: Option<String>,
/// How many payments the entry refused.
pub block_count: i64,
/// ISO 8601 creation timestamp.
pub created_at: String,
/// The blocked Stripe card fingerprint.
#[serde(default)]
pub card_fingerprint: Option<String>,
/// How the blocked card is shown, for example its brand and last four.
#[serde(default)]
pub card_display: Option<String>,
/// The blocked card BIN.
#[serde(default)]
pub card_bin: Option<String>,
/// The processor the card fingerprint came from.
#[serde(default)]
pub card_source: Option<BuyerBlocklistCardSource>,
/// Where the entry stands with Stripe Radar.
pub radar: BuyerBlocklistRadarState,
/// The blocked IP range, in CIDR notation.
#[serde(default)]
pub ip_range: Option<String>,
/// The blocked class of network: `datacenter`, `proxy_vpn` or `tor`.
#[serde(default)]
pub ip_class: Option<String>,
/// The blocked device traits' hash.
#[serde(default)]
pub device_traits_hash: Option<String>,
/// What a device-traits match does: `flag` or `refuse`.
#[serde(default)]
pub trait_action: Option<String>,
/// The group of entries one "all IPs" block created.
#[serde(default)]
pub group_id: Option<String>,
/// When the entry last refused a payment, ISO 8601.
#[serde(default)]
pub last_blocked_at: Option<String>,
/// The addresses an "all IPs" block took.
#[serde(default)]
pub ip_snapshot: Option<BuyerBlocklistIpSnapshot>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for BuyerBlocklistEntryResponse {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BuyerBlocklistEntryResponse")
.field("id", &self.id)
.field("email", &redact(&self.email))
.field("ip", &redact(&self.ip))
.field("customer_id", &redact(&self.customer_id))
.field("device_id", &redact(&self.device_id))
.field("kind", &self.kind)
.field("value", &"<redacted>")
.field("profile_id", &self.profile_id)
.field("note", &self.note)
.field("expires_at", &self.expires_at)
.field("block_count", &self.block_count)
.field("created_at", &self.created_at)
.field("card_fingerprint", &redact(&self.card_fingerprint))
.field("card_display", &redact(&self.card_display))
.field("card_bin", &redact(&self.card_bin))
.field("card_source", &self.card_source)
.field("radar", &self.radar)
.field("ip_range", &redact(&self.ip_range))
.field("ip_class", &self.ip_class)
.field("device_traits_hash", &redact(&self.device_traits_hash))
.field("trait_action", &self.trait_action)
.field("group_id", &self.group_id)
.field("last_blocked_at", &self.last_blocked_at)
.field("ip_snapshot", &self.ip_snapshot)
.finish_non_exhaustive()
}
}
/// One page of blocklist entries, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistListResponse {
/// The entries on this page.
#[serde(default)]
pub entries: Vec<BuyerBlocklistEntryResponse>,
/// Every entry matching the filters.
pub total_count: i64,
/// The page size applied.
pub limit: i64,
/// The offset applied.
pub offset: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One payment an entry refused or flagged.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistEventResponse {
/// Where: `payment_create`, `checkout_render` or `confirm`.
pub stage: String,
/// `refused` or `flagged`.
pub outcome: String,
/// The identifier kind that matched.
#[serde(default)]
pub matched_kind: Option<String>,
/// The payment.
pub payment_id: String,
/// ISO 8601 timestamp.
pub created_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// An entry's recorded refusals, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistEventsResponse {
/// The entry.
pub entry_id: String,
/// How many payments the entry refused in total.
pub block_count: i64,
/// When the entry last refused a payment, ISO 8601.
#[serde(default)]
pub last_blocked_at: Option<String>,
/// The events.
#[serde(default)]
pub events: Vec<BuyerBlocklistEventResponse>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Whether one class of network can be judged now, and by what.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistIpClassCapability {
/// `datacenter`, `proxy_vpn` or `tor`.
pub class: String,
/// Whether an `ip_class` entry of this class is judged now.
pub available: bool,
/// The sources that judge it.
#[serde(default)]
pub sources: Vec<String>,
/// The identity provider sources among them.
#[serde(default)]
pub provider_sources: Vec<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Which classes of network an `ip_class` entry can be judged by.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistCapabilitiesResponse {
/// One entry per class of network.
#[serde(default)]
pub ip_classes: Vec<BuyerBlocklistIpClassCapability>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// An address an "all IPs" block of a payment's buyer would take.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistIpCandidate {
/// The address.
pub ip: String,
/// Where it was seen: `this_payment`, `device`, `email` or `card`.
#[serde(default)]
pub sources: Vec<String>,
/// When it was last seen, ISO 8601.
#[serde(default)]
pub last_seen_at: Option<String>,
/// How many other buyers were seen at it.
pub other_buyers: i64,
/// Whether the block takes it unless told otherwise.
pub preselected: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for BuyerBlocklistIpCandidate {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("BuyerBlocklistIpCandidate")
.field("ip", &"<redacted>")
.field("sources", &self.sources)
.field("last_seen_at", &self.last_seen_at)
.field("other_buyers", &self.other_buyers)
.field("preselected", &self.preselected)
.finish_non_exhaustive()
}
}
/// The addresses an "all IPs" block of a payment's buyer would take.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistFromPaymentPreviewResponse {
/// The payment.
pub payment_id: String,
/// The candidates: the payment's own address first, then newest first.
#[serde(default)]
pub ips: Vec<BuyerBlocklistIpCandidate>,
/// Whether the candidates were cut at the limit.
pub truncated: bool,
/// How many candidates there were.
pub total: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A Stripe early fraud warning on a payment.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentEarlyFraudWarning {
/// Stripe's id for the warning.
#[serde(default)]
pub id: Option<String>,
/// The fraud type Stripe reported.
#[serde(default)]
pub fraud_type: Option<String>,
/// Whether the warning is actionable.
#[serde(default)]
pub actionable: Option<bool>,
/// When it was received, ISO 8601.
pub received_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A Stripe Radar review of a payment.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentFraudReview {
/// Stripe's id for the review.
#[serde(default)]
pub id: Option<String>,
/// Why the review was opened.
#[serde(default)]
pub reason: Option<String>,
/// Whether the review is open.
#[serde(default)]
pub open: Option<bool>,
/// Why it was closed.
#[serde(default)]
pub closed_reason: Option<String>,
/// When it was received, ISO 8601.
pub received_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// What of a payment's buyer can be blocked.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentBlockable {
/// The card's fingerprint.
pub card: bool,
/// The email address.
pub email: bool,
/// The IP address.
pub ip: bool,
/// The device.
pub device: bool,
/// The customer.
pub customer: bool,
/// The device's traits.
#[serde(default)]
pub device_traits: Option<bool>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A class of network a payment's address belongs to.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct BuyerBlocklistIpClassFinding {
/// `datacenter`, `proxy_vpn` or `tor`.
pub class: String,
/// The sources that said so.
#[serde(default)]
pub sources: Vec<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A summary of a payment's device traits.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentDeviceTraitsSummary {
/// The browser.
pub browser: String,
/// The operating system.
pub os: String,
/// The screen size.
#[serde(default)]
pub screen: Option<String>,
/// The time zone.
#[serde(default)]
pub time_zone: Option<String>,
/// The language.
#[serde(default)]
pub language: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The device traits a payment's checkout reported.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentDeviceTraits {
/// The traits' hash, which a `device_traits` entry blocks.
pub hash: String,
/// Whether the browser randomizes its traits.
pub randomized: bool,
/// How common the traits are, when known.
#[serde(default)]
pub commonness: Option<i64>,
/// Days of history the commonness is judged over.
pub history_days: i64,
/// A readable summary.
pub summary: PaymentDeviceTraitsSummary,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Stripe's fraud signals on a payment, and what of its buyer can be blocked.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct PaymentFraudSignalsResponse {
/// The payment.
pub payment_id: String,
/// Whether the caller's role hides processor names.
pub processor_names_hidden: bool,
/// Radar's risk level of the charge.
#[serde(default)]
pub risk_level: Option<String>,
/// Radar's risk score of the charge, 0 to 99.
#[serde(default)]
pub risk_score: Option<i64>,
/// Early fraud warnings on the payment.
#[serde(default)]
pub early_fraud_warnings: Vec<PaymentEarlyFraudWarning>,
/// Radar reviews of the payment.
#[serde(default)]
pub reviews: Vec<PaymentFraudReview>,
/// What of the buyer can be blocked.
pub blockable: PaymentBlockable,
/// The entries that already block an identifier of the payment.
#[serde(default)]
pub blocked_by: Vec<String>,
/// The classes of network the payment's address belongs to.
#[serde(default)]
pub ip_classes: Vec<BuyerBlocklistIpClassFinding>,
/// The device traits the payment's checkout reported.
#[serde(default)]
pub device_traits: Option<PaymentDeviceTraits>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A Radar value list a Stripe connection syncs to.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarValueListInfo {
/// `card_fingerprint`, `email`, `ip` or `card_bin`.
pub identifier: String,
/// Stripe's item type for the list.
pub item_type: String,
/// `live` or `sandbox`.
pub environment: String,
/// The list's alias.
pub value_list_alias: String,
/// Stripe's id for the list, once created.
#[serde(default)]
pub value_list_id: Option<String>,
/// Whether the list blocks nothing until its rule is added in Stripe.
pub rule_needed: bool,
/// The rule to add in Stripe.
pub rule_text: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// How many items of a connection are in each sync state.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarItemCounts {
/// Synced.
pub synced: i64,
/// Waiting to sync.
pub pending: i64,
/// Failed to sync.
pub failed: i64,
/// Being removed.
pub removing: i64,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One Stripe connection's Radar sync settings.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarSyncSettingsResponse {
/// The Stripe connector account.
pub merchant_connector_id: String,
/// The connection's label.
#[serde(default)]
pub connector_label: Option<String>,
/// The connection's shop.
pub profile_id: String,
/// The environments the connection has credentials for.
#[serde(default)]
pub environments: Vec<String>,
/// Whether the blocklist is shared with the connection's Radar lists.
pub enabled: bool,
/// What an early fraud warning does: `notify`, `notify_and_block` or
/// `none`.
pub efw_action: String,
/// What a Radar review does: `notify` or `none`.
pub review_action: String,
/// The connection's value lists.
#[serde(default)]
pub lists: Vec<RadarValueListInfo>,
/// How many items are in each sync state.
pub counts: RadarItemCounts,
/// ISO 8601 last-update timestamp.
#[serde(default)]
pub updated_at: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The Radar sync settings of every Stripe connection the caller sees.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct RadarSyncSettingsListResponse {
/// One entry per connection.
#[serde(default)]
pub connections: Vec<RadarSyncSettingsResponse>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}