stripe_shared/
payment_link.rs

1/// A payment link is a shareable URL that will take your customers to a hosted payment page.
2/// A payment link can be shared and used multiple times.
3///
4/// When a customer opens a payment link it will open a new [checkout session](https://stripe.com/docs/api/checkout/sessions) to render the payment page.
5/// You can use [checkout session events](https://stripe.com/docs/api/events/types#event_types-checkout.session.completed) to track payments through payment links.
6///
7/// Related guide: [Payment Links API](https://stripe.com/docs/payment-links)
8///
9/// For more details see <<https://stripe.com/docs/api/payment_links/payment_links/object>>.
10#[derive(Clone, Debug)]
11#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
12pub struct PaymentLink {
13    /// Whether the payment link's `url` is active.
14    /// If `false`, customers visiting the URL will be shown a page saying that the link has been deactivated.
15    pub active: bool,
16    pub after_completion: stripe_shared::PaymentLinksResourceAfterCompletion,
17    /// Whether user redeemable promotion codes are enabled.
18    pub allow_promotion_codes: bool,
19    /// The ID of the Connect application that created the Payment Link.
20    pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
21    /// The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account.
22    pub application_fee_amount: Option<i64>,
23    /// This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account.
24    pub application_fee_percent: Option<f64>,
25    pub automatic_tax: stripe_shared::PaymentLinksResourceAutomaticTax,
26    /// Configuration for collecting the customer's billing address. Defaults to `auto`.
27    pub billing_address_collection: stripe_shared::PaymentLinkBillingAddressCollection,
28    /// When set, provides configuration to gather active consent from customers.
29    pub consent_collection: Option<stripe_shared::PaymentLinksResourceConsentCollection>,
30    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
31    /// Must be a [supported currency](https://stripe.com/docs/currencies).
32    pub currency: stripe_types::Currency,
33    /// Collect additional information from your customer using custom fields.
34    /// Up to 3 fields are supported.
35    pub custom_fields: Vec<stripe_shared::PaymentLinksResourceCustomFields>,
36    pub custom_text: stripe_shared::PaymentLinksResourceCustomText,
37    /// Configuration for Customer creation during checkout.
38    pub customer_creation: PaymentLinkCustomerCreation,
39    /// Unique identifier for the object.
40    pub id: stripe_shared::PaymentLinkId,
41    /// The custom message to be displayed to a customer when a payment link is no longer active.
42    pub inactive_message: Option<String>,
43    /// Configuration for creating invoice for payment mode payment links.
44    pub invoice_creation: Option<stripe_shared::PaymentLinksResourceInvoiceCreation>,
45    /// The line items representing what is being sold.
46    pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>,
47    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
48    pub livemode: bool,
49    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
50    /// This can be useful for storing additional information about the object in a structured format.
51    pub metadata: std::collections::HashMap<String, String>,
52    /// The account on behalf of which to charge.
53    /// See the [Connect documentation](https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts) for details.
54    pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
55    /// The optional items presented to the customer at checkout.
56    pub optional_items: Option<Vec<stripe_shared::PaymentLinksResourceOptionalItem>>,
57    /// Indicates the parameters to be passed to PaymentIntent creation during checkout.
58    pub payment_intent_data: Option<stripe_shared::PaymentLinksResourcePaymentIntentData>,
59    /// Configuration for collecting a payment method during checkout. Defaults to `always`.
60    pub payment_method_collection: PaymentLinkPaymentMethodCollection,
61    /// The list of payment method types that customers can use.
62    /// When `null`, Stripe will dynamically show relevant payment methods you've enabled in your [payment method settings](https://dashboard.stripe.com/settings/payment_methods).
63    pub payment_method_types: Option<Vec<stripe_shared::PaymentLinkPaymentMethodTypes>>,
64    pub phone_number_collection: stripe_shared::PaymentLinksResourcePhoneNumberCollection,
65    /// Settings that restrict the usage of a payment link.
66    pub restrictions: Option<stripe_shared::PaymentLinksResourceRestrictions>,
67    /// Configuration for collecting the customer's shipping address.
68    pub shipping_address_collection:
69        Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>,
70    /// The shipping rate options applied to the session.
71    pub shipping_options: Vec<stripe_shared::PaymentLinksResourceShippingOption>,
72    /// Indicates the type of transaction being performed which customizes relevant text on the page, such as the submit button.
73    pub submit_type: stripe_shared::PaymentLinkSubmitType,
74    /// When creating a subscription, the specified configuration data will be used.
75    /// There must be at least one line item with a recurring price to use `subscription_data`.
76    pub subscription_data: Option<stripe_shared::PaymentLinksResourceSubscriptionData>,
77    pub tax_id_collection: stripe_shared::PaymentLinksResourceTaxIdCollection,
78    /// The account (if any) the payments will be attributed to for tax reporting, and where funds from each payment will be transferred to.
79    pub transfer_data: Option<stripe_shared::PaymentLinksResourceTransferData>,
80    /// The public URL that can be shared with customers.
81    pub url: String,
82}
83#[doc(hidden)]
84pub struct PaymentLinkBuilder {
85    active: Option<bool>,
86    after_completion: Option<stripe_shared::PaymentLinksResourceAfterCompletion>,
87    allow_promotion_codes: Option<bool>,
88    application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
89    application_fee_amount: Option<Option<i64>>,
90    application_fee_percent: Option<Option<f64>>,
91    automatic_tax: Option<stripe_shared::PaymentLinksResourceAutomaticTax>,
92    billing_address_collection: Option<stripe_shared::PaymentLinkBillingAddressCollection>,
93    consent_collection: Option<Option<stripe_shared::PaymentLinksResourceConsentCollection>>,
94    currency: Option<stripe_types::Currency>,
95    custom_fields: Option<Vec<stripe_shared::PaymentLinksResourceCustomFields>>,
96    custom_text: Option<stripe_shared::PaymentLinksResourceCustomText>,
97    customer_creation: Option<PaymentLinkCustomerCreation>,
98    id: Option<stripe_shared::PaymentLinkId>,
99    inactive_message: Option<Option<String>>,
100    invoice_creation: Option<Option<stripe_shared::PaymentLinksResourceInvoiceCreation>>,
101    line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>,
102    livemode: Option<bool>,
103    metadata: Option<std::collections::HashMap<String, String>>,
104    on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
105    optional_items: Option<Option<Vec<stripe_shared::PaymentLinksResourceOptionalItem>>>,
106    payment_intent_data: Option<Option<stripe_shared::PaymentLinksResourcePaymentIntentData>>,
107    payment_method_collection: Option<PaymentLinkPaymentMethodCollection>,
108    payment_method_types: Option<Option<Vec<stripe_shared::PaymentLinkPaymentMethodTypes>>>,
109    phone_number_collection: Option<stripe_shared::PaymentLinksResourcePhoneNumberCollection>,
110    restrictions: Option<Option<stripe_shared::PaymentLinksResourceRestrictions>>,
111    shipping_address_collection:
112        Option<Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>>,
113    shipping_options: Option<Vec<stripe_shared::PaymentLinksResourceShippingOption>>,
114    submit_type: Option<stripe_shared::PaymentLinkSubmitType>,
115    subscription_data: Option<Option<stripe_shared::PaymentLinksResourceSubscriptionData>>,
116    tax_id_collection: Option<stripe_shared::PaymentLinksResourceTaxIdCollection>,
117    transfer_data: Option<Option<stripe_shared::PaymentLinksResourceTransferData>>,
118    url: Option<String>,
119}
120
121#[allow(
122    unused_variables,
123    irrefutable_let_patterns,
124    clippy::let_unit_value,
125    clippy::match_single_binding,
126    clippy::single_match
127)]
128const _: () = {
129    use miniserde::de::{Map, Visitor};
130    use miniserde::json::Value;
131    use miniserde::{make_place, Deserialize, Result};
132    use stripe_types::miniserde_helpers::FromValueOpt;
133    use stripe_types::{MapBuilder, ObjectDeser};
134
135    make_place!(Place);
136
137    impl Deserialize for PaymentLink {
138        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
139            Place::new(out)
140        }
141    }
142
143    struct Builder<'a> {
144        out: &'a mut Option<PaymentLink>,
145        builder: PaymentLinkBuilder,
146    }
147
148    impl Visitor for Place<PaymentLink> {
149        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
150            Ok(Box::new(Builder {
151                out: &mut self.out,
152                builder: PaymentLinkBuilder::deser_default(),
153            }))
154        }
155    }
156
157    impl MapBuilder for PaymentLinkBuilder {
158        type Out = PaymentLink;
159        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
160            Ok(match k {
161                "active" => Deserialize::begin(&mut self.active),
162                "after_completion" => Deserialize::begin(&mut self.after_completion),
163                "allow_promotion_codes" => Deserialize::begin(&mut self.allow_promotion_codes),
164                "application" => Deserialize::begin(&mut self.application),
165                "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount),
166                "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent),
167                "automatic_tax" => Deserialize::begin(&mut self.automatic_tax),
168                "billing_address_collection" => {
169                    Deserialize::begin(&mut self.billing_address_collection)
170                }
171                "consent_collection" => Deserialize::begin(&mut self.consent_collection),
172                "currency" => Deserialize::begin(&mut self.currency),
173                "custom_fields" => Deserialize::begin(&mut self.custom_fields),
174                "custom_text" => Deserialize::begin(&mut self.custom_text),
175                "customer_creation" => Deserialize::begin(&mut self.customer_creation),
176                "id" => Deserialize::begin(&mut self.id),
177                "inactive_message" => Deserialize::begin(&mut self.inactive_message),
178                "invoice_creation" => Deserialize::begin(&mut self.invoice_creation),
179                "line_items" => Deserialize::begin(&mut self.line_items),
180                "livemode" => Deserialize::begin(&mut self.livemode),
181                "metadata" => Deserialize::begin(&mut self.metadata),
182                "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
183                "optional_items" => Deserialize::begin(&mut self.optional_items),
184                "payment_intent_data" => Deserialize::begin(&mut self.payment_intent_data),
185                "payment_method_collection" => {
186                    Deserialize::begin(&mut self.payment_method_collection)
187                }
188                "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
189                "phone_number_collection" => Deserialize::begin(&mut self.phone_number_collection),
190                "restrictions" => Deserialize::begin(&mut self.restrictions),
191                "shipping_address_collection" => {
192                    Deserialize::begin(&mut self.shipping_address_collection)
193                }
194                "shipping_options" => Deserialize::begin(&mut self.shipping_options),
195                "submit_type" => Deserialize::begin(&mut self.submit_type),
196                "subscription_data" => Deserialize::begin(&mut self.subscription_data),
197                "tax_id_collection" => Deserialize::begin(&mut self.tax_id_collection),
198                "transfer_data" => Deserialize::begin(&mut self.transfer_data),
199                "url" => Deserialize::begin(&mut self.url),
200
201                _ => <dyn Visitor>::ignore(),
202            })
203        }
204
205        fn deser_default() -> Self {
206            Self {
207                active: Deserialize::default(),
208                after_completion: Deserialize::default(),
209                allow_promotion_codes: Deserialize::default(),
210                application: Deserialize::default(),
211                application_fee_amount: Deserialize::default(),
212                application_fee_percent: Deserialize::default(),
213                automatic_tax: Deserialize::default(),
214                billing_address_collection: Deserialize::default(),
215                consent_collection: Deserialize::default(),
216                currency: Deserialize::default(),
217                custom_fields: Deserialize::default(),
218                custom_text: Deserialize::default(),
219                customer_creation: Deserialize::default(),
220                id: Deserialize::default(),
221                inactive_message: Deserialize::default(),
222                invoice_creation: Deserialize::default(),
223                line_items: Deserialize::default(),
224                livemode: Deserialize::default(),
225                metadata: Deserialize::default(),
226                on_behalf_of: Deserialize::default(),
227                optional_items: Deserialize::default(),
228                payment_intent_data: Deserialize::default(),
229                payment_method_collection: Deserialize::default(),
230                payment_method_types: Deserialize::default(),
231                phone_number_collection: Deserialize::default(),
232                restrictions: Deserialize::default(),
233                shipping_address_collection: Deserialize::default(),
234                shipping_options: Deserialize::default(),
235                submit_type: Deserialize::default(),
236                subscription_data: Deserialize::default(),
237                tax_id_collection: Deserialize::default(),
238                transfer_data: Deserialize::default(),
239                url: Deserialize::default(),
240            }
241        }
242
243        fn take_out(&mut self) -> Option<Self::Out> {
244            let (
245                Some(active),
246                Some(after_completion),
247                Some(allow_promotion_codes),
248                Some(application),
249                Some(application_fee_amount),
250                Some(application_fee_percent),
251                Some(automatic_tax),
252                Some(billing_address_collection),
253                Some(consent_collection),
254                Some(currency),
255                Some(custom_fields),
256                Some(custom_text),
257                Some(customer_creation),
258                Some(id),
259                Some(inactive_message),
260                Some(invoice_creation),
261                Some(line_items),
262                Some(livemode),
263                Some(metadata),
264                Some(on_behalf_of),
265                Some(optional_items),
266                Some(payment_intent_data),
267                Some(payment_method_collection),
268                Some(payment_method_types),
269                Some(phone_number_collection),
270                Some(restrictions),
271                Some(shipping_address_collection),
272                Some(shipping_options),
273                Some(submit_type),
274                Some(subscription_data),
275                Some(tax_id_collection),
276                Some(transfer_data),
277                Some(url),
278            ) = (
279                self.active,
280                self.after_completion.take(),
281                self.allow_promotion_codes,
282                self.application.take(),
283                self.application_fee_amount,
284                self.application_fee_percent,
285                self.automatic_tax.take(),
286                self.billing_address_collection,
287                self.consent_collection,
288                self.currency,
289                self.custom_fields.take(),
290                self.custom_text.take(),
291                self.customer_creation,
292                self.id.take(),
293                self.inactive_message.take(),
294                self.invoice_creation.take(),
295                self.line_items.take(),
296                self.livemode,
297                self.metadata.take(),
298                self.on_behalf_of.take(),
299                self.optional_items.take(),
300                self.payment_intent_data.take(),
301                self.payment_method_collection,
302                self.payment_method_types.take(),
303                self.phone_number_collection,
304                self.restrictions,
305                self.shipping_address_collection.take(),
306                self.shipping_options.take(),
307                self.submit_type,
308                self.subscription_data.take(),
309                self.tax_id_collection,
310                self.transfer_data.take(),
311                self.url.take(),
312            )
313            else {
314                return None;
315            };
316            Some(Self::Out {
317                active,
318                after_completion,
319                allow_promotion_codes,
320                application,
321                application_fee_amount,
322                application_fee_percent,
323                automatic_tax,
324                billing_address_collection,
325                consent_collection,
326                currency,
327                custom_fields,
328                custom_text,
329                customer_creation,
330                id,
331                inactive_message,
332                invoice_creation,
333                line_items,
334                livemode,
335                metadata,
336                on_behalf_of,
337                optional_items,
338                payment_intent_data,
339                payment_method_collection,
340                payment_method_types,
341                phone_number_collection,
342                restrictions,
343                shipping_address_collection,
344                shipping_options,
345                submit_type,
346                subscription_data,
347                tax_id_collection,
348                transfer_data,
349                url,
350            })
351        }
352    }
353
354    impl<'a> Map for Builder<'a> {
355        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
356            self.builder.key(k)
357        }
358
359        fn finish(&mut self) -> Result<()> {
360            *self.out = self.builder.take_out();
361            Ok(())
362        }
363    }
364
365    impl ObjectDeser for PaymentLink {
366        type Builder = PaymentLinkBuilder;
367    }
368
369    impl FromValueOpt for PaymentLink {
370        fn from_value(v: Value) -> Option<Self> {
371            let Value::Object(obj) = v else {
372                return None;
373            };
374            let mut b = PaymentLinkBuilder::deser_default();
375            for (k, v) in obj {
376                match k.as_str() {
377                    "active" => b.active = FromValueOpt::from_value(v),
378                    "after_completion" => b.after_completion = FromValueOpt::from_value(v),
379                    "allow_promotion_codes" => {
380                        b.allow_promotion_codes = FromValueOpt::from_value(v)
381                    }
382                    "application" => b.application = FromValueOpt::from_value(v),
383                    "application_fee_amount" => {
384                        b.application_fee_amount = FromValueOpt::from_value(v)
385                    }
386                    "application_fee_percent" => {
387                        b.application_fee_percent = FromValueOpt::from_value(v)
388                    }
389                    "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
390                    "billing_address_collection" => {
391                        b.billing_address_collection = FromValueOpt::from_value(v)
392                    }
393                    "consent_collection" => b.consent_collection = FromValueOpt::from_value(v),
394                    "currency" => b.currency = FromValueOpt::from_value(v),
395                    "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
396                    "custom_text" => b.custom_text = FromValueOpt::from_value(v),
397                    "customer_creation" => b.customer_creation = FromValueOpt::from_value(v),
398                    "id" => b.id = FromValueOpt::from_value(v),
399                    "inactive_message" => b.inactive_message = FromValueOpt::from_value(v),
400                    "invoice_creation" => b.invoice_creation = FromValueOpt::from_value(v),
401                    "line_items" => b.line_items = FromValueOpt::from_value(v),
402                    "livemode" => b.livemode = FromValueOpt::from_value(v),
403                    "metadata" => b.metadata = FromValueOpt::from_value(v),
404                    "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
405                    "optional_items" => b.optional_items = FromValueOpt::from_value(v),
406                    "payment_intent_data" => b.payment_intent_data = FromValueOpt::from_value(v),
407                    "payment_method_collection" => {
408                        b.payment_method_collection = FromValueOpt::from_value(v)
409                    }
410                    "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
411                    "phone_number_collection" => {
412                        b.phone_number_collection = FromValueOpt::from_value(v)
413                    }
414                    "restrictions" => b.restrictions = FromValueOpt::from_value(v),
415                    "shipping_address_collection" => {
416                        b.shipping_address_collection = FromValueOpt::from_value(v)
417                    }
418                    "shipping_options" => b.shipping_options = FromValueOpt::from_value(v),
419                    "submit_type" => b.submit_type = FromValueOpt::from_value(v),
420                    "subscription_data" => b.subscription_data = FromValueOpt::from_value(v),
421                    "tax_id_collection" => b.tax_id_collection = FromValueOpt::from_value(v),
422                    "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
423                    "url" => b.url = FromValueOpt::from_value(v),
424
425                    _ => {}
426                }
427            }
428            b.take_out()
429        }
430    }
431};
432#[cfg(feature = "serialize")]
433impl serde::Serialize for PaymentLink {
434    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
435        use serde::ser::SerializeStruct;
436        let mut s = s.serialize_struct("PaymentLink", 34)?;
437        s.serialize_field("active", &self.active)?;
438        s.serialize_field("after_completion", &self.after_completion)?;
439        s.serialize_field("allow_promotion_codes", &self.allow_promotion_codes)?;
440        s.serialize_field("application", &self.application)?;
441        s.serialize_field("application_fee_amount", &self.application_fee_amount)?;
442        s.serialize_field("application_fee_percent", &self.application_fee_percent)?;
443        s.serialize_field("automatic_tax", &self.automatic_tax)?;
444        s.serialize_field("billing_address_collection", &self.billing_address_collection)?;
445        s.serialize_field("consent_collection", &self.consent_collection)?;
446        s.serialize_field("currency", &self.currency)?;
447        s.serialize_field("custom_fields", &self.custom_fields)?;
448        s.serialize_field("custom_text", &self.custom_text)?;
449        s.serialize_field("customer_creation", &self.customer_creation)?;
450        s.serialize_field("id", &self.id)?;
451        s.serialize_field("inactive_message", &self.inactive_message)?;
452        s.serialize_field("invoice_creation", &self.invoice_creation)?;
453        s.serialize_field("line_items", &self.line_items)?;
454        s.serialize_field("livemode", &self.livemode)?;
455        s.serialize_field("metadata", &self.metadata)?;
456        s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
457        s.serialize_field("optional_items", &self.optional_items)?;
458        s.serialize_field("payment_intent_data", &self.payment_intent_data)?;
459        s.serialize_field("payment_method_collection", &self.payment_method_collection)?;
460        s.serialize_field("payment_method_types", &self.payment_method_types)?;
461        s.serialize_field("phone_number_collection", &self.phone_number_collection)?;
462        s.serialize_field("restrictions", &self.restrictions)?;
463        s.serialize_field("shipping_address_collection", &self.shipping_address_collection)?;
464        s.serialize_field("shipping_options", &self.shipping_options)?;
465        s.serialize_field("submit_type", &self.submit_type)?;
466        s.serialize_field("subscription_data", &self.subscription_data)?;
467        s.serialize_field("tax_id_collection", &self.tax_id_collection)?;
468        s.serialize_field("transfer_data", &self.transfer_data)?;
469        s.serialize_field("url", &self.url)?;
470
471        s.serialize_field("object", "payment_link")?;
472        s.end()
473    }
474}
475/// Configuration for Customer creation during checkout.
476#[derive(Copy, Clone, Eq, PartialEq)]
477pub enum PaymentLinkCustomerCreation {
478    Always,
479    IfRequired,
480}
481impl PaymentLinkCustomerCreation {
482    pub fn as_str(self) -> &'static str {
483        use PaymentLinkCustomerCreation::*;
484        match self {
485            Always => "always",
486            IfRequired => "if_required",
487        }
488    }
489}
490
491impl std::str::FromStr for PaymentLinkCustomerCreation {
492    type Err = stripe_types::StripeParseError;
493    fn from_str(s: &str) -> Result<Self, Self::Err> {
494        use PaymentLinkCustomerCreation::*;
495        match s {
496            "always" => Ok(Always),
497            "if_required" => Ok(IfRequired),
498            _ => Err(stripe_types::StripeParseError),
499        }
500    }
501}
502impl std::fmt::Display for PaymentLinkCustomerCreation {
503    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
504        f.write_str(self.as_str())
505    }
506}
507
508impl std::fmt::Debug for PaymentLinkCustomerCreation {
509    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
510        f.write_str(self.as_str())
511    }
512}
513#[cfg(feature = "serialize")]
514impl serde::Serialize for PaymentLinkCustomerCreation {
515    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
516    where
517        S: serde::Serializer,
518    {
519        serializer.serialize_str(self.as_str())
520    }
521}
522impl miniserde::Deserialize for PaymentLinkCustomerCreation {
523    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
524        crate::Place::new(out)
525    }
526}
527
528impl miniserde::de::Visitor for crate::Place<PaymentLinkCustomerCreation> {
529    fn string(&mut self, s: &str) -> miniserde::Result<()> {
530        use std::str::FromStr;
531        self.out = Some(PaymentLinkCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?);
532        Ok(())
533    }
534}
535
536stripe_types::impl_from_val_with_from_str!(PaymentLinkCustomerCreation);
537#[cfg(feature = "deserialize")]
538impl<'de> serde::Deserialize<'de> for PaymentLinkCustomerCreation {
539    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
540        use std::str::FromStr;
541        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
542        Self::from_str(&s)
543            .map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkCustomerCreation"))
544    }
545}
546/// Configuration for collecting a payment method during checkout. Defaults to `always`.
547#[derive(Copy, Clone, Eq, PartialEq)]
548pub enum PaymentLinkPaymentMethodCollection {
549    Always,
550    IfRequired,
551}
552impl PaymentLinkPaymentMethodCollection {
553    pub fn as_str(self) -> &'static str {
554        use PaymentLinkPaymentMethodCollection::*;
555        match self {
556            Always => "always",
557            IfRequired => "if_required",
558        }
559    }
560}
561
562impl std::str::FromStr for PaymentLinkPaymentMethodCollection {
563    type Err = stripe_types::StripeParseError;
564    fn from_str(s: &str) -> Result<Self, Self::Err> {
565        use PaymentLinkPaymentMethodCollection::*;
566        match s {
567            "always" => Ok(Always),
568            "if_required" => Ok(IfRequired),
569            _ => Err(stripe_types::StripeParseError),
570        }
571    }
572}
573impl std::fmt::Display for PaymentLinkPaymentMethodCollection {
574    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
575        f.write_str(self.as_str())
576    }
577}
578
579impl std::fmt::Debug for PaymentLinkPaymentMethodCollection {
580    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
581        f.write_str(self.as_str())
582    }
583}
584#[cfg(feature = "serialize")]
585impl serde::Serialize for PaymentLinkPaymentMethodCollection {
586    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
587    where
588        S: serde::Serializer,
589    {
590        serializer.serialize_str(self.as_str())
591    }
592}
593impl miniserde::Deserialize for PaymentLinkPaymentMethodCollection {
594    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
595        crate::Place::new(out)
596    }
597}
598
599impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodCollection> {
600    fn string(&mut self, s: &str) -> miniserde::Result<()> {
601        use std::str::FromStr;
602        self.out =
603            Some(PaymentLinkPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?);
604        Ok(())
605    }
606}
607
608stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodCollection);
609#[cfg(feature = "deserialize")]
610impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodCollection {
611    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
612        use std::str::FromStr;
613        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
614        Self::from_str(&s).map_err(|_| {
615            serde::de::Error::custom("Unknown value for PaymentLinkPaymentMethodCollection")
616        })
617    }
618}
619impl stripe_types::Object for PaymentLink {
620    type Id = stripe_shared::PaymentLinkId;
621    fn id(&self) -> &Self::Id {
622        &self.id
623    }
624
625    fn into_id(self) -> Self::Id {
626        self.id
627    }
628}
629stripe_types::def_id!(PaymentLinkId);
630#[derive(Copy, Clone, Eq, PartialEq)]
631pub enum PaymentLinkBillingAddressCollection {
632    Auto,
633    Required,
634}
635impl PaymentLinkBillingAddressCollection {
636    pub fn as_str(self) -> &'static str {
637        use PaymentLinkBillingAddressCollection::*;
638        match self {
639            Auto => "auto",
640            Required => "required",
641        }
642    }
643}
644
645impl std::str::FromStr for PaymentLinkBillingAddressCollection {
646    type Err = stripe_types::StripeParseError;
647    fn from_str(s: &str) -> Result<Self, Self::Err> {
648        use PaymentLinkBillingAddressCollection::*;
649        match s {
650            "auto" => Ok(Auto),
651            "required" => Ok(Required),
652            _ => Err(stripe_types::StripeParseError),
653        }
654    }
655}
656impl std::fmt::Display for PaymentLinkBillingAddressCollection {
657    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
658        f.write_str(self.as_str())
659    }
660}
661
662impl std::fmt::Debug for PaymentLinkBillingAddressCollection {
663    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
664        f.write_str(self.as_str())
665    }
666}
667impl serde::Serialize for PaymentLinkBillingAddressCollection {
668    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
669    where
670        S: serde::Serializer,
671    {
672        serializer.serialize_str(self.as_str())
673    }
674}
675impl miniserde::Deserialize for PaymentLinkBillingAddressCollection {
676    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
677        crate::Place::new(out)
678    }
679}
680
681impl miniserde::de::Visitor for crate::Place<PaymentLinkBillingAddressCollection> {
682    fn string(&mut self, s: &str) -> miniserde::Result<()> {
683        use std::str::FromStr;
684        self.out =
685            Some(PaymentLinkBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?);
686        Ok(())
687    }
688}
689
690stripe_types::impl_from_val_with_from_str!(PaymentLinkBillingAddressCollection);
691#[cfg(feature = "deserialize")]
692impl<'de> serde::Deserialize<'de> for PaymentLinkBillingAddressCollection {
693    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
694        use std::str::FromStr;
695        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
696        Self::from_str(&s).map_err(|_| {
697            serde::de::Error::custom("Unknown value for PaymentLinkBillingAddressCollection")
698        })
699    }
700}
701#[derive(Clone, Eq, PartialEq)]
702#[non_exhaustive]
703pub enum PaymentLinkPaymentMethodTypes {
704    Affirm,
705    AfterpayClearpay,
706    Alipay,
707    Alma,
708    AuBecsDebit,
709    BacsDebit,
710    Bancontact,
711    Billie,
712    Blik,
713    Boleto,
714    Card,
715    Cashapp,
716    Eps,
717    Fpx,
718    Giropay,
719    Grabpay,
720    Ideal,
721    Klarna,
722    Konbini,
723    Link,
724    Mobilepay,
725    Multibanco,
726    Oxxo,
727    P24,
728    PayByBank,
729    Paynow,
730    Paypal,
731    Pix,
732    Promptpay,
733    Satispay,
734    SepaDebit,
735    Sofort,
736    Swish,
737    Twint,
738    UsBankAccount,
739    WechatPay,
740    Zip,
741    /// An unrecognized value from Stripe. Should not be used as a request parameter.
742    Unknown(String),
743}
744impl PaymentLinkPaymentMethodTypes {
745    pub fn as_str(&self) -> &str {
746        use PaymentLinkPaymentMethodTypes::*;
747        match self {
748            Affirm => "affirm",
749            AfterpayClearpay => "afterpay_clearpay",
750            Alipay => "alipay",
751            Alma => "alma",
752            AuBecsDebit => "au_becs_debit",
753            BacsDebit => "bacs_debit",
754            Bancontact => "bancontact",
755            Billie => "billie",
756            Blik => "blik",
757            Boleto => "boleto",
758            Card => "card",
759            Cashapp => "cashapp",
760            Eps => "eps",
761            Fpx => "fpx",
762            Giropay => "giropay",
763            Grabpay => "grabpay",
764            Ideal => "ideal",
765            Klarna => "klarna",
766            Konbini => "konbini",
767            Link => "link",
768            Mobilepay => "mobilepay",
769            Multibanco => "multibanco",
770            Oxxo => "oxxo",
771            P24 => "p24",
772            PayByBank => "pay_by_bank",
773            Paynow => "paynow",
774            Paypal => "paypal",
775            Pix => "pix",
776            Promptpay => "promptpay",
777            Satispay => "satispay",
778            SepaDebit => "sepa_debit",
779            Sofort => "sofort",
780            Swish => "swish",
781            Twint => "twint",
782            UsBankAccount => "us_bank_account",
783            WechatPay => "wechat_pay",
784            Zip => "zip",
785            Unknown(v) => v,
786        }
787    }
788}
789
790impl std::str::FromStr for PaymentLinkPaymentMethodTypes {
791    type Err = std::convert::Infallible;
792    fn from_str(s: &str) -> Result<Self, Self::Err> {
793        use PaymentLinkPaymentMethodTypes::*;
794        match s {
795            "affirm" => Ok(Affirm),
796            "afterpay_clearpay" => Ok(AfterpayClearpay),
797            "alipay" => Ok(Alipay),
798            "alma" => Ok(Alma),
799            "au_becs_debit" => Ok(AuBecsDebit),
800            "bacs_debit" => Ok(BacsDebit),
801            "bancontact" => Ok(Bancontact),
802            "billie" => Ok(Billie),
803            "blik" => Ok(Blik),
804            "boleto" => Ok(Boleto),
805            "card" => Ok(Card),
806            "cashapp" => Ok(Cashapp),
807            "eps" => Ok(Eps),
808            "fpx" => Ok(Fpx),
809            "giropay" => Ok(Giropay),
810            "grabpay" => Ok(Grabpay),
811            "ideal" => Ok(Ideal),
812            "klarna" => Ok(Klarna),
813            "konbini" => Ok(Konbini),
814            "link" => Ok(Link),
815            "mobilepay" => Ok(Mobilepay),
816            "multibanco" => Ok(Multibanco),
817            "oxxo" => Ok(Oxxo),
818            "p24" => Ok(P24),
819            "pay_by_bank" => Ok(PayByBank),
820            "paynow" => Ok(Paynow),
821            "paypal" => Ok(Paypal),
822            "pix" => Ok(Pix),
823            "promptpay" => Ok(Promptpay),
824            "satispay" => Ok(Satispay),
825            "sepa_debit" => Ok(SepaDebit),
826            "sofort" => Ok(Sofort),
827            "swish" => Ok(Swish),
828            "twint" => Ok(Twint),
829            "us_bank_account" => Ok(UsBankAccount),
830            "wechat_pay" => Ok(WechatPay),
831            "zip" => Ok(Zip),
832            v => Ok(Unknown(v.to_owned())),
833        }
834    }
835}
836impl std::fmt::Display for PaymentLinkPaymentMethodTypes {
837    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
838        f.write_str(self.as_str())
839    }
840}
841
842impl std::fmt::Debug for PaymentLinkPaymentMethodTypes {
843    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
844        f.write_str(self.as_str())
845    }
846}
847impl serde::Serialize for PaymentLinkPaymentMethodTypes {
848    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
849    where
850        S: serde::Serializer,
851    {
852        serializer.serialize_str(self.as_str())
853    }
854}
855impl miniserde::Deserialize for PaymentLinkPaymentMethodTypes {
856    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
857        crate::Place::new(out)
858    }
859}
860
861impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodTypes> {
862    fn string(&mut self, s: &str) -> miniserde::Result<()> {
863        use std::str::FromStr;
864        self.out = Some(PaymentLinkPaymentMethodTypes::from_str(s).unwrap());
865        Ok(())
866    }
867}
868
869stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodTypes);
870#[cfg(feature = "deserialize")]
871impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodTypes {
872    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
873        use std::str::FromStr;
874        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
875        Ok(Self::from_str(&s).unwrap())
876    }
877}
878#[derive(Copy, Clone, Eq, PartialEq)]
879pub enum PaymentLinkSubmitType {
880    Auto,
881    Book,
882    Donate,
883    Pay,
884    Subscribe,
885}
886impl PaymentLinkSubmitType {
887    pub fn as_str(self) -> &'static str {
888        use PaymentLinkSubmitType::*;
889        match self {
890            Auto => "auto",
891            Book => "book",
892            Donate => "donate",
893            Pay => "pay",
894            Subscribe => "subscribe",
895        }
896    }
897}
898
899impl std::str::FromStr for PaymentLinkSubmitType {
900    type Err = stripe_types::StripeParseError;
901    fn from_str(s: &str) -> Result<Self, Self::Err> {
902        use PaymentLinkSubmitType::*;
903        match s {
904            "auto" => Ok(Auto),
905            "book" => Ok(Book),
906            "donate" => Ok(Donate),
907            "pay" => Ok(Pay),
908            "subscribe" => Ok(Subscribe),
909            _ => Err(stripe_types::StripeParseError),
910        }
911    }
912}
913impl std::fmt::Display for PaymentLinkSubmitType {
914    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
915        f.write_str(self.as_str())
916    }
917}
918
919impl std::fmt::Debug for PaymentLinkSubmitType {
920    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
921        f.write_str(self.as_str())
922    }
923}
924impl serde::Serialize for PaymentLinkSubmitType {
925    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
926    where
927        S: serde::Serializer,
928    {
929        serializer.serialize_str(self.as_str())
930    }
931}
932impl miniserde::Deserialize for PaymentLinkSubmitType {
933    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
934        crate::Place::new(out)
935    }
936}
937
938impl miniserde::de::Visitor for crate::Place<PaymentLinkSubmitType> {
939    fn string(&mut self, s: &str) -> miniserde::Result<()> {
940        use std::str::FromStr;
941        self.out = Some(PaymentLinkSubmitType::from_str(s).map_err(|_| miniserde::Error)?);
942        Ok(())
943    }
944}
945
946stripe_types::impl_from_val_with_from_str!(PaymentLinkSubmitType);
947#[cfg(feature = "deserialize")]
948impl<'de> serde::Deserialize<'de> for PaymentLinkSubmitType {
949    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
950        use std::str::FromStr;
951        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
952        Self::from_str(&s)
953            .map_err(|_| serde::de::Error::custom("Unknown value for PaymentLinkSubmitType"))
954    }
955}