1use stripe_client_core::{
2 RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListChargeBuilder {
7 #[serde(skip_serializing_if = "Option::is_none")]
8 created: Option<stripe_types::RangeQueryTs>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 customer: Option<String>,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 ending_before: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 expand: Option<Vec<String>>,
15 #[serde(skip_serializing_if = "Option::is_none")]
16 limit: Option<i64>,
17 #[serde(skip_serializing_if = "Option::is_none")]
18 payment_intent: Option<String>,
19 #[serde(skip_serializing_if = "Option::is_none")]
20 starting_after: Option<String>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 transfer_group: Option<String>,
23}
24impl ListChargeBuilder {
25 fn new() -> Self {
26 Self {
27 created: None,
28 customer: None,
29 ending_before: None,
30 expand: None,
31 limit: None,
32 payment_intent: None,
33 starting_after: None,
34 transfer_group: None,
35 }
36 }
37}
38#[derive(Clone, Debug, serde::Serialize)]
41pub struct ListCharge {
42 inner: ListChargeBuilder,
43}
44impl ListCharge {
45 pub fn new() -> Self {
47 Self { inner: ListChargeBuilder::new() }
48 }
49 pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
51 self.inner.created = Some(created.into());
52 self
53 }
54 pub fn customer(mut self, customer: impl Into<String>) -> Self {
56 self.inner.customer = Some(customer.into());
57 self
58 }
59 pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
63 self.inner.ending_before = Some(ending_before.into());
64 self
65 }
66 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
68 self.inner.expand = Some(expand.into());
69 self
70 }
71 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
74 self.inner.limit = Some(limit.into());
75 self
76 }
77 pub fn payment_intent(mut self, payment_intent: impl Into<String>) -> Self {
79 self.inner.payment_intent = Some(payment_intent.into());
80 self
81 }
82 pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
86 self.inner.starting_after = Some(starting_after.into());
87 self
88 }
89 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
91 self.inner.transfer_group = Some(transfer_group.into());
92 self
93 }
94}
95impl Default for ListCharge {
96 fn default() -> Self {
97 Self::new()
98 }
99}
100impl ListCharge {
101 pub async fn send<C: StripeClient>(
103 &self,
104 client: &C,
105 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
106 self.customize().send(client).await
107 }
108
109 pub fn send_blocking<C: StripeBlockingClient>(
111 &self,
112 client: &C,
113 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
114 self.customize().send_blocking(client)
115 }
116
117 pub fn paginate(
118 &self,
119 ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::Charge>> {
120 stripe_client_core::ListPaginator::new_list("/charges", &self.inner)
121 }
122}
123
124impl StripeRequest for ListCharge {
125 type Output = stripe_types::List<stripe_shared::Charge>;
126
127 fn build(&self) -> RequestBuilder {
128 RequestBuilder::new(StripeMethod::Get, "/charges").query(&self.inner)
129 }
130}
131#[derive(Clone, Debug, serde::Serialize)]
132struct RetrieveChargeBuilder {
133 #[serde(skip_serializing_if = "Option::is_none")]
134 expand: Option<Vec<String>>,
135}
136impl RetrieveChargeBuilder {
137 fn new() -> Self {
138 Self { expand: None }
139 }
140}
141#[derive(Clone, Debug, serde::Serialize)]
145pub struct RetrieveCharge {
146 inner: RetrieveChargeBuilder,
147 charge: stripe_shared::ChargeId,
148}
149impl RetrieveCharge {
150 pub fn new(charge: impl Into<stripe_shared::ChargeId>) -> Self {
152 Self { charge: charge.into(), inner: RetrieveChargeBuilder::new() }
153 }
154 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
156 self.inner.expand = Some(expand.into());
157 self
158 }
159}
160impl RetrieveCharge {
161 pub async fn send<C: StripeClient>(
163 &self,
164 client: &C,
165 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
166 self.customize().send(client).await
167 }
168
169 pub fn send_blocking<C: StripeBlockingClient>(
171 &self,
172 client: &C,
173 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
174 self.customize().send_blocking(client)
175 }
176}
177
178impl StripeRequest for RetrieveCharge {
179 type Output = stripe_shared::Charge;
180
181 fn build(&self) -> RequestBuilder {
182 let charge = &self.charge;
183 RequestBuilder::new(StripeMethod::Get, format!("/charges/{charge}")).query(&self.inner)
184 }
185}
186#[derive(Clone, Debug, serde::Serialize)]
187struct SearchChargeBuilder {
188 #[serde(skip_serializing_if = "Option::is_none")]
189 expand: Option<Vec<String>>,
190 #[serde(skip_serializing_if = "Option::is_none")]
191 limit: Option<i64>,
192 #[serde(skip_serializing_if = "Option::is_none")]
193 page: Option<String>,
194 query: String,
195}
196impl SearchChargeBuilder {
197 fn new(query: impl Into<String>) -> Self {
198 Self { expand: None, limit: None, page: None, query: query.into() }
199 }
200}
201#[derive(Clone, Debug, serde::Serialize)]
208pub struct SearchCharge {
209 inner: SearchChargeBuilder,
210}
211impl SearchCharge {
212 pub fn new(query: impl Into<String>) -> Self {
214 Self { inner: SearchChargeBuilder::new(query.into()) }
215 }
216 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
218 self.inner.expand = Some(expand.into());
219 self
220 }
221 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
224 self.inner.limit = Some(limit.into());
225 self
226 }
227 pub fn page(mut self, page: impl Into<String>) -> Self {
231 self.inner.page = Some(page.into());
232 self
233 }
234}
235impl SearchCharge {
236 pub async fn send<C: StripeClient>(
238 &self,
239 client: &C,
240 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
241 self.customize().send(client).await
242 }
243
244 pub fn send_blocking<C: StripeBlockingClient>(
246 &self,
247 client: &C,
248 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
249 self.customize().send_blocking(client)
250 }
251
252 pub fn paginate(
253 &self,
254 ) -> stripe_client_core::ListPaginator<stripe_types::SearchList<stripe_shared::Charge>> {
255 stripe_client_core::ListPaginator::new_search_list("/charges/search", &self.inner)
256 }
257}
258
259impl StripeRequest for SearchCharge {
260 type Output = stripe_types::SearchList<stripe_shared::Charge>;
261
262 fn build(&self) -> RequestBuilder {
263 RequestBuilder::new(StripeMethod::Get, "/charges/search").query(&self.inner)
264 }
265}
266#[derive(Clone, Debug, serde::Serialize)]
267struct CreateChargeBuilder {
268 #[serde(skip_serializing_if = "Option::is_none")]
269 amount: Option<i64>,
270 #[serde(skip_serializing_if = "Option::is_none")]
271 application_fee: Option<i64>,
272 #[serde(skip_serializing_if = "Option::is_none")]
273 application_fee_amount: Option<i64>,
274 #[serde(skip_serializing_if = "Option::is_none")]
275 capture: Option<bool>,
276 #[serde(skip_serializing_if = "Option::is_none")]
277 currency: Option<stripe_types::Currency>,
278 #[serde(skip_serializing_if = "Option::is_none")]
279 customer: Option<String>,
280 #[serde(skip_serializing_if = "Option::is_none")]
281 description: Option<String>,
282 #[serde(skip_serializing_if = "Option::is_none")]
283 destination: Option<CreateChargeDestination>,
284 #[serde(skip_serializing_if = "Option::is_none")]
285 expand: Option<Vec<String>>,
286 #[serde(skip_serializing_if = "Option::is_none")]
287 metadata: Option<std::collections::HashMap<String, String>>,
288 #[serde(skip_serializing_if = "Option::is_none")]
289 on_behalf_of: Option<String>,
290 #[serde(skip_serializing_if = "Option::is_none")]
291 radar_options: Option<CreateChargeRadarOptions>,
292 #[serde(skip_serializing_if = "Option::is_none")]
293 receipt_email: Option<String>,
294 #[serde(skip_serializing_if = "Option::is_none")]
295 shipping: Option<OptionalFieldsShipping>,
296 #[serde(skip_serializing_if = "Option::is_none")]
297 source: Option<String>,
298 #[serde(skip_serializing_if = "Option::is_none")]
299 statement_descriptor: Option<String>,
300 #[serde(skip_serializing_if = "Option::is_none")]
301 statement_descriptor_suffix: Option<String>,
302 #[serde(skip_serializing_if = "Option::is_none")]
303 transfer_data: Option<CreateChargeTransferData>,
304 #[serde(skip_serializing_if = "Option::is_none")]
305 transfer_group: Option<String>,
306}
307impl CreateChargeBuilder {
308 fn new() -> Self {
309 Self {
310 amount: None,
311 application_fee: None,
312 application_fee_amount: None,
313 capture: None,
314 currency: None,
315 customer: None,
316 description: None,
317 destination: None,
318 expand: None,
319 metadata: None,
320 on_behalf_of: None,
321 radar_options: None,
322 receipt_email: None,
323 shipping: None,
324 source: None,
325 statement_descriptor: None,
326 statement_descriptor_suffix: None,
327 transfer_data: None,
328 transfer_group: None,
329 }
330 }
331}
332#[derive(Clone, Debug, serde::Serialize)]
333pub struct CreateChargeDestination {
334 pub account: String,
336 #[serde(skip_serializing_if = "Option::is_none")]
340 pub amount: Option<i64>,
341}
342impl CreateChargeDestination {
343 pub fn new(account: impl Into<String>) -> Self {
344 Self { account: account.into(), amount: None }
345 }
346}
347#[derive(Clone, Debug, serde::Serialize)]
350pub struct CreateChargeRadarOptions {
351 #[serde(skip_serializing_if = "Option::is_none")]
353 pub session: Option<String>,
354}
355impl CreateChargeRadarOptions {
356 pub fn new() -> Self {
357 Self { session: None }
358 }
359}
360impl Default for CreateChargeRadarOptions {
361 fn default() -> Self {
362 Self::new()
363 }
364}
365#[derive(Clone, Debug, serde::Serialize)]
368pub struct CreateChargeTransferData {
369 #[serde(skip_serializing_if = "Option::is_none")]
372 pub amount: Option<i64>,
373 pub destination: String,
375}
376impl CreateChargeTransferData {
377 pub fn new(destination: impl Into<String>) -> Self {
378 Self { amount: None, destination: destination.into() }
379 }
380}
381#[derive(Clone, Debug, serde::Serialize)]
385pub struct CreateCharge {
386 inner: CreateChargeBuilder,
387}
388impl CreateCharge {
389 pub fn new() -> Self {
391 Self { inner: CreateChargeBuilder::new() }
392 }
393 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
398 self.inner.amount = Some(amount.into());
399 self
400 }
401 pub fn application_fee(mut self, application_fee: impl Into<i64>) -> Self {
402 self.inner.application_fee = Some(application_fee.into());
403 self
404 }
405 pub fn application_fee_amount(mut self, application_fee_amount: impl Into<i64>) -> Self {
409 self.inner.application_fee_amount = Some(application_fee_amount.into());
410 self
411 }
412 pub fn capture(mut self, capture: impl Into<bool>) -> Self {
418 self.inner.capture = Some(capture.into());
419 self
420 }
421 pub fn currency(mut self, currency: impl Into<stripe_types::Currency>) -> Self {
424 self.inner.currency = Some(currency.into());
425 self
426 }
427 pub fn customer(mut self, customer: impl Into<String>) -> Self {
429 self.inner.customer = Some(customer.into());
430 self
431 }
432 pub fn description(mut self, description: impl Into<String>) -> Self {
436 self.inner.description = Some(description.into());
437 self
438 }
439 pub fn destination(mut self, destination: impl Into<CreateChargeDestination>) -> Self {
440 self.inner.destination = Some(destination.into());
441 self
442 }
443 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
445 self.inner.expand = Some(expand.into());
446 self
447 }
448 pub fn metadata(
453 mut self,
454 metadata: impl Into<std::collections::HashMap<String, String>>,
455 ) -> Self {
456 self.inner.metadata = Some(metadata.into());
457 self
458 }
459 pub fn on_behalf_of(mut self, on_behalf_of: impl Into<String>) -> Self {
463 self.inner.on_behalf_of = Some(on_behalf_of.into());
464 self
465 }
466 pub fn radar_options(mut self, radar_options: impl Into<CreateChargeRadarOptions>) -> Self {
469 self.inner.radar_options = Some(radar_options.into());
470 self
471 }
472 pub fn receipt_email(mut self, receipt_email: impl Into<String>) -> Self {
477 self.inner.receipt_email = Some(receipt_email.into());
478 self
479 }
480 pub fn shipping(mut self, shipping: impl Into<OptionalFieldsShipping>) -> Self {
482 self.inner.shipping = Some(shipping.into());
483 self
484 }
485 pub fn source(mut self, source: impl Into<String>) -> Self {
489 self.inner.source = Some(source.into());
490 self
491 }
492 pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
498 self.inner.statement_descriptor = Some(statement_descriptor.into());
499 self
500 }
501 pub fn statement_descriptor_suffix(
505 mut self,
506 statement_descriptor_suffix: impl Into<String>,
507 ) -> Self {
508 self.inner.statement_descriptor_suffix = Some(statement_descriptor_suffix.into());
509 self
510 }
511 pub fn transfer_data(mut self, transfer_data: impl Into<CreateChargeTransferData>) -> Self {
514 self.inner.transfer_data = Some(transfer_data.into());
515 self
516 }
517 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
520 self.inner.transfer_group = Some(transfer_group.into());
521 self
522 }
523}
524impl Default for CreateCharge {
525 fn default() -> Self {
526 Self::new()
527 }
528}
529impl CreateCharge {
530 pub async fn send<C: StripeClient>(
532 &self,
533 client: &C,
534 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
535 self.customize().send(client).await
536 }
537
538 pub fn send_blocking<C: StripeBlockingClient>(
540 &self,
541 client: &C,
542 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
543 self.customize().send_blocking(client)
544 }
545}
546
547impl StripeRequest for CreateCharge {
548 type Output = stripe_shared::Charge;
549
550 fn build(&self) -> RequestBuilder {
551 RequestBuilder::new(StripeMethod::Post, "/charges").form(&self.inner)
552 }
553}
554#[derive(Clone, Debug, serde::Serialize)]
555struct UpdateChargeBuilder {
556 #[serde(skip_serializing_if = "Option::is_none")]
557 customer: Option<String>,
558 #[serde(skip_serializing_if = "Option::is_none")]
559 description: Option<String>,
560 #[serde(skip_serializing_if = "Option::is_none")]
561 expand: Option<Vec<String>>,
562 #[serde(skip_serializing_if = "Option::is_none")]
563 fraud_details: Option<UpdateChargeFraudDetails>,
564 #[serde(skip_serializing_if = "Option::is_none")]
565 metadata: Option<std::collections::HashMap<String, String>>,
566 #[serde(skip_serializing_if = "Option::is_none")]
567 receipt_email: Option<String>,
568 #[serde(skip_serializing_if = "Option::is_none")]
569 shipping: Option<OptionalFieldsShipping>,
570 #[serde(skip_serializing_if = "Option::is_none")]
571 transfer_group: Option<String>,
572}
573impl UpdateChargeBuilder {
574 fn new() -> Self {
575 Self {
576 customer: None,
577 description: None,
578 expand: None,
579 fraud_details: None,
580 metadata: None,
581 receipt_email: None,
582 shipping: None,
583 transfer_group: None,
584 }
585 }
586}
587#[derive(Copy, Clone, Debug, serde::Serialize)]
592pub struct UpdateChargeFraudDetails {
593 pub user_report: UpdateChargeFraudDetailsUserReport,
595}
596impl UpdateChargeFraudDetails {
597 pub fn new(user_report: impl Into<UpdateChargeFraudDetailsUserReport>) -> Self {
598 Self { user_report: user_report.into() }
599 }
600}
601#[derive(Copy, Clone, Eq, PartialEq)]
603pub enum UpdateChargeFraudDetailsUserReport {
604 Fraudulent,
605 Safe,
606}
607impl UpdateChargeFraudDetailsUserReport {
608 pub fn as_str(self) -> &'static str {
609 use UpdateChargeFraudDetailsUserReport::*;
610 match self {
611 Fraudulent => "fraudulent",
612 Safe => "safe",
613 }
614 }
615}
616
617impl std::str::FromStr for UpdateChargeFraudDetailsUserReport {
618 type Err = stripe_types::StripeParseError;
619 fn from_str(s: &str) -> Result<Self, Self::Err> {
620 use UpdateChargeFraudDetailsUserReport::*;
621 match s {
622 "fraudulent" => Ok(Fraudulent),
623 "safe" => Ok(Safe),
624 _ => Err(stripe_types::StripeParseError),
625 }
626 }
627}
628impl std::fmt::Display for UpdateChargeFraudDetailsUserReport {
629 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
630 f.write_str(self.as_str())
631 }
632}
633
634impl std::fmt::Debug for UpdateChargeFraudDetailsUserReport {
635 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
636 f.write_str(self.as_str())
637 }
638}
639impl serde::Serialize for UpdateChargeFraudDetailsUserReport {
640 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
641 where
642 S: serde::Serializer,
643 {
644 serializer.serialize_str(self.as_str())
645 }
646}
647#[cfg(feature = "deserialize")]
648impl<'de> serde::Deserialize<'de> for UpdateChargeFraudDetailsUserReport {
649 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
650 use std::str::FromStr;
651 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
652 Self::from_str(&s).map_err(|_| {
653 serde::de::Error::custom("Unknown value for UpdateChargeFraudDetailsUserReport")
654 })
655 }
656}
657#[derive(Clone, Debug, serde::Serialize)]
660pub struct UpdateCharge {
661 inner: UpdateChargeBuilder,
662 charge: stripe_shared::ChargeId,
663}
664impl UpdateCharge {
665 pub fn new(charge: impl Into<stripe_shared::ChargeId>) -> Self {
667 Self { charge: charge.into(), inner: UpdateChargeBuilder::new() }
668 }
669 pub fn customer(mut self, customer: impl Into<String>) -> Self {
672 self.inner.customer = Some(customer.into());
673 self
674 }
675 pub fn description(mut self, description: impl Into<String>) -> Self {
679 self.inner.description = Some(description.into());
680 self
681 }
682 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
684 self.inner.expand = Some(expand.into());
685 self
686 }
687 pub fn fraud_details(mut self, fraud_details: impl Into<UpdateChargeFraudDetails>) -> Self {
692 self.inner.fraud_details = Some(fraud_details.into());
693 self
694 }
695 pub fn metadata(
700 mut self,
701 metadata: impl Into<std::collections::HashMap<String, String>>,
702 ) -> Self {
703 self.inner.metadata = Some(metadata.into());
704 self
705 }
706 pub fn receipt_email(mut self, receipt_email: impl Into<String>) -> Self {
709 self.inner.receipt_email = Some(receipt_email.into());
710 self
711 }
712 pub fn shipping(mut self, shipping: impl Into<OptionalFieldsShipping>) -> Self {
714 self.inner.shipping = Some(shipping.into());
715 self
716 }
717 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
721 self.inner.transfer_group = Some(transfer_group.into());
722 self
723 }
724}
725impl UpdateCharge {
726 pub async fn send<C: StripeClient>(
728 &self,
729 client: &C,
730 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
731 self.customize().send(client).await
732 }
733
734 pub fn send_blocking<C: StripeBlockingClient>(
736 &self,
737 client: &C,
738 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
739 self.customize().send_blocking(client)
740 }
741}
742
743impl StripeRequest for UpdateCharge {
744 type Output = stripe_shared::Charge;
745
746 fn build(&self) -> RequestBuilder {
747 let charge = &self.charge;
748 RequestBuilder::new(StripeMethod::Post, format!("/charges/{charge}")).form(&self.inner)
749 }
750}
751#[derive(Clone, Debug, serde::Serialize)]
752struct CaptureChargeBuilder {
753 #[serde(skip_serializing_if = "Option::is_none")]
754 amount: Option<i64>,
755 #[serde(skip_serializing_if = "Option::is_none")]
756 application_fee: Option<i64>,
757 #[serde(skip_serializing_if = "Option::is_none")]
758 application_fee_amount: Option<i64>,
759 #[serde(skip_serializing_if = "Option::is_none")]
760 expand: Option<Vec<String>>,
761 #[serde(skip_serializing_if = "Option::is_none")]
762 receipt_email: Option<String>,
763 #[serde(skip_serializing_if = "Option::is_none")]
764 statement_descriptor: Option<String>,
765 #[serde(skip_serializing_if = "Option::is_none")]
766 statement_descriptor_suffix: Option<String>,
767 #[serde(skip_serializing_if = "Option::is_none")]
768 transfer_data: Option<CaptureChargeTransferData>,
769 #[serde(skip_serializing_if = "Option::is_none")]
770 transfer_group: Option<String>,
771}
772impl CaptureChargeBuilder {
773 fn new() -> Self {
774 Self {
775 amount: None,
776 application_fee: None,
777 application_fee_amount: None,
778 expand: None,
779 receipt_email: None,
780 statement_descriptor: None,
781 statement_descriptor_suffix: None,
782 transfer_data: None,
783 transfer_group: None,
784 }
785 }
786}
787#[derive(Copy, Clone, Debug, serde::Serialize)]
790pub struct CaptureChargeTransferData {
791 #[serde(skip_serializing_if = "Option::is_none")]
794 pub amount: Option<i64>,
795}
796impl CaptureChargeTransferData {
797 pub fn new() -> Self {
798 Self { amount: None }
799 }
800}
801impl Default for CaptureChargeTransferData {
802 fn default() -> Self {
803 Self::new()
804 }
805}
806#[derive(Clone, Debug, serde::Serialize)]
813pub struct CaptureCharge {
814 inner: CaptureChargeBuilder,
815 charge: stripe_shared::ChargeId,
816}
817impl CaptureCharge {
818 pub fn new(charge: impl Into<stripe_shared::ChargeId>) -> Self {
820 Self { charge: charge.into(), inner: CaptureChargeBuilder::new() }
821 }
822 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
824 self.inner.amount = Some(amount.into());
825 self
826 }
827 pub fn application_fee(mut self, application_fee: impl Into<i64>) -> Self {
829 self.inner.application_fee = Some(application_fee.into());
830 self
831 }
832 pub fn application_fee_amount(mut self, application_fee_amount: impl Into<i64>) -> Self {
834 self.inner.application_fee_amount = Some(application_fee_amount.into());
835 self
836 }
837 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
839 self.inner.expand = Some(expand.into());
840 self
841 }
842 pub fn receipt_email(mut self, receipt_email: impl Into<String>) -> Self {
846 self.inner.receipt_email = Some(receipt_email.into());
847 self
848 }
849 pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
855 self.inner.statement_descriptor = Some(statement_descriptor.into());
856 self
857 }
858 pub fn statement_descriptor_suffix(
862 mut self,
863 statement_descriptor_suffix: impl Into<String>,
864 ) -> Self {
865 self.inner.statement_descriptor_suffix = Some(statement_descriptor_suffix.into());
866 self
867 }
868 pub fn transfer_data(mut self, transfer_data: impl Into<CaptureChargeTransferData>) -> Self {
871 self.inner.transfer_data = Some(transfer_data.into());
872 self
873 }
874 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
878 self.inner.transfer_group = Some(transfer_group.into());
879 self
880 }
881}
882impl CaptureCharge {
883 pub async fn send<C: StripeClient>(
885 &self,
886 client: &C,
887 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
888 self.customize().send(client).await
889 }
890
891 pub fn send_blocking<C: StripeBlockingClient>(
893 &self,
894 client: &C,
895 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
896 self.customize().send_blocking(client)
897 }
898}
899
900impl StripeRequest for CaptureCharge {
901 type Output = stripe_shared::Charge;
902
903 fn build(&self) -> RequestBuilder {
904 let charge = &self.charge;
905 RequestBuilder::new(StripeMethod::Post, format!("/charges/{charge}/capture"))
906 .form(&self.inner)
907 }
908}
909
910#[derive(Clone, Debug, serde::Serialize)]
911pub struct OptionalFieldsAddress {
912 #[serde(skip_serializing_if = "Option::is_none")]
914 pub city: Option<String>,
915 #[serde(skip_serializing_if = "Option::is_none")]
917 pub country: Option<String>,
918 #[serde(skip_serializing_if = "Option::is_none")]
920 pub line1: Option<String>,
921 #[serde(skip_serializing_if = "Option::is_none")]
923 pub line2: Option<String>,
924 #[serde(skip_serializing_if = "Option::is_none")]
926 pub postal_code: Option<String>,
927 #[serde(skip_serializing_if = "Option::is_none")]
929 pub state: Option<String>,
930}
931impl OptionalFieldsAddress {
932 pub fn new() -> Self {
933 Self { city: None, country: None, line1: None, line2: None, postal_code: None, state: None }
934 }
935}
936impl Default for OptionalFieldsAddress {
937 fn default() -> Self {
938 Self::new()
939 }
940}
941#[derive(Clone, Debug, serde::Serialize)]
942pub struct OptionalFieldsShipping {
943 pub address: OptionalFieldsAddress,
945 #[serde(skip_serializing_if = "Option::is_none")]
947 pub carrier: Option<String>,
948 pub name: String,
950 #[serde(skip_serializing_if = "Option::is_none")]
952 pub phone: Option<String>,
953 #[serde(skip_serializing_if = "Option::is_none")]
956 pub tracking_number: Option<String>,
957}
958impl OptionalFieldsShipping {
959 pub fn new(address: impl Into<OptionalFieldsAddress>, name: impl Into<String>) -> Self {
960 Self {
961 address: address.into(),
962 carrier: None,
963 name: name.into(),
964 phone: None,
965 tracking_number: None,
966 }
967 }
968}