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
//! Whop Resolution Center cases: a buyer's claim before any chargeback, read
//! live from Whop through one connector account.
//!
//! The buyer's name, username and email are personal data: `Debug` on
//! [`WhopResolutionCase`] prints `<redacted>` in their place.
use std::fmt;
use serde::Deserialize;
use serde_json::Value;
/// A Whop resolution case as Whop reports it now.
#[derive(Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCase {
/// Whop's case id.
pub case_id: String,
/// The Whop connector account the case was read through.
pub merchant_connector_id: String,
/// Whether the case was read through the sandbox credentials.
pub test_mode: bool,
/// The shop of the case's payment, when matched.
#[serde(default)]
pub profile_id: Option<String>,
/// The DeloPay payment, when matched.
#[serde(default)]
pub payment_id: Option<String>,
/// The DeloPay payment attempt, when matched.
#[serde(default)]
pub attempt_id: Option<String>,
/// Whop's payment id.
pub connector_payment_id: String,
/// For example `awaiting_merchant`, `awaiting_customer`, `under_review` or
/// `closed`.
pub status: String,
/// The buyer's reason.
#[serde(default)]
pub reason: Option<String>,
/// How the case ended, once closed.
#[serde(default)]
pub outcome: Option<String>,
/// The refund Whop made, if any.
#[serde(default)]
pub refund: Option<String>,
/// Whether the case was escalated.
#[serde(default)]
pub escalated: bool,
/// Whether the buyer appealed.
#[serde(default)]
pub customer_appealed: bool,
/// The amount, as a decimal string.
#[serde(default)]
pub amount: Option<String>,
/// Three-letter ISO 4217 currency code.
#[serde(default)]
pub currency: Option<String>,
/// When the merchant must answer by, ISO 8601.
#[serde(default)]
pub response_due_at: Option<String>,
/// ISO 8601 creation timestamp.
#[serde(default)]
pub created_at: Option<String>,
/// ISO 8601 last-update timestamp.
#[serde(default)]
pub updated_at: Option<String>,
/// Whop's product id.
#[serde(default)]
pub product_id: Option<String>,
/// Whop's plan id.
#[serde(default)]
pub plan_id: Option<String>,
/// The payment method type.
#[serde(default)]
pub payment_method_type: Option<String>,
/// The card brand, for a card payment.
#[serde(default)]
pub card_brand: Option<String>,
/// The card's last four digits, for a card payment.
#[serde(default)]
pub card_last4: Option<String>,
/// The buyer's name.
#[serde(default)]
pub buyer_name: Option<String>,
/// The buyer's Whop username.
#[serde(default)]
pub buyer_username: Option<String>,
/// The buyer's email address.
#[serde(default)]
pub buyer_email: Option<String>,
/// `accept`, `deny`, `reply` and `request_info`, as the case allows now.
#[serde(default)]
pub available_actions: Vec<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
impl fmt::Debug for WhopResolutionCase {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("WhopResolutionCase")
.field("case_id", &self.case_id)
.field("merchant_connector_id", &self.merchant_connector_id)
.field("test_mode", &self.test_mode)
.field("profile_id", &self.profile_id)
.field("payment_id", &self.payment_id)
.field("attempt_id", &self.attempt_id)
.field("connector_payment_id", &self.connector_payment_id)
.field("status", &self.status)
.field("reason", &self.reason)
.field("outcome", &self.outcome)
.field("refund", &self.refund)
.field("escalated", &self.escalated)
.field("customer_appealed", &self.customer_appealed)
.field("amount", &self.amount)
.field("currency", &self.currency)
.field("response_due_at", &self.response_due_at)
.field("created_at", &self.created_at)
.field("updated_at", &self.updated_at)
.field("product_id", &self.product_id)
.field("plan_id", &self.plan_id)
.field("payment_method_type", &self.payment_method_type)
.field("card_brand", &self.card_brand)
.field("card_last4", &self.card_last4)
.field(
"buyer_name",
&self.buyer_name.as_ref().map(|_| "<redacted>"),
)
.field(
"buyer_username",
&self.buyer_username.as_ref().map(|_| "<redacted>"),
)
.field(
"buyer_email",
&self.buyer_email.as_ref().map(|_| "<redacted>"),
)
.field("available_actions", &self.available_actions)
.finish_non_exhaustive()
}
}
/// One page of Whop cases, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCaseList {
/// The cases on this page.
#[serde(default)]
pub cases: Vec<WhopResolutionCase>,
/// Pass as `cursor` to read the next page; `None` on the last.
#[serde(default)]
pub next_cursor: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// A file attached to a case event.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCaseAttachment {
/// Whop's attachment id.
pub id: String,
/// The file name.
#[serde(default)]
pub filename: Option<String>,
/// The file's media type.
#[serde(default)]
pub content_type: Option<String>,
/// Where Whop serves the file.
#[serde(default)]
pub url: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One event of a case's timeline.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCaseEvent {
/// Whop's event id.
pub event_id: String,
/// What happened.
pub action: String,
/// Who reported it.
pub reporter_type: String,
/// The event's text.
#[serde(default)]
pub details: Option<String>,
/// Whether the buyer sees the event.
#[serde(default)]
pub viewable_by_customer: bool,
/// ISO 8601 timestamp.
#[serde(default)]
pub created_at: Option<String>,
/// Files attached to the event.
#[serde(default)]
pub attachments: Vec<WhopResolutionCaseAttachment>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// One page of a case's timeline, newest first.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCaseEventList {
/// The events on this page.
#[serde(default)]
pub events: Vec<WhopResolutionCaseEvent>,
/// Pass as `cursor` to read the next page; `None` on the last.
#[serde(default)]
pub next_cursor: Option<String>,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}
/// The result of an action on a case.
#[derive(Debug, Clone, Deserialize)]
#[non_exhaustive]
pub struct WhopResolutionCaseActionResponse {
/// The request id the action was sent under.
pub request_id: String,
/// The action taken.
pub action: String,
/// `submitted`, or `unknown` when Whop's answer was lost: retry with the
/// same `request_id`.
pub outcome: String,
/// The case after the action.
pub case: WhopResolutionCase,
/// Any additional response fields not modeled above.
#[serde(flatten)]
pub extra: serde_json::Map<String, Value>,
}