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
// ====================================== // This file was automatically generated. // ====================================== use crate::config::{Client, Response}; use crate::ids::PayoutId; use crate::params::{Expand, Expandable, List, Metadata, Object, RangeQuery, Timestamp}; use crate::resources::{BalanceTransaction, BankAccount, Card, Currency}; use serde_derive::{Deserialize, Serialize}; /// The resource representing a Stripe "Payout". /// /// For more details see [https://stripe.com/docs/api/payouts/object](https://stripe.com/docs/api/payouts/object). #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Payout { /// Unique identifier for the object. pub id: PayoutId, /// Amount (in %s) to be transferred to your bank account or debit card. pub amount: i64, /// Date the payout is expected to arrive in the bank. /// /// This factors in delays like weekends or bank holidays. pub arrival_date: Timestamp, /// Returns `true` if the payout was created by an [automated payout schedule](https://stripe.com/docs/payouts#payout-schedule), and `false` if it was [requested manually](https://stripe.com/docs/payouts#manual-payouts). pub automatic: bool, /// ID of the balance transaction that describes the impact of this payout on your account balance. #[serde(skip_serializing_if = "Option::is_none")] pub balance_transaction: Option<Expandable<BalanceTransaction>>, /// Time at which the object was created. /// /// Measured in seconds since the Unix epoch. pub created: Timestamp, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: Currency, /// An arbitrary string attached to the object. /// /// Often useful for displaying to users. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<String>, /// ID of the bank account or card the payout was sent to. #[serde(skip_serializing_if = "Option::is_none")] pub destination: Option<Expandable<PayoutDestination>>, /// If the payout failed or was canceled, this will be the ID of the balance transaction that reversed the initial balance transaction, and puts the funds from the failed payout back in your balance. #[serde(skip_serializing_if = "Option::is_none")] pub failure_balance_transaction: Option<Expandable<BalanceTransaction>>, /// Error code explaining reason for payout failure if available. /// /// See [Types of payout failures](https://stripe.com/docs/api#payout_failures) for a list of failure codes. #[serde(skip_serializing_if = "Option::is_none")] pub failure_code: Option<String>, /// Message to user further explaining reason for payout failure if available. #[serde(skip_serializing_if = "Option::is_none")] pub failure_message: Option<String>, /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode. pub livemode: bool, /// Set of key-value pairs that you can attach to an object. /// /// This can be useful for storing additional information about the object in a structured format. pub metadata: Metadata, /// The method used to send this payout, which can be `standard` or `instant`. /// /// `instant` is only supported for payouts to debit cards. /// (See [Instant payouts for marketplaces](/blog/instant-payouts-for-marketplaces) for more information.). pub method: String, /// The source balance this payout came from. /// /// One of `card` or `bank_account`. pub source_type: String, /// Extra information about a payout to be displayed on the user's bank statement. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<String>, /// Current status of the payout (`paid`, `pending`, `in_transit`, `canceled` or `failed`). /// /// A payout will be `pending` until it is submitted to the bank, at which point it becomes `in_transit`. /// It will then change to `paid` if the transaction goes through. /// If it does not go through successfully, its status will change to `failed` or `canceled`. pub status: String, /// Can be `bank_account` or `card`. #[serde(rename = "type")] pub type_: PayoutType, } impl Payout { /// Returns a list of existing payouts sent to third-party bank accounts or that Stripe has sent you. /// /// The payouts are returned in sorted order, with the most recently created payouts appearing first. pub fn list(client: &Client, params: ListPayouts<'_>) -> Response<List<Payout>> { client.get_query("/payouts", ¶ms) } /// To send funds to your own bank account, you create a new payout object. /// /// Your [Stripe balance](https://stripe.com/docs/api#balance) must be able to cover the payout amount, or you’ll receive an “Insufficient Funds” error. If your API key is in test mode, money won’t actually be sent, though everything else will occur as if in live mode. If you are creating a manual payout on a Stripe account that uses multiple payment source types, you’ll need to specify the source type balance that the payout should draw from. /// The [balance object](https://stripe.com/docs/api#balance_object) details available and pending amounts by source type. pub fn create(client: &Client, params: CreatePayout<'_>) -> Response<Payout> { client.post_form("/payouts", ¶ms) } /// Retrieves the details of an existing payout. /// /// Supply the unique payout ID from either a payout creation request or the payout list, and Stripe will return the corresponding payout information. pub fn retrieve(client: &Client, id: &PayoutId, expand: &[&str]) -> Response<Payout> { client.get_query(&format!("/payouts/{}", id), &Expand { expand }) } /// Updates the specified payout by setting the values of the parameters passed. /// /// Any parameters not provided will be left unchanged. /// This request accepts only the metadata as arguments. pub fn update(client: &Client, id: &PayoutId, params: UpdatePayout<'_>) -> Response<Payout> { client.post_form(&format!("/payouts/{}", id), ¶ms) } } impl Object for Payout { type Id = PayoutId; fn id(&self) -> Self::Id { self.id.clone() } fn object(&self) -> &'static str { "payout" } } /// The parameters for `Payout::create`. #[derive(Clone, Debug, Serialize)] pub struct CreatePayout<'a> { /// A positive integer in cents representing how much to payout. pub amount: i64, /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase. /// /// Must be a [supported currency](https://stripe.com/docs/currencies). pub currency: Currency, /// An arbitrary string attached to the object. /// /// Often useful for displaying to users. #[serde(skip_serializing_if = "Option::is_none")] pub description: Option<&'a str>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Expand::is_empty")] pub expand: &'a [&'a str], /// A set of key-value pairs that you can attach to a payout object. /// /// It can be useful for storing additional information about the payout in a structured format. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<Metadata>, /// The method used to send this payout, which can be `standard` or `instant`. /// /// `instant` is only supported for payouts to debit cards. /// (See [Instant payouts for marketplaces for more information](https://stripe.com/blog/instant-payouts-for-marketplaces).). #[serde(skip_serializing_if = "Option::is_none")] pub method: Option<PayoutMethod>, /// The source balance to draw this payout from. /// /// Balances for different payment sources are kept separately. /// You can find the amounts with the balances API. /// One of `bank_account` or `card`. #[serde(skip_serializing_if = "Option::is_none")] pub source_type: Option<PayoutSourceType>, /// A string to be displayed on the recipient's bank or card statement. /// /// This may be at most 22 characters. /// Attempting to use a `statement_descriptor` longer than 22 characters will return an error. /// Note: Most banks will truncate this information and/or display it inconsistently. /// Some may not display it at all. #[serde(skip_serializing_if = "Option::is_none")] pub statement_descriptor: Option<&'a str>, } impl<'a> CreatePayout<'a> { pub fn new(amount: i64, currency: Currency) -> Self { CreatePayout { amount, currency, description: Default::default(), expand: Default::default(), metadata: Default::default(), method: Default::default(), source_type: Default::default(), statement_descriptor: Default::default(), } } } /// The parameters for `Payout::list`. #[derive(Clone, Debug, Serialize, Default)] pub struct ListPayouts<'a> { #[serde(skip_serializing_if = "Option::is_none")] pub arrival_date: Option<RangeQuery<Timestamp>>, #[serde(skip_serializing_if = "Option::is_none")] pub created: Option<RangeQuery<Timestamp>>, /// A cursor for use in pagination. /// /// `ending_before` is an object ID that defines your place in the list. /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list. #[serde(skip_serializing_if = "Option::is_none")] pub ending_before: Option<PayoutId>, /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Expand::is_empty")] pub expand: &'a [&'a str], /// A limit on the number of objects to be returned. /// /// Limit can range between 1 and 100, and the default is 10. #[serde(skip_serializing_if = "Option::is_none")] pub limit: Option<u64>, /// A cursor for use in pagination. /// /// `starting_after` is an object ID that defines your place in the list. /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list. #[serde(skip_serializing_if = "Option::is_none")] pub starting_after: Option<PayoutId>, /// Only return payouts that have the given status: `pending`, `paid`, `failed`, or `canceled`. #[serde(skip_serializing_if = "Option::is_none")] pub status: Option<&'a str>, } impl<'a> ListPayouts<'a> { pub fn new() -> Self { ListPayouts { arrival_date: Default::default(), created: Default::default(), ending_before: Default::default(), expand: Default::default(), limit: Default::default(), starting_after: Default::default(), status: Default::default(), } } } /// The parameters for `Payout::update`. #[derive(Clone, Debug, Serialize, Default)] pub struct UpdatePayout<'a> { /// Specifies which fields in the response should be expanded. #[serde(skip_serializing_if = "Expand::is_empty")] pub expand: &'a [&'a str], /// A set of key-value pairs that you can attach to a payout object. /// /// It can be useful for storing additional information about the payout in a structured format. #[serde(skip_serializing_if = "Option::is_none")] pub metadata: Option<Metadata>, } impl<'a> UpdatePayout<'a> { pub fn new() -> Self { UpdatePayout { expand: Default::default(), metadata: Default::default() } } } #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "object", rename_all = "snake_case")] pub enum PayoutDestination { BankAccount(BankAccount), Card(Card), } /// An enum representing the possible values of an `CreatePayout`'s `method` field. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] pub enum PayoutMethod { Instant, Standard, } impl PayoutMethod { pub fn as_str(self) -> &'static str { match self { PayoutMethod::Instant => "instant", PayoutMethod::Standard => "standard", } } } impl AsRef<str> for PayoutMethod { fn as_ref(&self) -> &str { self.as_str() } } impl std::fmt::Display for PayoutMethod { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { self.as_str().fmt(f) } } /// An enum representing the possible values of an `CreatePayout`'s `source_type` field. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] pub enum PayoutSourceType { BankAccount, Card, } impl PayoutSourceType { pub fn as_str(self) -> &'static str { match self { PayoutSourceType::BankAccount => "bank_account", PayoutSourceType::Card => "card", } } } impl AsRef<str> for PayoutSourceType { fn as_ref(&self) -> &str { self.as_str() } } impl std::fmt::Display for PayoutSourceType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { self.as_str().fmt(f) } } /// An enum representing the possible values of an `Payout`'s `type` field. #[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)] #[serde(rename_all = "snake_case")] pub enum PayoutType { BankAccount, Card, } impl PayoutType { pub fn as_str(self) -> &'static str { match self { PayoutType::BankAccount => "bank_account", PayoutType::Card => "card", } } } impl AsRef<str> for PayoutType { fn as_ref(&self) -> &str { self.as_str() } } impl std::fmt::Display for PayoutType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { self.as_str().fmt(f) } }