1use payjp_client_core::{PayjpClient, BlockingClient, PayjpRequest, RequestBuilder, PayjpMethod};
2
3#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
4 struct ListChargeBuilder {
5#[serde(skip_serializing_if = "Option::is_none")]
6 limit: Option<i64>,
7#[serde(skip_serializing_if = "Option::is_none")]
8 offset: Option<i64>,
9#[serde(skip_serializing_if = "Option::is_none")]
10 since: Option<i64>,
11#[serde(skip_serializing_if = "Option::is_none")]
12 until: Option<i64>,
13#[serde(skip_serializing_if = "Option::is_none")]
14 customer: Option<String>,
15#[serde(skip_serializing_if = "Option::is_none")]
16 subscription: Option<String>,
17#[serde(skip_serializing_if = "Option::is_none")]
18 tenant: Option<String>,
19#[serde(skip_serializing_if = "Option::is_none")]
20 term: Option<String>,
21
22}
23impl ListChargeBuilder {
24 fn new() -> Self {
25 Self {
26 limit: None,offset: None,since: None,until: None,customer: None,subscription: None,tenant: None,term: None,
27 }
28}
29
30}
31 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
33pub struct ListCharge {
34 inner: ListChargeBuilder,
35
36}
37impl ListCharge {
38 pub fn new() -> Self {
40 Self {
41 inner: ListChargeBuilder::new()
42 }
43}
44 pub fn limit(mut self, limit: impl Into<i64>) -> Self {
46 self.inner.limit = Some(limit.into());
47 self
48}
49 pub fn offset(mut self, offset: impl Into<i64>) -> Self {
51 self.inner.offset = Some(offset.into());
52 self
53}
54 pub fn since(mut self, since: impl Into<i64>) -> Self {
56 self.inner.since = Some(since.into());
57 self
58}
59 pub fn until(mut self, until: impl Into<i64>) -> Self {
61 self.inner.until = Some(until.into());
62 self
63}
64 pub fn customer(mut self, customer: impl Into<String>) -> Self {
66 self.inner.customer = Some(customer.into());
67 self
68}
69 pub fn subscription(mut self, subscription: impl Into<String>) -> Self {
71 self.inner.subscription = Some(subscription.into());
72 self
73}
74 pub fn tenant(mut self, tenant: impl Into<String>) -> Self {
78 self.inner.tenant = Some(tenant.into());
79 self
80}
81 pub fn term(mut self, term: impl Into<String>) -> Self {
85 self.inner.term = Some(term.into());
86 self
87}
88
89}
90 impl Default for ListCharge {
91 fn default() -> Self {
92 Self::new()
93 }
94}impl ListCharge {
95 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
97 self.customize().send(client).await
98 }
99
100 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
102 self.customize().send_blocking(client)
103 }
104
105 pub fn paginate(&self) -> payjp_client_core::ListPaginator<payjp_types::List<payjp_core::Charge>> {
106
107 payjp_client_core::ListPaginator::new_list("/charges", &self.inner)
108}
109
110}
111
112impl PayjpRequest for ListCharge {
113 type Output = payjp_types::List<payjp_core::Charge>;
114
115 fn build(&self) -> RequestBuilder {
116 RequestBuilder::new(PayjpMethod::Get, "/charges").query(&self.inner)
117}
118
119}
120#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
121 struct CreateChargeBuilder {
122#[serde(skip_serializing_if = "Option::is_none")]
123 amount: Option<i64>,
124#[serde(skip_serializing_if = "Option::is_none")]
125 capture: Option<bool>,
126#[serde(skip_serializing_if = "Option::is_none")]
127 card: Option<String>,
128#[serde(skip_serializing_if = "Option::is_none")]
129 currency: Option<String>,
130#[serde(skip_serializing_if = "Option::is_none")]
131 customer: Option<String>,
132#[serde(skip_serializing_if = "Option::is_none")]
133 description: Option<String>,
134#[serde(skip_serializing_if = "Option::is_none")]
135 expiry_days: Option<u32>,
136#[serde(skip_serializing_if = "Option::is_none")]
137#[serde(with = "payjp_types::with_serde_json_opt")]
138 metadata: Option<miniserde::json::Value>,
139#[serde(skip_serializing_if = "Option::is_none")]
140 platform_fee: Option<i64>,
141#[serde(skip_serializing_if = "Option::is_none")]
142 product: Option<String>,
143#[serde(skip_serializing_if = "Option::is_none")]
144 tenant: Option<String>,
145#[serde(skip_serializing_if = "Option::is_none")]
146 three_d_secure: Option<bool>,
147
148}
149impl CreateChargeBuilder {
150 fn new() -> Self {
151 Self {
152 amount: None,capture: None,card: None,currency: None,customer: None,description: None,expiry_days: None,metadata: None,platform_fee: None,product: None,tenant: None,three_d_secure: None,
153 }
154}
155
156}
157 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
170pub struct CreateCharge {
171 inner: CreateChargeBuilder,
172
173}
174impl CreateCharge {
175 pub fn new() -> Self {
177 Self {
178 inner: CreateChargeBuilder::new()
179 }
180}
181 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
183 self.inner.amount = Some(amount.into());
184 self
185}
186 pub fn capture(mut self, capture: impl Into<bool>) -> Self {
188 self.inner.capture = Some(capture.into());
189 self
190}
191 pub fn card(mut self, card: impl Into<String>) -> Self {
193 self.inner.card = Some(card.into());
194 self
195}
196 pub fn currency(mut self, currency: impl Into<String>) -> Self {
198 self.inner.currency = Some(currency.into());
199 self
200}
201 pub fn customer(mut self, customer: impl Into<String>) -> Self {
203 self.inner.customer = Some(customer.into());
204 self
205}
206 pub fn description(mut self, description: impl Into<String>) -> Self {
208 self.inner.description = Some(description.into());
209 self
210}
211 pub fn expiry_days(mut self, expiry_days: impl Into<u32>) -> Self {
213 self.inner.expiry_days = Some(expiry_days.into());
214 self
215}
216 pub fn metadata(mut self, metadata: impl Into<miniserde::json::Value>) -> Self {
218 self.inner.metadata = Some(metadata.into());
219 self
220}
221 pub fn platform_fee(mut self, platform_fee: impl Into<i64>) -> Self {
225 self.inner.platform_fee = Some(platform_fee.into());
226 self
227}
228 pub fn product(mut self, product: impl Into<String>) -> Self {
230 self.inner.product = Some(product.into());
231 self
232}
233 pub fn tenant(mut self, tenant: impl Into<String>) -> Self {
237 self.inner.tenant = Some(tenant.into());
238 self
239}
240 pub fn three_d_secure(mut self, three_d_secure: impl Into<bool>) -> Self {
242 self.inner.three_d_secure = Some(three_d_secure.into());
243 self
244}
245
246}
247 impl Default for CreateCharge {
248 fn default() -> Self {
249 Self::new()
250 }
251}impl CreateCharge {
252 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
254 self.customize().send(client).await
255 }
256
257 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
259 self.customize().send_blocking(client)
260 }
261
262
263}
264
265impl PayjpRequest for CreateCharge {
266 type Output = payjp_core::Charge;
267
268 fn build(&self) -> RequestBuilder {
269 RequestBuilder::new(PayjpMethod::Post, "/charges").form(&self.inner)
270}
271
272}
273 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
275pub struct RetrieveCharge {
276 charge: payjp_core::ChargeId,
277
278}
279impl RetrieveCharge {
280 pub fn new(charge:impl Into<payjp_core::ChargeId>) -> Self {
282 Self {
283 charge: charge.into(),
284 }
285}
286
287}
288 impl RetrieveCharge {
289 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
291 self.customize().send(client).await
292 }
293
294 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
296 self.customize().send_blocking(client)
297 }
298
299
300}
301
302impl PayjpRequest for RetrieveCharge {
303 type Output = payjp_core::Charge;
304
305 fn build(&self) -> RequestBuilder {
306 let charge = &self.charge;
307RequestBuilder::new(PayjpMethod::Get, format!("/charges/{charge}"))
308}
309
310}
311#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
312 struct UpdateChargeBuilder {
313#[serde(skip_serializing_if = "Option::is_none")]
314 description: Option<String>,
315#[serde(skip_serializing_if = "Option::is_none")]
316#[serde(with = "payjp_types::with_serde_json_opt")]
317 metadata: Option<miniserde::json::Value>,
318
319}
320impl UpdateChargeBuilder {
321 fn new() -> Self {
322 Self {
323 description: None,metadata: None,
324 }
325}
326
327}
328 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
330pub struct UpdateCharge {
331 inner: UpdateChargeBuilder,
332 charge: payjp_core::ChargeId,
333
334}
335impl UpdateCharge {
336 pub fn new(charge:impl Into<payjp_core::ChargeId>) -> Self {
338 Self {
339 charge: charge.into(),inner: UpdateChargeBuilder::new()
340 }
341}
342 pub fn description(mut self, description: impl Into<String>) -> Self {
344 self.inner.description = Some(description.into());
345 self
346}
347 pub fn metadata(mut self, metadata: impl Into<miniserde::json::Value>) -> Self {
349 self.inner.metadata = Some(metadata.into());
350 self
351}
352
353}
354 impl UpdateCharge {
355 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
357 self.customize().send(client).await
358 }
359
360 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
362 self.customize().send_blocking(client)
363 }
364
365
366}
367
368impl PayjpRequest for UpdateCharge {
369 type Output = payjp_core::Charge;
370
371 fn build(&self) -> RequestBuilder {
372 let charge = &self.charge;
373RequestBuilder::new(PayjpMethod::Post, format!("/charges/{charge}")).form(&self.inner)
374}
375
376}
377 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
383pub struct TdsFinishCharge {
384 charge: payjp_core::ChargeId,
385
386}
387impl TdsFinishCharge {
388 pub fn new(charge:impl Into<payjp_core::ChargeId>) -> Self {
390 Self {
391 charge: charge.into(),
392 }
393}
394
395}
396 impl TdsFinishCharge {
397 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
399 self.customize().send(client).await
400 }
401
402 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
404 self.customize().send_blocking(client)
405 }
406
407
408}
409
410impl PayjpRequest for TdsFinishCharge {
411 type Output = payjp_core::Charge;
412
413 fn build(&self) -> RequestBuilder {
414 let charge = &self.charge;
415RequestBuilder::new(PayjpMethod::Post, format!("/charges/{charge}/tds_finish"))
416}
417
418}
419#[derive(Clone,Debug,)]#[derive(serde::Serialize)]
420 struct RefundChargeBuilder {
421 amount: i64,
422#[serde(skip_serializing_if = "Option::is_none")]
423 refund_reason: Option<String>,
424
425}
426impl RefundChargeBuilder {
427 fn new(amount: impl Into<i64>,) -> Self {
428 Self {
429 amount: amount.into(),refund_reason: None,
430 }
431}
432
433}
434 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
438pub struct RefundCharge {
439 inner: RefundChargeBuilder,
440 charge: payjp_core::ChargeId,
441
442}
443impl RefundCharge {
444 pub fn new(charge:impl Into<payjp_core::ChargeId>,amount:impl Into<i64>) -> Self {
446 Self {
447 charge: charge.into(),inner: RefundChargeBuilder::new(amount.into(),)
448 }
449}
450 pub fn refund_reason(mut self, refund_reason: impl Into<String>) -> Self {
452 self.inner.refund_reason = Some(refund_reason.into());
453 self
454}
455
456}
457 impl RefundCharge {
458 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
460 self.customize().send(client).await
461 }
462
463 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
465 self.customize().send_blocking(client)
466 }
467
468
469}
470
471impl PayjpRequest for RefundCharge {
472 type Output = payjp_core::Charge;
473
474 fn build(&self) -> RequestBuilder {
475 let charge = &self.charge;
476RequestBuilder::new(PayjpMethod::Post, format!("/charges/{charge}/refund")).form(&self.inner)
477}
478
479}
480#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
481 struct ReauthChargeBuilder {
482#[serde(skip_serializing_if = "Option::is_none")]
483 expiry_days: Option<u32>,
484
485}
486impl ReauthChargeBuilder {
487 fn new() -> Self {
488 Self {
489 expiry_days: None,
490 }
491}
492
493}
494 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
503pub struct ReauthCharge {
504 inner: ReauthChargeBuilder,
505 charge: payjp_core::ChargeId,
506
507}
508impl ReauthCharge {
509 pub fn new(charge:impl Into<payjp_core::ChargeId>) -> Self {
511 Self {
512 charge: charge.into(),inner: ReauthChargeBuilder::new()
513 }
514}
515 pub fn expiry_days(mut self, expiry_days: impl Into<u32>) -> Self {
517 self.inner.expiry_days = Some(expiry_days.into());
518 self
519}
520
521}
522 impl ReauthCharge {
523 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
525 self.customize().send(client).await
526 }
527
528 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
530 self.customize().send_blocking(client)
531 }
532
533
534}
535
536impl PayjpRequest for ReauthCharge {
537 type Output = payjp_core::Charge;
538
539 fn build(&self) -> RequestBuilder {
540 let charge = &self.charge;
541RequestBuilder::new(PayjpMethod::Post, format!("/charges/{charge}/reauth")).form(&self.inner)
542}
543
544}
545#[derive(Copy,Clone,Debug,)]#[derive(serde::Serialize)]
546 struct CaptureChargeBuilder {
547#[serde(skip_serializing_if = "Option::is_none")]
548 amount: Option<i64>,
549
550}
551impl CaptureChargeBuilder {
552 fn new() -> Self {
553 Self {
554 amount: None,
555 }
556}
557
558}
559 #[derive(Clone,Debug,)]#[derive(serde::Serialize)]
561pub struct CaptureCharge {
562 inner: CaptureChargeBuilder,
563 charge: payjp_core::ChargeId,
564
565}
566impl CaptureCharge {
567 pub fn new(charge:impl Into<payjp_core::ChargeId>) -> Self {
569 Self {
570 charge: charge.into(),inner: CaptureChargeBuilder::new()
571 }
572}
573 pub fn amount(mut self, amount: impl Into<i64>) -> Self {
581 self.inner.amount = Some(amount.into());
582 self
583}
584
585}
586 impl CaptureCharge {
587 pub async fn send<C: PayjpClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
589 self.customize().send(client).await
590 }
591
592 pub fn send_blocking<C: BlockingClient>(&self, client: &C) -> Result<<Self as PayjpRequest>::Output, C::Err> {
594 self.customize().send_blocking(client)
595 }
596
597
598}
599
600impl PayjpRequest for CaptureCharge {
601 type Output = payjp_core::Charge;
602
603 fn build(&self) -> RequestBuilder {
604 let charge = &self.charge;
605RequestBuilder::new(PayjpMethod::Post, format!("/charges/{charge}/capture")).form(&self.inner)
606}
607
608}
609