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