1#[derive(Clone, Debug)]
11#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
12pub struct PaymentLink {
13 pub active: bool,
16 pub after_completion: stripe_shared::PaymentLinksResourceAfterCompletion,
17 pub allow_promotion_codes: bool,
19 pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
21 pub application_fee_amount: Option<i64>,
23 pub application_fee_percent: Option<f64>,
25 pub automatic_tax: stripe_shared::PaymentLinksResourceAutomaticTax,
26 pub billing_address_collection: stripe_shared::PaymentLinkBillingAddressCollection,
28 pub consent_collection: Option<stripe_shared::PaymentLinksResourceConsentCollection>,
30 pub currency: stripe_types::Currency,
33 pub custom_fields: Vec<stripe_shared::PaymentLinksResourceCustomFields>,
36 pub custom_text: stripe_shared::PaymentLinksResourceCustomText,
37 pub customer_creation: PaymentLinkCustomerCreation,
39 pub id: stripe_shared::PaymentLinkId,
41 pub inactive_message: Option<String>,
43 pub invoice_creation: Option<stripe_shared::PaymentLinksResourceInvoiceCreation>,
45 pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>,
47 pub livemode: bool,
49 pub metadata: std::collections::HashMap<String, String>,
52 pub name_collection: Option<stripe_shared::PaymentLinksResourceNameCollection>,
53 pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
56 pub optional_items: Option<Vec<stripe_shared::PaymentLinksResourceOptionalItem>>,
58 pub payment_intent_data: Option<stripe_shared::PaymentLinksResourcePaymentIntentData>,
60 pub payment_method_collection: PaymentLinkPaymentMethodCollection,
62 pub payment_method_types: Option<Vec<stripe_shared::PaymentLinkPaymentMethodTypes>>,
65 pub phone_number_collection: stripe_shared::PaymentLinksResourcePhoneNumberCollection,
66 pub restrictions: Option<stripe_shared::PaymentLinksResourceRestrictions>,
68 pub shipping_address_collection:
70 Option<stripe_shared::PaymentLinksResourceShippingAddressCollection>,
71 pub shipping_options: Vec<stripe_shared::PaymentLinksResourceShippingOption>,
73 pub submit_type: stripe_shared::PaymentLinkSubmitType,
75 pub subscription_data: Option<stripe_shared::PaymentLinksResourceSubscriptionData>,
78 pub tax_id_collection: stripe_shared::PaymentLinksResourceTaxIdCollection,
79 pub transfer_data: Option<stripe_shared::PaymentLinksResourceTransferData>,
81 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.take(),
291 self.consent_collection.take(),
292 self.currency.take(),
293 self.custom_fields.take(),
294 self.custom_text.take(),
295 self.customer_creation.take(),
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.take(),
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.take(),
313 self.subscription_data.take(),
314 self.tax_id_collection.take(),
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#[derive(Clone, Eq, PartialEq)]
484#[non_exhaustive]
485pub enum PaymentLinkCustomerCreation {
486 Always,
487 IfRequired,
488 Unknown(String),
490}
491impl PaymentLinkCustomerCreation {
492 pub fn as_str(&self) -> &str {
493 use PaymentLinkCustomerCreation::*;
494 match self {
495 Always => "always",
496 IfRequired => "if_required",
497 Unknown(v) => v,
498 }
499 }
500}
501
502impl std::str::FromStr for PaymentLinkCustomerCreation {
503 type Err = std::convert::Infallible;
504 fn from_str(s: &str) -> Result<Self, Self::Err> {
505 use PaymentLinkCustomerCreation::*;
506 match s {
507 "always" => Ok(Always),
508 "if_required" => Ok(IfRequired),
509 v => {
510 tracing::warn!(
511 "Unknown value '{}' for enum '{}'",
512 v,
513 "PaymentLinkCustomerCreation"
514 );
515 Ok(Unknown(v.to_owned()))
516 }
517 }
518 }
519}
520impl std::fmt::Display for PaymentLinkCustomerCreation {
521 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
522 f.write_str(self.as_str())
523 }
524}
525
526impl std::fmt::Debug for PaymentLinkCustomerCreation {
527 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
528 f.write_str(self.as_str())
529 }
530}
531#[cfg(feature = "serialize")]
532impl serde::Serialize for PaymentLinkCustomerCreation {
533 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
534 where
535 S: serde::Serializer,
536 {
537 serializer.serialize_str(self.as_str())
538 }
539}
540impl miniserde::Deserialize for PaymentLinkCustomerCreation {
541 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
542 crate::Place::new(out)
543 }
544}
545
546impl miniserde::de::Visitor for crate::Place<PaymentLinkCustomerCreation> {
547 fn string(&mut self, s: &str) -> miniserde::Result<()> {
548 use std::str::FromStr;
549 self.out = Some(PaymentLinkCustomerCreation::from_str(s).expect("infallible"));
550 Ok(())
551 }
552}
553
554stripe_types::impl_from_val_with_from_str!(PaymentLinkCustomerCreation);
555#[cfg(feature = "deserialize")]
556impl<'de> serde::Deserialize<'de> for PaymentLinkCustomerCreation {
557 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
558 use std::str::FromStr;
559 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
560 Ok(Self::from_str(&s).expect("infallible"))
561 }
562}
563#[derive(Clone, Eq, PartialEq)]
565#[non_exhaustive]
566pub enum PaymentLinkPaymentMethodCollection {
567 Always,
568 IfRequired,
569 Unknown(String),
571}
572impl PaymentLinkPaymentMethodCollection {
573 pub fn as_str(&self) -> &str {
574 use PaymentLinkPaymentMethodCollection::*;
575 match self {
576 Always => "always",
577 IfRequired => "if_required",
578 Unknown(v) => v,
579 }
580 }
581}
582
583impl std::str::FromStr for PaymentLinkPaymentMethodCollection {
584 type Err = std::convert::Infallible;
585 fn from_str(s: &str) -> Result<Self, Self::Err> {
586 use PaymentLinkPaymentMethodCollection::*;
587 match s {
588 "always" => Ok(Always),
589 "if_required" => Ok(IfRequired),
590 v => {
591 tracing::warn!(
592 "Unknown value '{}' for enum '{}'",
593 v,
594 "PaymentLinkPaymentMethodCollection"
595 );
596 Ok(Unknown(v.to_owned()))
597 }
598 }
599 }
600}
601impl std::fmt::Display for PaymentLinkPaymentMethodCollection {
602 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
603 f.write_str(self.as_str())
604 }
605}
606
607impl std::fmt::Debug for PaymentLinkPaymentMethodCollection {
608 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
609 f.write_str(self.as_str())
610 }
611}
612#[cfg(feature = "serialize")]
613impl serde::Serialize for PaymentLinkPaymentMethodCollection {
614 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
615 where
616 S: serde::Serializer,
617 {
618 serializer.serialize_str(self.as_str())
619 }
620}
621impl miniserde::Deserialize for PaymentLinkPaymentMethodCollection {
622 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
623 crate::Place::new(out)
624 }
625}
626
627impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodCollection> {
628 fn string(&mut self, s: &str) -> miniserde::Result<()> {
629 use std::str::FromStr;
630 self.out = Some(PaymentLinkPaymentMethodCollection::from_str(s).expect("infallible"));
631 Ok(())
632 }
633}
634
635stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodCollection);
636#[cfg(feature = "deserialize")]
637impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodCollection {
638 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
639 use std::str::FromStr;
640 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
641 Ok(Self::from_str(&s).expect("infallible"))
642 }
643}
644impl stripe_types::Object for PaymentLink {
645 type Id = stripe_shared::PaymentLinkId;
646 fn id(&self) -> &Self::Id {
647 &self.id
648 }
649
650 fn into_id(self) -> Self::Id {
651 self.id
652 }
653}
654stripe_types::def_id!(PaymentLinkId);
655#[derive(Clone, Eq, PartialEq)]
656#[non_exhaustive]
657pub enum PaymentLinkBillingAddressCollection {
658 Auto,
659 Required,
660 Unknown(String),
662}
663impl PaymentLinkBillingAddressCollection {
664 pub fn as_str(&self) -> &str {
665 use PaymentLinkBillingAddressCollection::*;
666 match self {
667 Auto => "auto",
668 Required => "required",
669 Unknown(v) => v,
670 }
671 }
672}
673
674impl std::str::FromStr for PaymentLinkBillingAddressCollection {
675 type Err = std::convert::Infallible;
676 fn from_str(s: &str) -> Result<Self, Self::Err> {
677 use PaymentLinkBillingAddressCollection::*;
678 match s {
679 "auto" => Ok(Auto),
680 "required" => Ok(Required),
681 v => {
682 tracing::warn!(
683 "Unknown value '{}' for enum '{}'",
684 v,
685 "PaymentLinkBillingAddressCollection"
686 );
687 Ok(Unknown(v.to_owned()))
688 }
689 }
690 }
691}
692impl std::fmt::Display for PaymentLinkBillingAddressCollection {
693 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
694 f.write_str(self.as_str())
695 }
696}
697
698impl std::fmt::Debug for PaymentLinkBillingAddressCollection {
699 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
700 f.write_str(self.as_str())
701 }
702}
703impl serde::Serialize for PaymentLinkBillingAddressCollection {
704 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
705 where
706 S: serde::Serializer,
707 {
708 serializer.serialize_str(self.as_str())
709 }
710}
711impl miniserde::Deserialize for PaymentLinkBillingAddressCollection {
712 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
713 crate::Place::new(out)
714 }
715}
716
717impl miniserde::de::Visitor for crate::Place<PaymentLinkBillingAddressCollection> {
718 fn string(&mut self, s: &str) -> miniserde::Result<()> {
719 use std::str::FromStr;
720 self.out = Some(PaymentLinkBillingAddressCollection::from_str(s).expect("infallible"));
721 Ok(())
722 }
723}
724
725stripe_types::impl_from_val_with_from_str!(PaymentLinkBillingAddressCollection);
726#[cfg(feature = "deserialize")]
727impl<'de> serde::Deserialize<'de> for PaymentLinkBillingAddressCollection {
728 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
729 use std::str::FromStr;
730 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
731 Ok(Self::from_str(&s).expect("infallible"))
732 }
733}
734#[derive(Clone, Eq, PartialEq)]
735#[non_exhaustive]
736pub enum PaymentLinkPaymentMethodTypes {
737 Affirm,
738 AfterpayClearpay,
739 Alipay,
740 Alma,
741 AuBecsDebit,
742 BacsDebit,
743 Bancontact,
744 Billie,
745 Blik,
746 Boleto,
747 Card,
748 Cashapp,
749 Eps,
750 Fpx,
751 Giropay,
752 Grabpay,
753 Ideal,
754 Klarna,
755 Konbini,
756 Link,
757 MbWay,
758 Mobilepay,
759 Multibanco,
760 Oxxo,
761 P24,
762 PayByBank,
763 Paynow,
764 Paypal,
765 Payto,
766 Pix,
767 Promptpay,
768 Satispay,
769 SepaDebit,
770 Sofort,
771 Swish,
772 Twint,
773 UsBankAccount,
774 WechatPay,
775 Zip,
776 Unknown(String),
778}
779impl PaymentLinkPaymentMethodTypes {
780 pub fn as_str(&self) -> &str {
781 use PaymentLinkPaymentMethodTypes::*;
782 match self {
783 Affirm => "affirm",
784 AfterpayClearpay => "afterpay_clearpay",
785 Alipay => "alipay",
786 Alma => "alma",
787 AuBecsDebit => "au_becs_debit",
788 BacsDebit => "bacs_debit",
789 Bancontact => "bancontact",
790 Billie => "billie",
791 Blik => "blik",
792 Boleto => "boleto",
793 Card => "card",
794 Cashapp => "cashapp",
795 Eps => "eps",
796 Fpx => "fpx",
797 Giropay => "giropay",
798 Grabpay => "grabpay",
799 Ideal => "ideal",
800 Klarna => "klarna",
801 Konbini => "konbini",
802 Link => "link",
803 MbWay => "mb_way",
804 Mobilepay => "mobilepay",
805 Multibanco => "multibanco",
806 Oxxo => "oxxo",
807 P24 => "p24",
808 PayByBank => "pay_by_bank",
809 Paynow => "paynow",
810 Paypal => "paypal",
811 Payto => "payto",
812 Pix => "pix",
813 Promptpay => "promptpay",
814 Satispay => "satispay",
815 SepaDebit => "sepa_debit",
816 Sofort => "sofort",
817 Swish => "swish",
818 Twint => "twint",
819 UsBankAccount => "us_bank_account",
820 WechatPay => "wechat_pay",
821 Zip => "zip",
822 Unknown(v) => v,
823 }
824 }
825}
826
827impl std::str::FromStr for PaymentLinkPaymentMethodTypes {
828 type Err = std::convert::Infallible;
829 fn from_str(s: &str) -> Result<Self, Self::Err> {
830 use PaymentLinkPaymentMethodTypes::*;
831 match s {
832 "affirm" => Ok(Affirm),
833 "afterpay_clearpay" => Ok(AfterpayClearpay),
834 "alipay" => Ok(Alipay),
835 "alma" => Ok(Alma),
836 "au_becs_debit" => Ok(AuBecsDebit),
837 "bacs_debit" => Ok(BacsDebit),
838 "bancontact" => Ok(Bancontact),
839 "billie" => Ok(Billie),
840 "blik" => Ok(Blik),
841 "boleto" => Ok(Boleto),
842 "card" => Ok(Card),
843 "cashapp" => Ok(Cashapp),
844 "eps" => Ok(Eps),
845 "fpx" => Ok(Fpx),
846 "giropay" => Ok(Giropay),
847 "grabpay" => Ok(Grabpay),
848 "ideal" => Ok(Ideal),
849 "klarna" => Ok(Klarna),
850 "konbini" => Ok(Konbini),
851 "link" => Ok(Link),
852 "mb_way" => Ok(MbWay),
853 "mobilepay" => Ok(Mobilepay),
854 "multibanco" => Ok(Multibanco),
855 "oxxo" => Ok(Oxxo),
856 "p24" => Ok(P24),
857 "pay_by_bank" => Ok(PayByBank),
858 "paynow" => Ok(Paynow),
859 "paypal" => Ok(Paypal),
860 "payto" => Ok(Payto),
861 "pix" => Ok(Pix),
862 "promptpay" => Ok(Promptpay),
863 "satispay" => Ok(Satispay),
864 "sepa_debit" => Ok(SepaDebit),
865 "sofort" => Ok(Sofort),
866 "swish" => Ok(Swish),
867 "twint" => Ok(Twint),
868 "us_bank_account" => Ok(UsBankAccount),
869 "wechat_pay" => Ok(WechatPay),
870 "zip" => Ok(Zip),
871 v => {
872 tracing::warn!(
873 "Unknown value '{}' for enum '{}'",
874 v,
875 "PaymentLinkPaymentMethodTypes"
876 );
877 Ok(Unknown(v.to_owned()))
878 }
879 }
880 }
881}
882impl std::fmt::Display for PaymentLinkPaymentMethodTypes {
883 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
884 f.write_str(self.as_str())
885 }
886}
887
888impl std::fmt::Debug for PaymentLinkPaymentMethodTypes {
889 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
890 f.write_str(self.as_str())
891 }
892}
893impl serde::Serialize for PaymentLinkPaymentMethodTypes {
894 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
895 where
896 S: serde::Serializer,
897 {
898 serializer.serialize_str(self.as_str())
899 }
900}
901impl miniserde::Deserialize for PaymentLinkPaymentMethodTypes {
902 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
903 crate::Place::new(out)
904 }
905}
906
907impl miniserde::de::Visitor for crate::Place<PaymentLinkPaymentMethodTypes> {
908 fn string(&mut self, s: &str) -> miniserde::Result<()> {
909 use std::str::FromStr;
910 self.out = Some(PaymentLinkPaymentMethodTypes::from_str(s).expect("infallible"));
911 Ok(())
912 }
913}
914
915stripe_types::impl_from_val_with_from_str!(PaymentLinkPaymentMethodTypes);
916#[cfg(feature = "deserialize")]
917impl<'de> serde::Deserialize<'de> for PaymentLinkPaymentMethodTypes {
918 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
919 use std::str::FromStr;
920 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
921 Ok(Self::from_str(&s).expect("infallible"))
922 }
923}
924#[derive(Clone, Eq, PartialEq)]
925#[non_exhaustive]
926pub enum PaymentLinkSubmitType {
927 Auto,
928 Book,
929 Donate,
930 Pay,
931 Subscribe,
932 Unknown(String),
934}
935impl PaymentLinkSubmitType {
936 pub fn as_str(&self) -> &str {
937 use PaymentLinkSubmitType::*;
938 match self {
939 Auto => "auto",
940 Book => "book",
941 Donate => "donate",
942 Pay => "pay",
943 Subscribe => "subscribe",
944 Unknown(v) => v,
945 }
946 }
947}
948
949impl std::str::FromStr for PaymentLinkSubmitType {
950 type Err = std::convert::Infallible;
951 fn from_str(s: &str) -> Result<Self, Self::Err> {
952 use PaymentLinkSubmitType::*;
953 match s {
954 "auto" => Ok(Auto),
955 "book" => Ok(Book),
956 "donate" => Ok(Donate),
957 "pay" => Ok(Pay),
958 "subscribe" => Ok(Subscribe),
959 v => {
960 tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentLinkSubmitType");
961 Ok(Unknown(v.to_owned()))
962 }
963 }
964 }
965}
966impl std::fmt::Display for PaymentLinkSubmitType {
967 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
968 f.write_str(self.as_str())
969 }
970}
971
972impl std::fmt::Debug for PaymentLinkSubmitType {
973 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
974 f.write_str(self.as_str())
975 }
976}
977impl serde::Serialize for PaymentLinkSubmitType {
978 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
979 where
980 S: serde::Serializer,
981 {
982 serializer.serialize_str(self.as_str())
983 }
984}
985impl miniserde::Deserialize for PaymentLinkSubmitType {
986 fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
987 crate::Place::new(out)
988 }
989}
990
991impl miniserde::de::Visitor for crate::Place<PaymentLinkSubmitType> {
992 fn string(&mut self, s: &str) -> miniserde::Result<()> {
993 use std::str::FromStr;
994 self.out = Some(PaymentLinkSubmitType::from_str(s).expect("infallible"));
995 Ok(())
996 }
997}
998
999stripe_types::impl_from_val_with_from_str!(PaymentLinkSubmitType);
1000#[cfg(feature = "deserialize")]
1001impl<'de> serde::Deserialize<'de> for PaymentLinkSubmitType {
1002 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1003 use std::str::FromStr;
1004 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1005 Ok(Self::from_str(&s).expect("infallible"))
1006 }
1007}