stripe/resources/generated/
issuing_authorization.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::IssuingAuthorizationId;
6use crate::params::{Expandable, Metadata, Object, Timestamp};
7use crate::resources::{
8    BalanceTransaction, Currency, IssuingAuthorizationAmountDetails, IssuingAuthorizationCheck,
9    IssuingAuthorizationMethod, IssuingAuthorizationReason, IssuingCard, IssuingCardholder,
10    IssuingToken, IssuingTransaction, MerchantData,
11};
12use serde::{Deserialize, Serialize};
13
14/// The resource representing a Stripe "IssuingAuthorization".
15///
16/// For more details see <https://stripe.com/docs/api/issuing/authorizations/object>
17#[derive(Clone, Debug, Default, Deserialize, Serialize)]
18pub struct IssuingAuthorization {
19    /// Unique identifier for the object.
20    pub id: IssuingAuthorizationId,
21
22    /// The total amount that was authorized or rejected.
23    ///
24    /// This amount is in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
25    /// `amount` should be the same as `merchant_amount`, unless `currency` and `merchant_currency` are different.
26    pub amount: i64,
27
28    /// Detailed breakdown of amount components.
29    ///
30    /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
31    pub amount_details: Option<IssuingAuthorizationAmountDetails>,
32
33    /// Whether the authorization has been approved.
34    pub approved: bool,
35
36    /// How the card details were provided.
37    pub authorization_method: IssuingAuthorizationMethod,
38
39    /// List of balance transactions associated with this authorization.
40    pub balance_transactions: Vec<BalanceTransaction>,
41
42    pub card: IssuingCard,
43
44    /// The cardholder to whom this authorization belongs.
45    pub cardholder: Option<Expandable<IssuingCardholder>>,
46
47    /// Time at which the object was created.
48    ///
49    /// Measured in seconds since the Unix epoch.
50    pub created: Timestamp,
51
52    /// The currency of the cardholder.
53    ///
54    /// This currency can be different from the currency presented at authorization and the `merchant_currency` field on this authorization.
55    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
56    /// Must be a [supported currency](https://stripe.com/docs/currencies).
57    pub currency: Currency,
58
59    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
60    pub livemode: bool,
61
62    /// The total amount that was authorized or rejected.
63    ///
64    /// This amount is in the `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
65    /// `merchant_amount` should be the same as `amount`, unless `merchant_currency` and `currency` are different.
66    pub merchant_amount: i64,
67
68    /// The local currency that was presented to the cardholder for the authorization.
69    ///
70    /// This currency can be different from the cardholder currency and the `currency` field on this authorization.
71    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
72    /// Must be a [supported currency](https://stripe.com/docs/currencies).
73    pub merchant_currency: Currency,
74
75    pub merchant_data: MerchantData,
76
77    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
78    ///
79    /// This can be useful for storing additional information about the object in a structured format.
80    pub metadata: Metadata,
81
82    /// Details about the authorization, such as identifiers, set by the card network.
83    pub network_data: Option<IssuingAuthorizationNetworkData>,
84
85    /// The pending authorization request.
86    ///
87    /// This field will only be non-null during an `issuing_authorization.request` webhook.
88    pub pending_request: Option<IssuingAuthorizationPendingRequest>,
89
90    /// History of every time a `pending_request` authorization was approved/declined, either by you directly or by Stripe (e.g.
91    ///
92    /// based on your spending_controls).
93    /// If the merchant changes the authorization by performing an incremental authorization, you can look at this field to see the previous requests for the authorization.
94    /// This field can be helpful in determining why a given authorization was approved/declined.
95    pub request_history: Vec<IssuingAuthorizationRequest>,
96
97    /// The current status of the authorization in its lifecycle.
98    pub status: IssuingAuthorizationStatus,
99
100    /// [Token](https://stripe.com/docs/api/issuing/tokens/object) object used for this authorization.
101    ///
102    /// If a network token was not used for this authorization, this field will be null.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub token: Option<Expandable<IssuingToken>>,
105
106    /// List of [transactions](https://stripe.com/docs/api/issuing/transactions) associated with this authorization.
107    pub transactions: Vec<IssuingTransaction>,
108
109    /// [Treasury](https://stripe.com/docs/api/treasury) details related to this authorization if it was created on a [FinancialAccount](https://stripe.com/docs/api/treasury/financial_accounts).
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub treasury: Option<IssuingAuthorizationTreasury>,
112
113    pub verification_data: IssuingAuthorizationVerificationData,
114
115    /// The digital wallet used for this transaction.
116    ///
117    /// One of `apple_pay`, `google_pay`, or `samsung_pay`.
118    /// Will populate as `null` when no digital wallet was utilized.
119    pub wallet: Option<String>,
120}
121
122impl Object for IssuingAuthorization {
123    type Id = IssuingAuthorizationId;
124    fn id(&self) -> Self::Id {
125        self.id.clone()
126    }
127    fn object(&self) -> &'static str {
128        "issuing.authorization"
129    }
130}
131
132#[derive(Clone, Debug, Default, Deserialize, Serialize)]
133pub struct IssuingAuthorizationNetworkData {
134    /// Identifier assigned to the acquirer by the card network.
135    ///
136    /// Sometimes this value is not provided by the network; in this case, the value will be `null`.
137    pub acquiring_institution_id: Option<String>,
138
139    /// The System Trace Audit Number (STAN) is a 6-digit identifier assigned by the acquirer.
140    ///
141    /// Prefer `network_data.transaction_id` if present, unless you have special requirements.
142    pub system_trace_audit_number: Option<String>,
143
144    /// Unique identifier for the authorization assigned by the card network used to match subsequent messages, disputes, and transactions.
145    pub transaction_id: Option<String>,
146}
147
148#[derive(Clone, Debug, Default, Deserialize, Serialize)]
149pub struct IssuingAuthorizationPendingRequest {
150    /// The additional amount Stripe will hold if the authorization is approved, in the card's [currency](https://stripe.com/docs/api#issuing_authorization_object-pending-request-currency) and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
151    pub amount: i64,
152
153    /// Detailed breakdown of amount components.
154    ///
155    /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
156    pub amount_details: Option<IssuingAuthorizationAmountDetails>,
157
158    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
159    ///
160    /// Must be a [supported currency](https://stripe.com/docs/currencies).
161    pub currency: Currency,
162
163    /// If set `true`, you may provide [amount](https://stripe.com/docs/api/issuing/authorizations/approve#approve_issuing_authorization-amount) to control how much to hold for the authorization.
164    pub is_amount_controllable: bool,
165
166    /// The amount the merchant is requesting to be authorized in the `merchant_currency`.
167    ///
168    /// The amount is in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
169    pub merchant_amount: i64,
170
171    /// The local currency the merchant is requesting to authorize.
172    pub merchant_currency: Currency,
173
174    /// The card network's estimate of the likelihood that an authorization is fraudulent.
175    ///
176    /// Takes on values between 1 and 99.
177    pub network_risk_score: Option<i64>,
178}
179
180#[derive(Clone, Debug, Default, Deserialize, Serialize)]
181pub struct IssuingAuthorizationRequest {
182    /// The `pending_request.amount` at the time of the request, presented in your card's currency and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
183    ///
184    /// Stripe held this amount from your account to fund the authorization if the request was approved.
185    pub amount: i64,
186
187    /// Detailed breakdown of amount components.
188    ///
189    /// These amounts are denominated in `currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
190    pub amount_details: Option<IssuingAuthorizationAmountDetails>,
191
192    /// Whether this request was approved.
193    pub approved: bool,
194
195    /// A code created by Stripe which is shared with the merchant to validate the authorization.
196    ///
197    /// This field will be populated if the authorization message was approved.
198    /// The code typically starts with the letter "S", followed by a six-digit number.
199    /// For example, "S498162".
200    /// Please note that the code is not guaranteed to be unique across authorizations.
201    pub authorization_code: Option<String>,
202
203    /// Time at which the object was created.
204    ///
205    /// Measured in seconds since the Unix epoch.
206    pub created: Timestamp,
207
208    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
209    ///
210    /// Must be a [supported currency](https://stripe.com/docs/currencies).
211    pub currency: Currency,
212
213    /// The `pending_request.merchant_amount` at the time of the request, presented in the `merchant_currency` and in the [smallest currency unit](https://stripe.com/docs/currencies#zero-decimal).
214    pub merchant_amount: i64,
215
216    /// The currency that was collected by the merchant and presented to the cardholder for the authorization.
217    ///
218    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
219    /// Must be a [supported currency](https://stripe.com/docs/currencies).
220    pub merchant_currency: Currency,
221
222    /// The card network's estimate of the likelihood that an authorization is fraudulent.
223    ///
224    /// Takes on values between 1 and 99.
225    pub network_risk_score: Option<i64>,
226
227    /// When an authorization is approved or declined by you or by Stripe, this field provides additional detail on the reason for the outcome.
228    pub reason: IssuingAuthorizationReason,
229
230    /// If the `request_history.reason` is `webhook_error` because the direct webhook response is invalid (for example, parsing errors or missing parameters), we surface a more detailed error message via this field.
231    pub reason_message: Option<String>,
232
233    /// Time when the card network received an authorization request from the acquirer in UTC.
234    ///
235    /// Referred to by networks as transmission time.
236    pub requested_at: Option<Timestamp>,
237}
238
239#[derive(Clone, Debug, Default, Deserialize, Serialize)]
240pub struct IssuingAuthorizationTreasury {
241    /// The array of [ReceivedCredits](https://stripe.com/docs/api/treasury/received_credits) associated with this authorization.
242    pub received_credits: Vec<String>,
243
244    /// The array of [ReceivedDebits](https://stripe.com/docs/api/treasury/received_debits) associated with this authorization.
245    pub received_debits: Vec<String>,
246
247    /// The Treasury [Transaction](https://stripe.com/docs/api/treasury/transactions) associated with this authorization.
248    pub transaction: Option<String>,
249}
250
251#[derive(Clone, Debug, Default, Deserialize, Serialize)]
252pub struct IssuingAuthorizationVerificationData {
253    /// Whether the cardholder provided an address first line and if it matched the cardholder’s `billing.address.line1`.
254    pub address_line1_check: IssuingAuthorizationCheck,
255
256    /// Whether the cardholder provided a postal code and if it matched the cardholder’s `billing.address.postal_code`.
257    pub address_postal_code_check: IssuingAuthorizationCheck,
258
259    /// The exemption applied to this authorization.
260    pub authentication_exemption: Option<IssuingAuthorizationAuthenticationExemption>,
261
262    /// Whether the cardholder provided a CVC and if it matched Stripe’s record.
263    pub cvc_check: IssuingAuthorizationCheck,
264
265    /// Whether the cardholder provided an expiry date and if it matched Stripe’s record.
266    pub expiry_check: IssuingAuthorizationCheck,
267
268    /// The postal code submitted as part of the authorization used for postal code verification.
269    pub postal_code: Option<String>,
270
271    /// 3D Secure details.
272    pub three_d_secure: Option<IssuingAuthorizationThreeDSecure>,
273}
274
275#[derive(Clone, Debug, Default, Deserialize, Serialize)]
276pub struct IssuingAuthorizationAuthenticationExemption {
277    /// The entity that requested the exemption, either the acquiring merchant or the Issuing user.
278    pub claimed_by: IssuingAuthorizationAuthenticationExemptionClaimedBy,
279
280    /// The specific exemption claimed for this authorization.
281    #[serde(rename = "type")]
282    pub type_: IssuingAuthorizationAuthenticationExemptionType,
283}
284
285#[derive(Clone, Debug, Default, Deserialize, Serialize)]
286pub struct IssuingAuthorizationThreeDSecure {
287    /// The outcome of the 3D Secure authentication request.
288    pub result: IssuingAuthorizationThreeDSecureResult,
289}
290
291/// An enum representing the possible values of an `IssuingAuthorizationAuthenticationExemption`'s `claimed_by` field.
292#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
293#[serde(rename_all = "snake_case")]
294pub enum IssuingAuthorizationAuthenticationExemptionClaimedBy {
295    Acquirer,
296    Issuer,
297}
298
299impl IssuingAuthorizationAuthenticationExemptionClaimedBy {
300    pub fn as_str(self) -> &'static str {
301        match self {
302            IssuingAuthorizationAuthenticationExemptionClaimedBy::Acquirer => "acquirer",
303            IssuingAuthorizationAuthenticationExemptionClaimedBy::Issuer => "issuer",
304        }
305    }
306}
307
308impl AsRef<str> for IssuingAuthorizationAuthenticationExemptionClaimedBy {
309    fn as_ref(&self) -> &str {
310        self.as_str()
311    }
312}
313
314impl std::fmt::Display for IssuingAuthorizationAuthenticationExemptionClaimedBy {
315    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
316        self.as_str().fmt(f)
317    }
318}
319impl std::default::Default for IssuingAuthorizationAuthenticationExemptionClaimedBy {
320    fn default() -> Self {
321        Self::Acquirer
322    }
323}
324
325/// An enum representing the possible values of an `IssuingAuthorizationAuthenticationExemption`'s `type` field.
326#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
327#[serde(rename_all = "snake_case")]
328pub enum IssuingAuthorizationAuthenticationExemptionType {
329    LowValueTransaction,
330    TransactionRiskAnalysis,
331    Unknown,
332}
333
334impl IssuingAuthorizationAuthenticationExemptionType {
335    pub fn as_str(self) -> &'static str {
336        match self {
337            IssuingAuthorizationAuthenticationExemptionType::LowValueTransaction => {
338                "low_value_transaction"
339            }
340            IssuingAuthorizationAuthenticationExemptionType::TransactionRiskAnalysis => {
341                "transaction_risk_analysis"
342            }
343            IssuingAuthorizationAuthenticationExemptionType::Unknown => "unknown",
344        }
345    }
346}
347
348impl AsRef<str> for IssuingAuthorizationAuthenticationExemptionType {
349    fn as_ref(&self) -> &str {
350        self.as_str()
351    }
352}
353
354impl std::fmt::Display for IssuingAuthorizationAuthenticationExemptionType {
355    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
356        self.as_str().fmt(f)
357    }
358}
359impl std::default::Default for IssuingAuthorizationAuthenticationExemptionType {
360    fn default() -> Self {
361        Self::LowValueTransaction
362    }
363}
364
365/// An enum representing the possible values of an `IssuingAuthorization`'s `status` field.
366#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
367#[serde(rename_all = "snake_case")]
368pub enum IssuingAuthorizationStatus {
369    Closed,
370    Pending,
371    Reversed,
372}
373
374impl IssuingAuthorizationStatus {
375    pub fn as_str(self) -> &'static str {
376        match self {
377            IssuingAuthorizationStatus::Closed => "closed",
378            IssuingAuthorizationStatus::Pending => "pending",
379            IssuingAuthorizationStatus::Reversed => "reversed",
380        }
381    }
382}
383
384impl AsRef<str> for IssuingAuthorizationStatus {
385    fn as_ref(&self) -> &str {
386        self.as_str()
387    }
388}
389
390impl std::fmt::Display for IssuingAuthorizationStatus {
391    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
392        self.as_str().fmt(f)
393    }
394}
395impl std::default::Default for IssuingAuthorizationStatus {
396    fn default() -> Self {
397        Self::Closed
398    }
399}
400
401/// An enum representing the possible values of an `IssuingAuthorizationThreeDSecure`'s `result` field.
402#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
403#[serde(rename_all = "snake_case")]
404pub enum IssuingAuthorizationThreeDSecureResult {
405    AttemptAcknowledged,
406    Authenticated,
407    Failed,
408    Required,
409}
410
411impl IssuingAuthorizationThreeDSecureResult {
412    pub fn as_str(self) -> &'static str {
413        match self {
414            IssuingAuthorizationThreeDSecureResult::AttemptAcknowledged => "attempt_acknowledged",
415            IssuingAuthorizationThreeDSecureResult::Authenticated => "authenticated",
416            IssuingAuthorizationThreeDSecureResult::Failed => "failed",
417            IssuingAuthorizationThreeDSecureResult::Required => "required",
418        }
419    }
420}
421
422impl AsRef<str> for IssuingAuthorizationThreeDSecureResult {
423    fn as_ref(&self) -> &str {
424        self.as_str()
425    }
426}
427
428impl std::fmt::Display for IssuingAuthorizationThreeDSecureResult {
429    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
430        self.as_str().fmt(f)
431    }
432}
433impl std::default::Default for IssuingAuthorizationThreeDSecureResult {
434    fn default() -> Self {
435        Self::AttemptAcknowledged
436    }
437}