1use std::fmt;
2
3use bigdecimal::BigDecimal;
4use log::debug;
5
6use crate::client::HttpClient;
7use crate::model::PaymentItem;
8use crate::options::Options;
9use crate::requests::CreateApmInitializeRequest;
10use crate::requests::CreateApprovalRequest;
11use crate::requests::CreateSubMerchantRequest;
12use crate::requests::PKISerialize;
13use crate::requests::RetrieveApmRequest;
14use crate::requests::RetrieveSubMerchantRequest;
15use crate::requests::RetrieveTransactionsRequest;
16use crate::requests::UpdateSubMerchantRequest;
17use crate::resource::IyzipayResource;
18use crate::types::Result;
19
20#[derive(Debug, Default, Serialize, Deserialize)]
21#[serde(rename_all = "camelCase")]
22#[serde(default)]
23pub struct SubMerchant {
24 #[serde(flatten)]
25 resource: IyzipayResource,
26
27 name: Option<String>,
28
29 email: Option<String>,
30
31 gsm_number: Option<String>,
32
33 address: Option<String>,
34
35 iban: Option<String>,
36
37 tax_office: Option<String>,
38
39 contact_name: Option<String>,
40
41 contact_surname: Option<String>,
42
43 legal_company_title: Option<String>,
44
45 swift_code: Option<String>,
46
47 currency: Option<String>,
48
49 identity_number: Option<String>,
50
51 tax_number: Option<String>,
52
53 sub_merchant_external_id: Option<String>,
54
55 sub_merchant_type: Option<String>,
56
57 sub_merchant_key: Option<String>,
58}
59
60impl std::ops::Deref for SubMerchant {
61 type Target = IyzipayResource;
62 fn deref(&self) -> &Self::Target {
63 &self.resource
64 }
65}
66
67impl SubMerchant {
68 pub fn create(req: &CreateSubMerchantRequest, options: &Options) -> Result<SubMerchant> {
69 let request = serde_json::to_string(req)?;
70 debug!("RequestBody:{}", request);
71 let res = HttpClient::create().post(
72 format!("{}{}", options.base_url(), "/onboarding/submerchant").as_str(),
73 request,
74 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
75 )?;
76 let response = res.json()?;
77 Ok(response)
78 }
79
80 pub fn update(req: &UpdateSubMerchantRequest, options: &Options) -> Result<SubMerchant> {
81 let request = serde_json::to_string(req)?;
82 debug!("RequestBody:{}", request);
83 let res = HttpClient::create().put(
84 format!("{}{}", options.base_url(), "/onboarding/submerchant").as_str(),
85 request,
86 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
87 )?;
88 let response = res.json()?;
89 Ok(response)
90 }
91
92 pub fn retrieve(req: &RetrieveSubMerchantRequest, options: &Options) -> Result<SubMerchant> {
93 let request = serde_json::to_string(req)?;
94 debug!("RequestBody:{}", request);
95 let res = HttpClient::create().post(
96 format!("{}{}", options.base_url(), "/onboarding/submerchant/detail").as_str(),
97 request,
98 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
99 )?;
100 let response = res.json()?;
101 Ok(response)
102 }
103
104 pub fn set_name<T: Into<String>>(&mut self, name: T) {
105 self.name = Some(name.into());
106 }
107
108 pub fn set_email<T: Into<String>>(&mut self, email: T) {
109 self.email = Some(email.into());
110 }
111
112 pub fn set_gsm_number<T: Into<String>>(&mut self, gsm_number: T) {
113 self.gsm_number = Some(gsm_number.into());
114 }
115
116 pub fn set_address<T: Into<String>>(&mut self, address: T) {
117 self.address = Some(address.into());
118 }
119
120 pub fn set_iban<T: Into<String>>(&mut self, iban: T) {
121 self.iban = Some(iban.into());
122 }
123
124 pub fn set_tax_office<T: Into<String>>(&mut self, tax_office: T) {
125 self.tax_office = Some(tax_office.into());
126 }
127
128 pub fn set_contact_name<T: Into<String>>(&mut self, contact_name: T) {
129 self.contact_name = Some(contact_name.into());
130 }
131
132 pub fn set_contact_surname<T: Into<String>>(&mut self, contact_surname: T) {
133 self.contact_surname = Some(contact_surname.into());
134 }
135
136 pub fn set_legal_company_title<T: Into<String>>(&mut self, legal_company_title: T) {
137 self.legal_company_title = Some(legal_company_title.into());
138 }
139
140 pub fn set_swift_code<T: Into<String>>(&mut self, swift_code: T) {
141 self.swift_code = Some(swift_code.into());
142 }
143
144 pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
145 self.currency = Some(currency.into());
146 }
147
148 pub fn set_identity_number<T: Into<String>>(&mut self, identity_number: T) {
149 self.identity_number = Some(identity_number.into());
150 }
151
152 pub fn set_tax_number<T: Into<String>>(&mut self, tax_number: T) {
153 self.tax_number = Some(tax_number.into());
154 }
155
156 pub fn set_sub_merchant_external_id<T: Into<String>>(&mut self, sub_merchant_external_id: T) {
157 self.sub_merchant_external_id = Some(sub_merchant_external_id.into());
158 }
159
160 pub fn set_sub_merchant_type<T: Into<String>>(&mut self, sub_merchant_type: T) {
161 self.sub_merchant_type = Some(sub_merchant_type.into());
162 }
163
164 pub fn set_sub_merchant_key<T: Into<String>>(&mut self, sub_merchant_key: T) {
165 self.sub_merchant_key = Some(sub_merchant_key.into());
166 }
167
168 pub fn name(&self) -> Option<&String> {
169 self.name.as_ref()
170 }
171 pub fn email(&self) -> Option<&String> {
172 self.email.as_ref()
173 }
174 pub fn gsm_number(&self) -> Option<&String> {
175 self.gsm_number.as_ref()
176 }
177 pub fn address(&self) -> Option<&String> {
178 self.address.as_ref()
179 }
180 pub fn iban(&self) -> Option<&String> {
181 self.iban.as_ref()
182 }
183 pub fn tax_office(&self) -> Option<&String> {
184 self.tax_office.as_ref()
185 }
186 pub fn contact_name(&self) -> Option<&String> {
187 self.contact_name.as_ref()
188 }
189 pub fn contact_surname(&self) -> Option<&String> {
190 self.contact_surname.as_ref()
191 }
192 pub fn legal_company_title(&self) -> Option<&String> {
193 self.legal_company_title.as_ref()
194 }
195 pub fn swift_code(&self) -> Option<&String> {
196 self.swift_code.as_ref()
197 }
198 pub fn currency(&self) -> Option<&String> {
199 self.currency.as_ref()
200 }
201 pub fn identity_number(&self) -> Option<&String> {
202 self.identity_number.as_ref()
203 }
204 pub fn tax_number(&self) -> Option<&String> {
205 self.tax_number.as_ref()
206 }
207 pub fn sub_merchant_external_id(&self) -> Option<&String> {
208 self.sub_merchant_external_id.as_ref()
209 }
210 pub fn sub_merchant_type(&self) -> Option<&String> {
211 self.sub_merchant_type.as_ref()
212 }
213 pub fn sub_merchant_key(&self) -> Option<&String> {
214 self.sub_merchant_key.as_ref()
215 }
216}
217
218#[derive(Debug, Serialize, Deserialize, PartialEq)]
219#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
220pub enum SubMerchantType {
221 Personal,
222 PrivateCompany,
223 LimitedOrJointStockCompany,
224}
225
226impl SubMerchantType {
227 pub fn value(&self) -> &'static str {
228 match self {
229 SubMerchantType::Personal => "PERSONAL",
230 SubMerchantType::PrivateCompany => "PRIVATE_COMPANY",
231 SubMerchantType::LimitedOrJointStockCompany => "LIMITED_OR_JOINT_STOCK_COMPANY",
232 }
233 }
234}
235
236impl std::fmt::Display for SubMerchantType {
237 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
238 write!(f, "{}", self.value())
239 }
240}
241
242#[derive(Debug, Serialize, Deserialize)]
243#[serde(rename_all = "camelCase")]
244pub struct Approval {
245 #[serde(flatten)]
246 resource: IyzipayResource,
247
248 payment_transaction_id: Option<String>,
249}
250
251impl Approval {
252 pub fn create(req: &CreateApprovalRequest, options: &Options) -> Result<Approval> {
253 let request = serde_json::to_string(req)?;
254 debug!("RequestBody:{}", request);
255 let res = HttpClient::create().post(
256 format!("{}{}", options.base_url(), "/payment/iyzipos/item/approve").as_str(),
257 request,
258 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
259 )?;
260 let response = res.json()?;
261 Ok(response)
262 }
263
264 pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
265 self.payment_transaction_id = Some(payment_transaction_id.into());
266 }
267
268 pub fn payment_transaction_id(&self) -> Option<&String> {
269 self.payment_transaction_id.as_ref()
270 }
271}
272
273impl std::ops::Deref for Approval {
274 type Target = IyzipayResource;
275 fn deref(&self) -> &Self::Target {
276 &self.resource
277 }
278}
279
280#[derive(Debug, Serialize, Deserialize)]
281#[serde(rename_all = "camelCase")]
282pub struct Disapproval {
283 #[serde(flatten)]
284 resource: IyzipayResource,
285
286 payment_transaction_id: Option<String>,
287}
288
289impl Disapproval {
290 pub fn create(req: &CreateApprovalRequest, options: &Options) -> Result<Disapproval> {
291 let request = serde_json::to_string(req)?;
292 debug!("RequestBody:{}", request);
293 let res = HttpClient::create().post(
294 format!(
295 "{}{}",
296 options.base_url(),
297 "/payment/iyzipos/item/disapprove"
298 )
299 .as_str(),
300 request,
301 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
302 )?;
303 let response = res.json()?;
304 Ok(response)
305 }
306
307 pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
308 self.payment_transaction_id = Some(payment_transaction_id.into());
309 }
310
311 pub fn payment_transaction_id(&self) -> Option<&String> {
312 self.payment_transaction_id.as_ref()
313 }
314}
315
316impl std::ops::Deref for Disapproval {
317 type Target = IyzipayResource;
318 fn deref(&self) -> &Self::Target {
319 &self.resource
320 }
321}
322
323#[derive(Debug, Default, Serialize, Deserialize)]
324#[serde(rename_all = "camelCase")]
325#[serde(default)]
326pub struct PayoutCompletedTransactionList {
327 #[serde(flatten)]
328 resource: IyzipayResource,
329
330 payout_completed_transactions: Option<Vec<PayoutCompletedTransaction>>,
331}
332
333impl PayoutCompletedTransactionList {
334 pub fn retrieve(
335 req: &RetrieveTransactionsRequest,
336 options: &Options,
337 ) -> Result<PayoutCompletedTransactionList> {
338 let request = serde_json::to_string(req)?;
339 debug!("RequestBody:{}", request);
340 let res = HttpClient::create().post(
341 format!(
342 "{}{}",
343 options.base_url(),
344 "/reporting/settlement/payoutcompleted"
345 )
346 .as_str(),
347 request,
348 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
349 )?;
350 let response = res.json()?;
351 Ok(response)
352 }
353
354 pub fn set_payout_completed_transactions<T: Into<Vec<PayoutCompletedTransaction>>>(
355 &mut self,
356 payout_completed_transactions: T,
357 ) {
358 self.payout_completed_transactions = Some(payout_completed_transactions.into());
359 }
360
361 pub fn payout_completed_transactions(&self) -> Option<&Vec<PayoutCompletedTransaction>> {
362 self.payout_completed_transactions.as_ref()
363 }
364}
365
366impl std::ops::Deref for PayoutCompletedTransactionList {
367 type Target = IyzipayResource;
368 fn deref(&self) -> &Self::Target {
369 &self.resource
370 }
371}
372
373#[derive(Debug, Default, Serialize, Deserialize)]
374#[serde(rename_all = "camelCase")]
375#[serde(default)]
376pub struct PayoutCompletedTransaction {
377 payment_transaction_id: Option<String>,
378
379 payout_amount: Option<BigDecimal>,
380
381 payout_type: Option<String>,
382
383 sub_merchant_key: Option<String>,
384
385 currency: Option<String>,
386}
387
388impl PayoutCompletedTransaction {
389 pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
390 self.payment_transaction_id = Some(payment_transaction_id.into());
391 }
392
393 pub fn set_payout_amount<T: Into<BigDecimal>>(&mut self, payout_amount: T) {
394 self.payout_amount = Some(payout_amount.into());
395 }
396
397 pub fn set_payout_type<T: Into<String>>(&mut self, payout_type: T) {
398 self.payout_type = Some(payout_type.into());
399 }
400
401 pub fn set_sub_merchant_key<T: Into<String>>(&mut self, sub_merchant_key: T) {
402 self.sub_merchant_key = Some(sub_merchant_key.into());
403 }
404
405 pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
406 self.currency = Some(currency.into());
407 }
408
409 pub fn payment_transaction_id(&self) -> Option<&String> {
410 self.payment_transaction_id.as_ref()
411 }
412 pub fn payout_amount(&self) -> Option<&BigDecimal> {
413 self.payout_amount.as_ref()
414 }
415 pub fn payout_type(&self) -> Option<&String> {
416 self.payout_type.as_ref()
417 }
418 pub fn sub_merchant_key(&self) -> Option<&String> {
419 self.sub_merchant_key.as_ref()
420 }
421 pub fn currency(&self) -> Option<&String> {
422 self.currency.as_ref()
423 }
424}
425
426#[derive(Debug, Default, Serialize, Deserialize)]
427#[serde(rename_all = "camelCase")]
428#[serde(default)]
429pub struct BouncedBankTransferList {
430 #[serde(flatten)]
431 resource: IyzipayResource,
432
433 bank_transfers: Option<Vec<BankTransfer>>,
434}
435
436impl BouncedBankTransferList {
437 pub fn retrieve(
438 req: &RetrieveTransactionsRequest,
439 options: &Options,
440 ) -> Result<BouncedBankTransferList> {
441 let request = serde_json::to_string(req)?;
442 debug!("RequestBody:{}", request);
443 let res = HttpClient::create().post(
444 format!("{}{}", options.base_url(), "/reporting/settlement/bounced").as_str(),
445 request,
446 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
447 )?;
448 let response = res.json()?;
449 Ok(response)
450 }
451
452 pub fn set_bank_transfers<T: Into<Vec<BankTransfer>>>(&mut self, bank_transfers: T) {
453 self.bank_transfers = Some(bank_transfers.into());
454 }
455
456 pub fn bank_transfers(&self) -> Option<&Vec<BankTransfer>> {
457 self.bank_transfers.as_ref()
458 }
459}
460
461impl std::ops::Deref for BouncedBankTransferList {
462 type Target = IyzipayResource;
463 fn deref(&self) -> &Self::Target {
464 &self.resource
465 }
466}
467
468#[derive(Debug, Default, Serialize, Deserialize)]
469#[serde(rename_all = "camelCase")]
470#[serde(default)]
471pub struct BankTransfer {
472 sub_merchant_key: Option<String>,
473
474 iban: Option<String>,
475
476 contact_name: Option<String>,
477
478 contact_surname: Option<String>,
479
480 legal_company_title: Option<String>,
481
482 #[serde(rename = "marketplaceSubmerchantType")]
483 marketplace_sub_merchant_type: Option<String>,
484}
485
486impl BankTransfer {
487 pub fn set_sub_merchant_key<T: Into<String>>(&mut self, sub_merchant_key: T) {
488 self.sub_merchant_key = Some(sub_merchant_key.into());
489 }
490
491 pub fn set_iban<T: Into<String>>(&mut self, iban: T) {
492 self.iban = Some(iban.into());
493 }
494
495 pub fn set_contact_name<T: Into<String>>(&mut self, contact_name: T) {
496 self.contact_name = Some(contact_name.into());
497 }
498
499 pub fn set_contact_surname<T: Into<String>>(&mut self, contact_surname: T) {
500 self.contact_surname = Some(contact_surname.into());
501 }
502
503 pub fn set_legal_company_title<T: Into<String>>(&mut self, legal_company_title: T) {
504 self.legal_company_title = Some(legal_company_title.into());
505 }
506
507 pub fn set_marketplace_sub_merchant_type<T: Into<String>>(
508 &mut self,
509 marketplace_sub_merchant_type: T,
510 ) {
511 self.marketplace_sub_merchant_type = Some(marketplace_sub_merchant_type.into());
512 }
513
514 pub fn sub_merchant_key(&self) -> Option<&String> {
515 self.sub_merchant_key.as_ref()
516 }
517 pub fn iban(&self) -> Option<&String> {
518 self.iban.as_ref()
519 }
520 pub fn contact_name(&self) -> Option<&String> {
521 self.contact_name.as_ref()
522 }
523 pub fn contact_surname(&self) -> Option<&String> {
524 self.contact_surname.as_ref()
525 }
526 pub fn legal_company_title(&self) -> Option<&String> {
527 self.legal_company_title.as_ref()
528 }
529 pub fn marketplace_sub_merchant_type(&self) -> Option<&String> {
530 self.marketplace_sub_merchant_type.as_ref()
531 }
532}
533
534#[derive(Debug, Serialize, Deserialize)]
535#[serde(rename_all = "camelCase")]
536pub struct Apm {
537 #[serde(flatten)]
538 resource: ApmResource,
539
540 payment_transaction_id: Option<String>,
541}
542
543impl Apm {
544 pub fn create(req: &CreateApmInitializeRequest, options: &Options) -> Result<Apm> {
545 let request = serde_json::to_string(req)?;
546 debug!("RequestBody:{}", request);
547 let res = HttpClient::create().post(
548 format!("{}{}", options.base_url(), "/payment/apm/initialize").as_str(),
549 request,
550 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
551 )?;
552 let response = res.json()?;
553 Ok(response)
554 }
555
556 pub fn retrieve(req: &RetrieveApmRequest, options: &Options) -> Result<Apm> {
557 let request = serde_json::to_string(req)?;
558 debug!("RequestBody:{}", request);
559 let res = HttpClient::create().post(
560 format!("{}{}", options.base_url(), "/payment/apm/retrieve").as_str(),
561 request,
562 IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
563 )?;
564 let response = res.json()?;
565 Ok(response)
566 }
567
568 pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
569 self.payment_transaction_id = Some(payment_transaction_id.into());
570 }
571
572 pub fn payment_transaction_id(&self) -> Option<&String> {
573 self.payment_transaction_id.as_ref()
574 }
575}
576
577impl std::ops::Deref for Apm {
578 type Target = ApmResource;
579 fn deref(&self) -> &Self::Target {
580 &self.resource
581 }
582}
583
584#[derive(Debug, Default, Serialize, Deserialize)]
585#[serde(rename_all = "camelCase")]
586#[serde(default)]
587pub struct ApmResource {
588 #[serde(flatten)]
589 resource: IyzipayResource,
590
591 redirect_url: Option<String>,
592
593 price: Option<BigDecimal>,
594
595 paid_price: Option<BigDecimal>,
596
597 payment_id: Option<String>,
598
599 merchant_commission_rate: Option<BigDecimal>,
600
601 merchant_commission_rate_amount: Option<BigDecimal>,
602
603 iyzi_commission_rate_amount: Option<BigDecimal>,
604
605 iyzi_commission_fee: Option<BigDecimal>,
606
607 basket_id: Option<String>,
608
609 currency: Option<String>,
610
611 #[serde(rename = "itemTransactions")]
612 payment_items: Option<Vec<PaymentItem>>,
613
614 phase: Option<String>,
615
616 account_holder_name: Option<String>,
617
618 account_number: Option<String>,
619
620 bank_name: Option<String>,
621
622 bank_code: Option<String>,
623
624 bic: Option<String>,
625
626 payment_purpose: Option<String>,
627
628 iban: Option<String>,
629
630 country_code: Option<String>,
631
632 apm: Option<String>,
633
634 mobile_phone: Option<String>,
635
636 payment_status: Option<String>,
637}
638
639impl ApmResource {
640 pub fn set_redirect_url<T: Into<String>>(&mut self, redirect_url: T) {
641 self.redirect_url = Some(redirect_url.into());
642 }
643 pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
644 self.price = Some(price.into());
645 }
646
647 pub fn set_paid_price<T: Into<BigDecimal>>(&mut self, paid_price: T) {
648 self.paid_price = Some(paid_price.into());
649 }
650
651 pub fn set_payment_id<T: Into<String>>(&mut self, payment_id: T) {
652 self.payment_id = Some(payment_id.into());
653 }
654
655 pub fn set_merchant_commission_rate<T: Into<BigDecimal>>(
656 &mut self,
657 merchant_commission_rate: T,
658 ) {
659 self.merchant_commission_rate = Some(merchant_commission_rate.into());
660 }
661
662 pub fn set_merchant_commission_rate_amount<T: Into<BigDecimal>>(
663 &mut self,
664 merchant_commission_rate_amount: T,
665 ) {
666 self.merchant_commission_rate_amount = Some(merchant_commission_rate_amount.into());
667 }
668
669 pub fn set_iyzi_commission_rate_amount<T: Into<BigDecimal>>(
670 &mut self,
671 iyzi_commission_rate_amount: T,
672 ) {
673 self.iyzi_commission_rate_amount = Some(iyzi_commission_rate_amount.into());
674 }
675
676 pub fn set_iyzi_commission_fee<T: Into<BigDecimal>>(&mut self, iyzi_commission_fee: T) {
677 self.iyzi_commission_fee = Some(iyzi_commission_fee.into());
678 }
679
680 pub fn set_basket_id<T: Into<String>>(&mut self, basket_id: T) {
681 self.basket_id = Some(basket_id.into());
682 }
683
684 pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
685 self.currency = Some(currency.into());
686 }
687
688 pub fn set_payment_items<T: Into<Vec<PaymentItem>>>(&mut self, payment_items: T) {
689 self.payment_items = Some(payment_items.into());
690 }
691
692 pub fn set_phase<T: Into<String>>(&mut self, phase: T) {
693 self.phase = Some(phase.into());
694 }
695
696 pub fn set_account_holder_name<T: Into<String>>(&mut self, account_holder_name: T) {
697 self.account_holder_name = Some(account_holder_name.into());
698 }
699
700 pub fn set_account_number<T: Into<String>>(&mut self, account_number: T) {
701 self.account_number = Some(account_number.into());
702 }
703
704 pub fn set_bank_name<T: Into<String>>(&mut self, bank_name: T) {
705 self.bank_name = Some(bank_name.into());
706 }
707
708 pub fn set_bank_code<T: Into<String>>(&mut self, bank_code: T) {
709 self.bank_code = Some(bank_code.into());
710 }
711
712 pub fn set_bic<T: Into<String>>(&mut self, bic: T) {
713 self.bic = Some(bic.into());
714 }
715
716 pub fn set_payment_purpose<T: Into<String>>(&mut self, payment_purpose: T) {
717 self.payment_purpose = Some(payment_purpose.into());
718 }
719
720 pub fn set_iban<T: Into<String>>(&mut self, iban: T) {
721 self.iban = Some(iban.into());
722 }
723
724 pub fn set_country_code<T: Into<String>>(&mut self, country_code: T) {
725 self.country_code = Some(country_code.into());
726 }
727
728 pub fn set_apm<T: Into<String>>(&mut self, apm: T) {
729 self.apm = Some(apm.into());
730 }
731
732 pub fn set_mobile_phone<T: Into<String>>(&mut self, mobile_phone: T) {
733 self.mobile_phone = Some(mobile_phone.into());
734 }
735
736 pub fn set_payment_status<T: Into<String>>(&mut self, payment_status: T) {
737 self.payment_status = Some(payment_status.into());
738 }
739
740 pub fn redirect_url(&self) -> Option<&String> {
741 self.redirect_url.as_ref()
742 }
743
744 pub fn price(&self) -> Option<&BigDecimal> {
745 self.price.as_ref()
746 }
747 pub fn paid_price(&self) -> Option<&BigDecimal> {
748 self.paid_price.as_ref()
749 }
750 pub fn payment_id(&self) -> Option<&String> {
751 self.payment_id.as_ref()
752 }
753 pub fn merchant_commission_rate(&self) -> Option<&BigDecimal> {
754 self.merchant_commission_rate.as_ref()
755 }
756 pub fn merchant_commission_rate_amount(&self) -> Option<&BigDecimal> {
757 self.merchant_commission_rate_amount.as_ref()
758 }
759 pub fn iyzi_commission_rate_amount(&self) -> Option<&BigDecimal> {
760 self.iyzi_commission_rate_amount.as_ref()
761 }
762 pub fn iyzi_commission_fee(&self) -> Option<&BigDecimal> {
763 self.iyzi_commission_fee.as_ref()
764 }
765 pub fn basket_id(&self) -> Option<&String> {
766 self.basket_id.as_ref()
767 }
768 pub fn currency(&self) -> Option<&String> {
769 self.currency.as_ref()
770 }
771 pub fn payment_items(&self) -> Option<&Vec<PaymentItem>> {
772 self.payment_items.as_ref()
773 }
774 pub fn phase(&self) -> Option<&String> {
775 self.phase.as_ref()
776 }
777 pub fn account_holder_name(&self) -> Option<&String> {
778 self.account_holder_name.as_ref()
779 }
780 pub fn account_number(&self) -> Option<&String> {
781 self.account_number.as_ref()
782 }
783 pub fn bank_name(&self) -> Option<&String> {
784 self.bank_name.as_ref()
785 }
786 pub fn bank_code(&self) -> Option<&String> {
787 self.bank_code.as_ref()
788 }
789 pub fn bic(&self) -> Option<&String> {
790 self.bic.as_ref()
791 }
792 pub fn payment_purpose(&self) -> Option<&String> {
793 self.payment_purpose.as_ref()
794 }
795 pub fn iban(&self) -> Option<&String> {
796 self.iban.as_ref()
797 }
798 pub fn country_code(&self) -> Option<&String> {
799 self.country_code.as_ref()
800 }
801 pub fn apm(&self) -> Option<&String> {
802 self.apm.as_ref()
803 }
804 pub fn mobile_phone(&self) -> Option<&String> {
805 self.mobile_phone.as_ref()
806 }
807 pub fn payment_status(&self) -> Option<&String> {
808 self.payment_status.as_ref()
809 }
810}
811
812impl std::ops::Deref for ApmResource {
813 type Target = IyzipayResource;
814 fn deref(&self) -> &Self::Target {
815 &self.resource
816 }
817}
818
819#[derive(Debug, Serialize, Deserialize, PartialEq)]
820#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
821pub enum ApmType {
822 Sofort,
823 Ideal,
824 Qiwi,
825 Giropay,
826}
827
828impl ApmType {
829 pub fn value(&self) -> &'static str {
830 match self {
831 ApmType::Sofort => "SOFORT",
832 ApmType::Ideal => "IDEAL",
833 ApmType::Qiwi => "QIWI",
834 ApmType::Giropay => "GIROPAY",
835 }
836 }
837}