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(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(Clone, Eq, PartialEq)]
603#[non_exhaustive]
604pub enum UpdateChargeFraudDetailsUserReport {
605 Fraudulent,
606 Safe,
607 Unknown(String),
609}
610impl UpdateChargeFraudDetailsUserReport {
611 pub fn as_str(&self) -> &str {
612 use UpdateChargeFraudDetailsUserReport::*;
613 match self {
614 Fraudulent => "fraudulent",
615 Safe => "safe",
616 Unknown(v) => v,
617 }
618 }
619}
620
621impl std::str::FromStr for UpdateChargeFraudDetailsUserReport {
622 type Err = std::convert::Infallible;
623 fn from_str(s: &str) -> Result<Self, Self::Err> {
624 use UpdateChargeFraudDetailsUserReport::*;
625 match s {
626 "fraudulent" => Ok(Fraudulent),
627 "safe" => Ok(Safe),
628 v => {
629 tracing::warn!(
630 "Unknown value '{}' for enum '{}'",
631 v,
632 "UpdateChargeFraudDetailsUserReport"
633 );
634 Ok(Unknown(v.to_owned()))
635 }
636 }
637 }
638}
639impl std::fmt::Display for UpdateChargeFraudDetailsUserReport {
640 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
641 f.write_str(self.as_str())
642 }
643}
644
645impl std::fmt::Debug for UpdateChargeFraudDetailsUserReport {
646 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
647 f.write_str(self.as_str())
648 }
649}
650impl serde::Serialize for UpdateChargeFraudDetailsUserReport {
651 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
652 where
653 S: serde::Serializer,
654 {
655 serializer.serialize_str(self.as_str())
656 }
657}
658#[cfg(feature = "deserialize")]
659impl<'de> serde::Deserialize<'de> for UpdateChargeFraudDetailsUserReport {
660 fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
661 use std::str::FromStr;
662 let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
663 Ok(Self::from_str(&s).expect("infallible"))
664 }
665}
666#[derive(Clone, Debug, serde::Serialize)]
669pub struct UpdateCharge {
670 inner: UpdateChargeBuilder,
671 charge: stripe_shared::ChargeId,
672}
673impl UpdateCharge {
674 pub fn new(charge: impl Into<stripe_shared::ChargeId>) -> Self {
676 Self { charge: charge.into(), inner: UpdateChargeBuilder::new() }
677 }
678 pub fn customer(mut self, customer: impl Into<String>) -> Self {
681 self.inner.customer = Some(customer.into());
682 self
683 }
684 pub fn description(mut self, description: impl Into<String>) -> Self {
688 self.inner.description = Some(description.into());
689 self
690 }
691 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
693 self.inner.expand = Some(expand.into());
694 self
695 }
696 pub fn fraud_details(mut self, fraud_details: impl Into<UpdateChargeFraudDetails>) -> Self {
701 self.inner.fraud_details = Some(fraud_details.into());
702 self
703 }
704 pub fn metadata(
709 mut self,
710 metadata: impl Into<std::collections::HashMap<String, String>>,
711 ) -> Self {
712 self.inner.metadata = Some(metadata.into());
713 self
714 }
715 pub fn receipt_email(mut self, receipt_email: impl Into<String>) -> Self {
718 self.inner.receipt_email = Some(receipt_email.into());
719 self
720 }
721 pub fn shipping(mut self, shipping: impl Into<OptionalFieldsShipping>) -> Self {
723 self.inner.shipping = Some(shipping.into());
724 self
725 }
726 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
730 self.inner.transfer_group = Some(transfer_group.into());
731 self
732 }
733}
734impl UpdateCharge {
735 pub async fn send<C: StripeClient>(
737 &self,
738 client: &C,
739 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
740 self.customize().send(client).await
741 }
742
743 pub fn send_blocking<C: StripeBlockingClient>(
745 &self,
746 client: &C,
747 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
748 self.customize().send_blocking(client)
749 }
750}
751
752impl StripeRequest for UpdateCharge {
753 type Output = stripe_shared::Charge;
754
755 fn build(&self) -> RequestBuilder {
756 let charge = &self.charge;
757 RequestBuilder::new(StripeMethod::Post, format!("/charges/{charge}")).form(&self.inner)
758 }
759}
760#[derive(Clone, Debug, serde::Serialize)]
761struct CaptureChargeBuilder {
762 #[serde(skip_serializing_if = "Option::is_none")]
763 amount: Option<i64>,
764 #[serde(skip_serializing_if = "Option::is_none")]
765 application_fee: Option<i64>,
766 #[serde(skip_serializing_if = "Option::is_none")]
767 application_fee_amount: Option<i64>,
768 #[serde(skip_serializing_if = "Option::is_none")]
769 expand: Option<Vec<String>>,
770 #[serde(skip_serializing_if = "Option::is_none")]
771 receipt_email: Option<String>,
772 #[serde(skip_serializing_if = "Option::is_none")]
773 statement_descriptor: Option<String>,
774 #[serde(skip_serializing_if = "Option::is_none")]
775 statement_descriptor_suffix: Option<String>,
776 #[serde(skip_serializing_if = "Option::is_none")]
777 transfer_data: Option<CaptureChargeTransferData>,
778 #[serde(skip_serializing_if = "Option::is_none")]
779 transfer_group: Option<String>,
780}
781impl CaptureChargeBuilder {
782 fn new() -> Self {
783 Self {
784 amount: None,
785 application_fee: None,
786 application_fee_amount: None,
787 expand: None,
788 receipt_email: None,
789 statement_descriptor: None,
790 statement_descriptor_suffix: None,
791 transfer_data: None,
792 transfer_group: None,
793 }
794 }
795}
796#[derive(Copy, Clone, Debug, serde::Serialize)]
799pub struct CaptureChargeTransferData {
800 #[serde(skip_serializing_if = "Option::is_none")]
803 pub amount: Option<i64>,
804}
805impl CaptureChargeTransferData {
806 pub fn new() -> Self {
807 Self { amount: None }
808 }
809}
810impl Default for CaptureChargeTransferData {
811 fn default() -> Self {
812 Self::new()
813 }
814}
815#[derive(Clone, Debug, serde::Serialize)]
822pub struct CaptureCharge {
823 inner: CaptureChargeBuilder,
824 charge: stripe_shared::ChargeId,
825}
826impl CaptureCharge {
827 pub fn new(charge: impl Into<stripe_shared::ChargeId>) -> Self {
829 Self { charge: charge.into(), inner: CaptureChargeBuilder::new() }
830 }
831 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
833 self.inner.amount = Some(amount.into());
834 self
835 }
836 pub fn application_fee(mut self, application_fee: impl Into<i64>) -> Self {
838 self.inner.application_fee = Some(application_fee.into());
839 self
840 }
841 pub fn application_fee_amount(mut self, application_fee_amount: impl Into<i64>) -> Self {
843 self.inner.application_fee_amount = Some(application_fee_amount.into());
844 self
845 }
846 pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
848 self.inner.expand = Some(expand.into());
849 self
850 }
851 pub fn receipt_email(mut self, receipt_email: impl Into<String>) -> Self {
855 self.inner.receipt_email = Some(receipt_email.into());
856 self
857 }
858 pub fn statement_descriptor(mut self, statement_descriptor: impl Into<String>) -> Self {
864 self.inner.statement_descriptor = Some(statement_descriptor.into());
865 self
866 }
867 pub fn statement_descriptor_suffix(
871 mut self,
872 statement_descriptor_suffix: impl Into<String>,
873 ) -> Self {
874 self.inner.statement_descriptor_suffix = Some(statement_descriptor_suffix.into());
875 self
876 }
877 pub fn transfer_data(mut self, transfer_data: impl Into<CaptureChargeTransferData>) -> Self {
880 self.inner.transfer_data = Some(transfer_data.into());
881 self
882 }
883 pub fn transfer_group(mut self, transfer_group: impl Into<String>) -> Self {
887 self.inner.transfer_group = Some(transfer_group.into());
888 self
889 }
890}
891impl CaptureCharge {
892 pub async fn send<C: StripeClient>(
894 &self,
895 client: &C,
896 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
897 self.customize().send(client).await
898 }
899
900 pub fn send_blocking<C: StripeBlockingClient>(
902 &self,
903 client: &C,
904 ) -> Result<<Self as StripeRequest>::Output, C::Err> {
905 self.customize().send_blocking(client)
906 }
907}
908
909impl StripeRequest for CaptureCharge {
910 type Output = stripe_shared::Charge;
911
912 fn build(&self) -> RequestBuilder {
913 let charge = &self.charge;
914 RequestBuilder::new(StripeMethod::Post, format!("/charges/{charge}/capture"))
915 .form(&self.inner)
916 }
917}
918
919#[derive(Clone, Debug, serde::Serialize)]
920pub struct OptionalFieldsAddress {
921 #[serde(skip_serializing_if = "Option::is_none")]
923 pub city: Option<String>,
924 #[serde(skip_serializing_if = "Option::is_none")]
926 pub country: Option<String>,
927 #[serde(skip_serializing_if = "Option::is_none")]
929 pub line1: Option<String>,
930 #[serde(skip_serializing_if = "Option::is_none")]
932 pub line2: Option<String>,
933 #[serde(skip_serializing_if = "Option::is_none")]
935 pub postal_code: Option<String>,
936 #[serde(skip_serializing_if = "Option::is_none")]
938 pub state: Option<String>,
939}
940impl OptionalFieldsAddress {
941 pub fn new() -> Self {
942 Self { city: None, country: None, line1: None, line2: None, postal_code: None, state: None }
943 }
944}
945impl Default for OptionalFieldsAddress {
946 fn default() -> Self {
947 Self::new()
948 }
949}
950#[derive(Clone, Debug, serde::Serialize)]
951pub struct OptionalFieldsShipping {
952 pub address: OptionalFieldsAddress,
954 #[serde(skip_serializing_if = "Option::is_none")]
956 pub carrier: Option<String>,
957 pub name: String,
959 #[serde(skip_serializing_if = "Option::is_none")]
961 pub phone: Option<String>,
962 #[serde(skip_serializing_if = "Option::is_none")]
965 pub tracking_number: Option<String>,
966}
967impl OptionalFieldsShipping {
968 pub fn new(address: impl Into<OptionalFieldsAddress>, name: impl Into<String>) -> Self {
969 Self {
970 address: address.into(),
971 carrier: None,
972 name: name.into(),
973 phone: None,
974 tracking_number: None,
975 }
976 }
977}