Skip to main content

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