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