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
//! Sell-to restrictions: the buyer countries a merchant refuses to sell to,
//! merchant-wide, per project, per shop and per connector account.
use serde::Deserialize;
use serde_json::Value;
/// A sell-to policy.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionPolicy {
/// Buyer countries refused, as ISO 3166-1 alpha-2 codes.
#[serde(default)]
pub blocked_countries: Vec<String>,
/// Whether a payment whose buyer IP country cannot be resolved is refused.
#[serde(default)]
pub block_unknown_ip_country: bool,
/// ISO 8601 last-modification timestamp.
pub modified_at: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One shop's effective policy and where it comes from.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ShopSellToRestriction {
/// The shop (business profile).
pub profile_id: String,
/// The shop's name.
pub profile_name: String,
/// `merchant`, `shop`, `project`, `connector` or `none`.
pub source: String,
/// The policy that applies to the shop.
#[serde(default)]
pub effective_policy: Option<SellToRestrictionPolicy>,
/// The project the policy comes from, for a `project` source.
#[serde(default)]
pub source_project_id: Option<String>,
/// That project's name.
#[serde(default)]
pub source_project_name: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One project's own policy.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ProjectSellToRestriction {
/// The project.
pub project_id: String,
/// The project's name.
pub project_name: String,
/// The parent project.
#[serde(default)]
pub parent_project_id: Option<String>,
/// Whether the project is active.
pub is_active: bool,
/// The project's own policy, or `None` when it has none.
#[serde(default)]
pub policy: Option<SellToRestrictionPolicy>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Which buyer signals a connector account's payments can be judged on.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorSellToEnforcement {
/// The buyer's IP country.
pub ip_country: bool,
/// The card's issuing country.
pub card_issuing_country: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One connector account's own policy.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct ConnectorSellToRestriction {
/// The connector account.
pub merchant_connector_id: String,
/// The connector.
pub connector_name: String,
/// The account's label.
#[serde(default)]
pub connector_label: Option<String>,
/// The account's own policy, or `None` when it has none.
#[serde(default)]
pub policy: Option<SellToRestrictionPolicy>,
/// Which buyer signals its payments can be judged on.
pub enforces: ConnectorSellToEnforcement,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The merchant-wide policy and every shop's effective policy.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionsResponse {
/// The merchant-wide policy. `None` for a caller scoped to one shop.
#[serde(default)]
pub merchant_policy: Option<SellToRestrictionPolicy>,
/// Every shop the caller sees.
#[serde(default)]
pub shops: Vec<ShopSellToRestriction>,
/// Every project with its own policy.
#[serde(default)]
pub projects: Vec<ProjectSellToRestriction>,
/// Every connector account with its own policy.
#[serde(default)]
pub connectors: Vec<ConnectorSellToRestriction>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// How this deployment resolves a buyer's IP country.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct IpCountryResolution {
/// From a country header set at the edge.
pub edge_country_header: bool,
/// From a GeoIP database.
pub geoip_database: bool,
/// From a country the hosted checkout forwards, signed.
pub signed_checkout_forwarding: bool,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Which checks one payment path performs.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionRailCapability {
/// The payment path, for example `api_payments` or `stripe_hosted_card`.
pub rail: String,
/// `checkout_and_confirm`, `checkout_only` or `merchant_stated_ip`.
pub ip_country: String,
/// `before_authorization`, `not_enforced` or `not_applicable`.
pub card_issuing_country: String,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Which checks each payment path performs, and how a buyer's country is
/// resolved.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionCapabilitiesResponse {
/// How the buyer's IP country is resolved.
pub ip_country_resolution: IpCountryResolution,
/// One entry per payment path.
#[serde(default)]
pub rails: Vec<SellToRestrictionRailCapability>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One refusal of a payment by a sell-to policy.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionDecisionResponse {
/// Where: `checkout_render` or `confirm`.
pub stage: String,
/// The signal that refused: `ip_country`, `ip_country_unknown`,
/// `ip_country_unverified` or `card_issuing_country`.
pub signal: String,
/// The country refused, as an ISO 3166-1 alpha-2 code.
#[serde(default)]
pub country: Option<String>,
/// The policy that refused: `merchant`, `shop`, `project` or `connector`.
pub policy_source: String,
/// The payment attempt.
#[serde(default)]
pub attempt_id: Option<String>,
/// The connector.
#[serde(default)]
pub connector: Option<String>,
/// ISO 8601 timestamp.
pub created_at: String,
/// The id of the project or connector account whose policy refused.
#[serde(default)]
pub policy_ref: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// Why a payment was refused by sell-to policies.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct SellToRestrictionDecisionsResponse {
/// The payment.
pub payment_id: String,
/// Every refusal.
#[serde(default)]
pub decisions: Vec<SellToRestrictionDecisionResponse>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}