iyzipay_rust/model/
payment.rs

1use std::fmt;
2
3use bigdecimal::BigDecimal;
4use log::debug;
5
6use crate::client::HttpClient;
7use crate::options::Options;
8use crate::requests::CreateCancelRequest;
9use crate::requests::CreatePaymentRequest;
10use crate::requests::CreatePeccoInitializeRequest;
11use crate::requests::CreatePeccoPaymentRequest;
12use crate::requests::CreateRefundRequest;
13use crate::requests::CreateThreedsPaymentRequest;
14use crate::requests::PKISerialize;
15use crate::requests::RequestStringBuilder;
16use crate::requests::RetrieveBkmRequest;
17use crate::requests::RetrievePaymentRequest;
18use crate::requests::{CreateBkmInitializeRequest, UpdatePaymentItemRequest};
19use crate::resource::IyzipayResource;
20use crate::types::Result;
21
22#[derive(Debug, Serialize, Deserialize, PartialEq)]
23#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
24pub enum PaymentChannel {
25    Mobile,
26    Web,
27    MobileWeb,
28    MobileIos,
29    MobileAndroid,
30    MobileWindows,
31    MobileTablet,
32    MobilePhone,
33}
34
35impl PaymentChannel {
36    pub fn value(&self) -> &'static str {
37        match self {
38            PaymentChannel::Mobile => "MOBILE",
39            PaymentChannel::Web => "WEB",
40            PaymentChannel::MobileWeb => "MOBILE_WEB",
41            PaymentChannel::MobileIos => "MOBILE_IOS",
42            PaymentChannel::MobileAndroid => "MOBILE_ANDROID",
43            PaymentChannel::MobileWindows => "MOBILE_WINDOWS",
44            PaymentChannel::MobileTablet => "MOBILE_TABLET",
45            PaymentChannel::MobilePhone => "MOBILE_PHONE",
46        }
47    }
48}
49
50impl std::fmt::Display for PaymentChannel {
51    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
52        write!(f, "{}", self.value())
53    }
54}
55
56#[derive(Debug, Serialize, Deserialize, PartialEq)]
57#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
58pub enum PaymentGroup {
59    Product,
60    Listing,
61    Subscription,
62}
63
64impl PaymentGroup {
65    pub fn value(&self) -> &'static str {
66        match self {
67            PaymentGroup::Product => "PRODUCT",
68            PaymentGroup::Listing => "LISTING",
69            PaymentGroup::Subscription => "SUBSCRIPTION",
70        }
71    }
72}
73
74impl std::fmt::Display for PaymentGroup {
75    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
76        write!(f, "{}", self.value())
77    }
78}
79
80#[derive(Debug, Serialize, Deserialize, PartialEq)]
81#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
82pub enum BasketItemType {
83    Physical,
84    Virtual,
85}
86
87impl BasketItemType {
88    pub fn value(&self) -> &'static str {
89        match self {
90            BasketItemType::Physical => "PHYSICAL",
91            BasketItemType::Virtual => "VIRTUAL",
92        }
93    }
94}
95
96impl std::fmt::Display for BasketItemType {
97    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
98        write!(f, "{}", self.value())
99    }
100}
101
102#[derive(Debug, Serialize, Deserialize, PartialEq)]
103#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
104pub enum RefundReason {
105    DoublePayment,
106    BuyerRequest,
107    Fraud,
108    Other,
109}
110
111impl RefundReason {
112    pub fn value(&self) -> &'static str {
113        match self {
114            RefundReason::DoublePayment => "DOUBLE_PAYMENT",
115            RefundReason::BuyerRequest => "BUYER_REQUEST",
116            RefundReason::Fraud => "FRAUD",
117            RefundReason::Other => "OTHER",
118        }
119    }
120}
121
122impl Default for RefundReason {
123    fn default() -> Self {
124        RefundReason::Other
125    }
126}
127
128impl PKISerialize for Option<RefundReason> {
129    fn serialize(&self) -> Option<String> {
130        match &self {
131            Some(val) => Option::from(val.value().to_string()),
132            None => None,
133        }
134    }
135}
136
137#[derive(Debug, Default, Serialize, Deserialize, Clone)]
138#[serde(rename_all = "camelCase")]
139#[serde(default)]
140pub struct BasketItem {
141    id: Option<String>,
142
143    price: Option<BigDecimal>,
144
145    name: Option<String>,
146
147    category1: Option<String>,
148
149    category2: Option<String>,
150
151    item_type: Option<String>,
152
153    sub_merchant_key: Option<String>,
154
155    sub_merchant_price: Option<BigDecimal>,
156}
157
158impl BasketItem {
159    pub fn new() -> Self {
160        BasketItem::default()
161    }
162
163    pub fn set_id<T: Into<String>>(&mut self, id: T) {
164        self.id = Some(id.into());
165    }
166
167    pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
168        self.price = Some(price.into());
169    }
170
171    pub fn set_name<T: Into<String>>(&mut self, name: T) {
172        self.name = Some(name.into());
173    }
174
175    pub fn set_category1<T: Into<String>>(&mut self, category1: T) {
176        self.category1 = Some(category1.into());
177    }
178
179    pub fn set_category2<T: Into<String>>(&mut self, category2: T) {
180        self.category2 = Some(category2.into());
181    }
182
183    pub fn set_item_type<T: Into<String>>(&mut self, item_type: T) {
184        self.item_type = Some(item_type.into());
185    }
186
187    pub fn set_sub_merchant_key<T: Into<String>>(&mut self, sub_merchant_key: T) {
188        self.sub_merchant_key = Some(sub_merchant_key.into());
189    }
190
191    pub fn set_sub_merchant_price<T: Into<BigDecimal>>(&mut self, sub_merchant_price: T) {
192        self.sub_merchant_price = Some(sub_merchant_price.into());
193    }
194
195    pub fn id(&self) -> Option<&String> {
196        self.id.as_ref()
197    }
198    pub fn price(&self) -> Option<&BigDecimal> {
199        self.price.as_ref()
200    }
201    pub fn name(&self) -> Option<&String> {
202        self.name.as_ref()
203    }
204    pub fn category1(&self) -> Option<&String> {
205        self.category1.as_ref()
206    }
207    pub fn category2(&self) -> Option<&String> {
208        self.category2.as_ref()
209    }
210    pub fn item_type(&self) -> Option<&String> {
211        self.item_type.as_ref()
212    }
213    pub fn sub_merchant_key(&self) -> Option<&String> {
214        self.sub_merchant_key.as_ref()
215    }
216    pub fn sub_merchant_price(&self) -> Option<&BigDecimal> {
217        self.sub_merchant_price.as_ref()
218    }
219}
220
221impl PKISerialize for BasketItem {
222    fn serialize(&self) -> Option<String> {
223        let mut ser = RequestStringBuilder::new();
224        ser.append_option("id", self.id.as_ref());
225        ser.append_price_option("price", self.price.as_ref());
226        ser.append_option("name", self.name.as_ref());
227        ser.append_option("category1", self.category1.as_ref());
228        ser.append_option("category2", self.category2.as_ref());
229        ser.append_option("itemType", self.item_type.as_ref());
230        ser.append_option("subMerchantKey", self.sub_merchant_key.as_ref());
231        ser.append_price_option("subMerchantPrice", self.sub_merchant_price.as_ref());
232        Option::from(ser.build(true))
233    }
234}
235
236#[derive(Debug, Default, Serialize, Deserialize, Clone)]
237#[serde(rename_all = "camelCase")]
238#[serde(default)]
239pub struct Address {
240    address: Option<String>,
241
242    zip_code: Option<String>,
243
244    contact_name: Option<String>,
245
246    city: Option<String>,
247
248    country: Option<String>,
249}
250
251impl Address {
252    pub fn new() -> Self {
253        Address::default()
254    }
255
256    pub fn set_address<T: Into<String>>(&mut self, address: T) {
257        self.address = Some(address.into());
258    }
259
260    pub fn set_zip_code<T: Into<String>>(&mut self, zip_code: T) {
261        self.zip_code = Some(zip_code.into());
262    }
263
264    pub fn set_contact_name<T: Into<String>>(&mut self, contact_name: T) {
265        self.contact_name = Some(contact_name.into());
266    }
267
268    pub fn set_city<T: Into<String>>(&mut self, city: T) {
269        self.city = Some(city.into());
270    }
271
272    pub fn set_country<T: Into<String>>(&mut self, country: T) {
273        self.country = Some(country.into());
274    }
275
276    pub fn address(&self) -> Option<&String> {
277        self.address.as_ref()
278    }
279    pub fn zip_code(&self) -> Option<&String> {
280        self.zip_code.as_ref()
281    }
282    pub fn contact_name(&self) -> Option<&String> {
283        self.contact_name.as_ref()
284    }
285    pub fn city(&self) -> Option<&String> {
286        self.city.as_ref()
287    }
288    pub fn country(&self) -> Option<&String> {
289        self.country.as_ref()
290    }
291}
292
293impl PKISerialize for Address {
294    fn serialize(&self) -> Option<String> {
295        let mut ser = RequestStringBuilder::new();
296        ser.append_option("address", self.address.as_ref());
297        ser.append_option("zipCode", self.zip_code.as_ref());
298        ser.append_option("contactName", self.contact_name.as_ref());
299        ser.append_option("city", self.city.as_ref());
300        ser.append_option("country", self.country.as_ref());
301        Option::from(ser.build(true))
302    }
303}
304
305#[derive(Debug, Default, Serialize, Deserialize, Clone)]
306#[serde(rename_all = "camelCase")]
307#[serde(default)]
308pub struct PaymentCard {
309    card_holder_name: Option<String>,
310
311    card_number: Option<String>,
312
313    expire_year: Option<String>,
314
315    expire_month: Option<String>,
316
317    cvc: Option<String>,
318
319    register_card: Option<u8>,
320
321    card_alias: Option<String>,
322
323    card_token: Option<String>,
324
325    card_user_key: Option<String>,
326}
327
328impl PaymentCard {
329    pub fn new() -> Self {
330        PaymentCard::default()
331    }
332
333    pub fn set_card_holder_name<T: Into<String>>(&mut self, card_holder_name: T) {
334        self.card_holder_name = Some(card_holder_name.into());
335    }
336
337    pub fn set_card_number<T: Into<String>>(&mut self, card_number: T) {
338        self.card_number = Some(card_number.into());
339    }
340
341    pub fn set_expire_year<T: Into<String>>(&mut self, expire_year: T) {
342        self.expire_year = Some(expire_year.into());
343    }
344
345    pub fn set_expire_month<T: Into<String>>(&mut self, expire_month: T) {
346        self.expire_month = Some(expire_month.into());
347    }
348
349    pub fn set_cvc<T: Into<String>>(&mut self, cvc: T) {
350        self.cvc = Some(cvc.into());
351    }
352
353    pub fn set_register_card<T: Into<u8>>(&mut self, register_card: T) {
354        self.register_card = Some(register_card.into());
355    }
356
357    pub fn set_card_alias<T: Into<String>>(&mut self, card_alias: T) {
358        self.card_alias = Some(card_alias.into());
359    }
360
361    pub fn set_card_token<T: Into<String>>(&mut self, card_token: T) {
362        self.card_token = Some(card_token.into());
363    }
364
365    pub fn set_card_user_key<T: Into<String>>(&mut self, card_user_key: T) {
366        self.card_user_key = Some(card_user_key.into());
367    }
368
369    pub fn card_holder_name(&self) -> Option<&String> {
370        self.card_holder_name.as_ref()
371    }
372    pub fn card_number(&self) -> Option<&String> {
373        self.card_number.as_ref()
374    }
375    pub fn expire_year(&self) -> Option<&String> {
376        self.expire_year.as_ref()
377    }
378    pub fn expire_month(&self) -> Option<&String> {
379        self.expire_month.as_ref()
380    }
381    pub fn cvc(&self) -> Option<&String> {
382        self.cvc.as_ref()
383    }
384    pub fn register_card(&self) -> Option<&u8> {
385        self.register_card.as_ref()
386    }
387    pub fn card_alias(&self) -> Option<&String> {
388        self.card_alias.as_ref()
389    }
390    pub fn card_token(&self) -> Option<&String> {
391        self.card_token.as_ref()
392    }
393    pub fn card_user_key(&self) -> Option<&String> {
394        self.card_user_key.as_ref()
395    }
396}
397
398impl PKISerialize for PaymentCard {
399    fn serialize(&self) -> Option<String> {
400        let mut ser = RequestStringBuilder::new();
401        ser.append_option("cardHolderName", self.card_holder_name.as_ref());
402        ser.append_option("cardNumber", self.card_number.as_ref());
403        ser.append_option("expireYear", self.expire_year.as_ref());
404        ser.append_option("expireMonth", self.expire_month.as_ref());
405        ser.append_option("cvc", self.cvc.as_ref());
406        ser.append_option("registerCard", self.register_card.as_ref());
407        ser.append_option("cardAlias", self.card_alias.as_ref());
408        ser.append_option("cardToken", self.card_token.as_ref());
409        ser.append_option("cardUserKey", self.card_user_key.as_ref());
410        Option::from(ser.build(true))
411    }
412}
413
414#[derive(Debug, Default, Serialize, Deserialize, Clone)]
415#[serde(rename_all = "camelCase")]
416#[serde(default)]
417pub struct Buyer {
418    id: Option<String>,
419
420    name: Option<String>,
421
422    surname: Option<String>,
423
424    identity_number: Option<String>,
425
426    email: Option<String>,
427
428    gsm_number: Option<String>,
429
430    registration_date: Option<String>,
431
432    last_login_date: Option<String>,
433
434    registration_address: Option<String>,
435
436    city: Option<String>,
437
438    country: Option<String>,
439
440    zip_code: Option<String>,
441
442    ip: Option<String>,
443}
444
445impl Buyer {
446    pub fn new() -> Self {
447        Buyer::default()
448    }
449
450    pub fn set_id<T: Into<String>>(&mut self, id: T) {
451        self.id = Some(id.into());
452    }
453
454    pub fn set_name<T: Into<String>>(&mut self, name: T) {
455        self.name = Some(name.into());
456    }
457
458    pub fn set_surname<T: Into<String>>(&mut self, surname: T) {
459        self.surname = Some(surname.into());
460    }
461
462    pub fn set_identity_number<T: Into<String>>(&mut self, identity_number: T) {
463        self.identity_number = Some(identity_number.into());
464    }
465
466    pub fn set_email<T: Into<String>>(&mut self, email: T) {
467        self.email = Some(email.into());
468    }
469
470    pub fn set_gsm_number<T: Into<String>>(&mut self, gsm_number: T) {
471        self.gsm_number = Some(gsm_number.into());
472    }
473
474    pub fn set_registration_date<T: Into<String>>(&mut self, registration_date: T) {
475        self.registration_date = Some(registration_date.into());
476    }
477
478    pub fn set_last_login_date<T: Into<String>>(&mut self, last_login_date: T) {
479        self.last_login_date = Some(last_login_date.into());
480    }
481
482    pub fn set_registration_address<T: Into<String>>(&mut self, registration_address: T) {
483        self.registration_address = Some(registration_address.into());
484    }
485
486    pub fn set_city<T: Into<String>>(&mut self, city: T) {
487        self.city = Some(city.into());
488    }
489
490    pub fn set_country<T: Into<String>>(&mut self, country: T) {
491        self.country = Some(country.into());
492    }
493
494    pub fn set_zip_code<T: Into<String>>(&mut self, zip_code: T) {
495        self.zip_code = Some(zip_code.into());
496    }
497
498    pub fn set_ip<T: Into<String>>(&mut self, ip: T) {
499        self.ip = Some(ip.into());
500    }
501
502    pub fn id(&self) -> Option<&String> {
503        self.id.as_ref()
504    }
505    pub fn name(&self) -> Option<&String> {
506        self.name.as_ref()
507    }
508    pub fn surname(&self) -> Option<&String> {
509        self.surname.as_ref()
510    }
511    pub fn identity_number(&self) -> Option<&String> {
512        self.identity_number.as_ref()
513    }
514    pub fn email(&self) -> Option<&String> {
515        self.email.as_ref()
516    }
517    pub fn gsm_number(&self) -> Option<&String> {
518        self.gsm_number.as_ref()
519    }
520    pub fn registration_date(&self) -> Option<&String> {
521        self.registration_date.as_ref()
522    }
523    pub fn last_login_date(&self) -> Option<&String> {
524        self.last_login_date.as_ref()
525    }
526    pub fn registration_address(&self) -> Option<&String> {
527        self.registration_address.as_ref()
528    }
529    pub fn city(&self) -> Option<&String> {
530        self.city.as_ref()
531    }
532    pub fn country(&self) -> Option<&String> {
533        self.country.as_ref()
534    }
535    pub fn zip_code(&self) -> Option<&String> {
536        self.zip_code.as_ref()
537    }
538    pub fn ip(&self) -> Option<&String> {
539        self.ip.as_ref()
540    }
541}
542
543impl PKISerialize for Buyer {
544    fn serialize(&self) -> Option<String> {
545        let mut ser = RequestStringBuilder::new();
546        ser.append_option("id", self.id.as_ref());
547        ser.append_option("name", self.name.as_ref());
548        ser.append_option("surname", self.surname.as_ref());
549        ser.append_option("identityNumber", self.identity_number.as_ref());
550        ser.append_option("email", self.email.as_ref());
551        ser.append_option("gsmNumber", self.gsm_number.as_ref());
552        ser.append_option("registrationDate", self.registration_date.as_ref());
553        ser.append_option("lastLoginDate", self.last_login_date.as_ref());
554        ser.append_option("registrationAddress", self.registration_address.as_ref());
555        ser.append_option("city", self.city.as_ref());
556        ser.append_option("country", self.country.as_ref());
557        ser.append_option("zipCode", self.zip_code.as_ref());
558        ser.append_option("ip", self.ip.as_ref());
559        Option::from(ser.build(true))
560    }
561}
562
563#[derive(Debug, Default, Serialize, Deserialize)]
564#[serde(rename_all = "camelCase")]
565pub struct Payment {
566    #[serde(flatten)]
567    resource: PaymentResource,
568}
569
570impl Payment {
571    pub fn create(req: &CreatePaymentRequest, options: &Options) -> Result<Payment> {
572        let request = serde_json::to_string(req)?;
573        debug!("RequestBody:{}", request);
574        let res = HttpClient::create().post(
575            format!("{}{}", options.base_url(), "/payment/auth").as_str(),
576            request,
577            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
578        )?;
579        let response = res.json()?;
580        Ok(response)
581    }
582
583    pub fn retrieve(req: &RetrievePaymentRequest, options: &Options) -> Result<Payment> {
584        let request = serde_json::to_string(req)?;
585        debug!("RequestBody:{}", request);
586        let res = HttpClient::create().post(
587            format!("{}{}", options.base_url(), "/payment/detail").as_str(),
588            request,
589            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
590        )?;
591        let response = res.json()?;
592        Ok(response)
593    }
594}
595
596impl std::ops::Deref for Payment {
597    type Target = PaymentResource;
598    fn deref(&self) -> &Self::Target {
599        &self.resource
600    }
601}
602
603#[derive(Debug, Default, Serialize, Deserialize)]
604#[serde(rename_all = "camelCase")]
605#[serde(default)]
606pub struct PaymentResource {
607    #[serde(flatten)]
608    resource: IyzipayResource,
609
610    price: Option<BigDecimal>,
611
612    paid_price: Option<BigDecimal>,
613
614    currency: Option<String>,
615
616    installment: Option<u8>,
617
618    payment_id: Option<String>,
619
620    payment_status: Option<String>,
621
622    fraud_status: Option<u8>,
623
624    merchant_commission_rate: Option<BigDecimal>,
625
626    merchant_commission_rate_amount: Option<BigDecimal>,
627
628    iyzi_commission_rate_amount: Option<BigDecimal>,
629
630    iyzi_commission_fee: Option<BigDecimal>,
631
632    card_type: Option<String>,
633
634    card_association: Option<String>,
635
636    card_family: Option<String>,
637
638    card_token: Option<String>,
639
640    card_user_key: Option<String>,
641
642    bin_number: Option<String>,
643
644    basket_id: Option<String>,
645
646    #[serde(rename = "itemTransactions")]
647    payment_items: Option<Vec<PaymentItem>>,
648
649    connector_name: Option<String>,
650
651    auth_code: Option<String>,
652
653    phase: Option<String>,
654
655    last_four_digits: Option<String>,
656
657    pos_order_id: Option<String>,
658
659    host_reference: Option<String>,
660}
661
662impl PaymentResource {
663    pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
664        self.price = Some(price.into());
665    }
666
667    pub fn set_paid_price<T: Into<BigDecimal>>(&mut self, paid_price: T) {
668        self.paid_price = Some(paid_price.into());
669    }
670
671    pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
672        self.currency = Some(currency.into());
673    }
674
675    pub fn set_installment<T: Into<u8>>(&mut self, installment: T) {
676        self.installment = Some(installment.into());
677    }
678
679    pub fn set_payment_id<T: Into<String>>(&mut self, payment_id: T) {
680        self.payment_id = Some(payment_id.into());
681    }
682
683    pub fn set_payment_status<T: Into<String>>(&mut self, payment_status: T) {
684        self.payment_status = Some(payment_status.into());
685    }
686
687    pub fn set_fraud_status<T: Into<u8>>(&mut self, fraud_status: T) {
688        self.fraud_status = Some(fraud_status.into());
689    }
690
691    pub fn set_merchant_commission_rate<T: Into<BigDecimal>>(
692        &mut self,
693        merchant_commission_rate: T,
694    ) {
695        self.merchant_commission_rate = Some(merchant_commission_rate.into());
696    }
697
698    pub fn set_merchant_commission_rate_amount<T: Into<BigDecimal>>(
699        &mut self,
700        merchant_commission_rate_amount: T,
701    ) {
702        self.merchant_commission_rate_amount = Some(merchant_commission_rate_amount.into());
703    }
704
705    pub fn set_iyzi_commission_rate_amount<T: Into<BigDecimal>>(
706        &mut self,
707        iyzi_commission_rate_amount: T,
708    ) {
709        self.iyzi_commission_rate_amount = Some(iyzi_commission_rate_amount.into());
710    }
711
712    pub fn set_iyzi_commission_fee<T: Into<BigDecimal>>(&mut self, iyzi_commission_fee: T) {
713        self.iyzi_commission_fee = Some(iyzi_commission_fee.into());
714    }
715
716    pub fn set_card_type<T: Into<String>>(&mut self, card_type: T) {
717        self.card_type = Some(card_type.into());
718    }
719
720    pub fn set_card_association<T: Into<String>>(&mut self, card_association: T) {
721        self.card_association = Some(card_association.into());
722    }
723
724    pub fn set_card_family<T: Into<String>>(&mut self, card_family: T) {
725        self.card_family = Some(card_family.into());
726    }
727
728    pub fn set_card_token<T: Into<String>>(&mut self, card_token: T) {
729        self.card_token = Some(card_token.into());
730    }
731
732    pub fn set_card_user_key<T: Into<String>>(&mut self, card_user_key: T) {
733        self.card_user_key = Some(card_user_key.into());
734    }
735
736    pub fn set_bin_number<T: Into<String>>(&mut self, bin_number: T) {
737        self.bin_number = Some(bin_number.into());
738    }
739
740    pub fn set_basket_id<T: Into<String>>(&mut self, basket_id: T) {
741        self.basket_id = Some(basket_id.into());
742    }
743
744    pub fn set_payment_items<T: Into<Vec<PaymentItem>>>(&mut self, payment_items: T) {
745        self.payment_items = Some(payment_items.into());
746    }
747
748    pub fn set_connector_name<T: Into<String>>(&mut self, connector_name: T) {
749        self.connector_name = Some(connector_name.into());
750    }
751
752    pub fn set_auth_code<T: Into<String>>(&mut self, auth_code: T) {
753        self.auth_code = Some(auth_code.into());
754    }
755
756    pub fn set_phase<T: Into<String>>(&mut self, phase: T) {
757        self.phase = Some(phase.into());
758    }
759
760    pub fn set_last_four_digits<T: Into<String>>(&mut self, last_four_digits: T) {
761        self.last_four_digits = Some(last_four_digits.into());
762    }
763
764    pub fn set_pos_order_id<T: Into<String>>(&mut self, pos_order_id: T) {
765        self.pos_order_id = Some(pos_order_id.into());
766    }
767
768    pub fn set_host_reference<T: Into<String>>(&mut self, host_reference: T) {
769        self.host_reference = Some(host_reference.into());
770    }
771
772    pub fn price(&self) -> Option<&BigDecimal> {
773        self.price.as_ref()
774    }
775    pub fn paid_price(&self) -> Option<&BigDecimal> {
776        self.paid_price.as_ref()
777    }
778    pub fn currency(&self) -> Option<&String> {
779        self.currency.as_ref()
780    }
781    pub fn installment(&self) -> Option<&u8> {
782        self.installment.as_ref()
783    }
784    pub fn payment_id(&self) -> Option<&String> {
785        self.payment_id.as_ref()
786    }
787    pub fn payment_status(&self) -> Option<&String> {
788        self.payment_status.as_ref()
789    }
790    pub fn fraud_status(&self) -> Option<&u8> {
791        self.fraud_status.as_ref()
792    }
793    pub fn merchant_commission_rate(&self) -> Option<&BigDecimal> {
794        self.merchant_commission_rate.as_ref()
795    }
796    pub fn merchant_commission_rate_amount(&self) -> Option<&BigDecimal> {
797        self.merchant_commission_rate_amount.as_ref()
798    }
799    pub fn iyzi_commission_rate_amount(&self) -> Option<&BigDecimal> {
800        self.iyzi_commission_rate_amount.as_ref()
801    }
802    pub fn iyzi_commission_fee(&self) -> Option<&BigDecimal> {
803        self.iyzi_commission_fee.as_ref()
804    }
805    pub fn card_type(&self) -> Option<&String> {
806        self.card_type.as_ref()
807    }
808    pub fn card_association(&self) -> Option<&String> {
809        self.card_association.as_ref()
810    }
811    pub fn card_family(&self) -> Option<&String> {
812        self.card_family.as_ref()
813    }
814    pub fn card_token(&self) -> Option<&String> {
815        self.card_token.as_ref()
816    }
817    pub fn card_user_key(&self) -> Option<&String> {
818        self.card_user_key.as_ref()
819    }
820    pub fn bin_number(&self) -> Option<&String> {
821        self.bin_number.as_ref()
822    }
823    pub fn basket_id(&self) -> Option<&String> {
824        self.basket_id.as_ref()
825    }
826    pub fn payment_items(&self) -> Option<&Vec<PaymentItem>> {
827        self.payment_items.as_ref()
828    }
829    pub fn connector_name(&self) -> Option<&String> {
830        self.connector_name.as_ref()
831    }
832    pub fn auth_code(&self) -> Option<&String> {
833        self.auth_code.as_ref()
834    }
835    pub fn phase(&self) -> Option<&String> {
836        self.phase.as_ref()
837    }
838    pub fn last_four_digits(&self) -> Option<&String> {
839        self.last_four_digits.as_ref()
840    }
841    pub fn pos_order_id(&self) -> Option<&String> {
842        self.pos_order_id.as_ref()
843    }
844    pub fn host_reference(&self) -> Option<&String> {
845        self.host_reference.as_ref()
846    }
847}
848
849impl std::ops::Deref for PaymentResource {
850    type Target = IyzipayResource;
851    fn deref(&self) -> &Self::Target {
852        &self.resource
853    }
854}
855
856#[derive(Debug, Default, Serialize, Deserialize)]
857#[serde(rename_all = "camelCase")]
858#[serde(default)]
859pub struct PaymentItem {
860    #[serde(flatten)]
861    resource: IyzipayResource,
862
863    item_id: Option<String>,
864
865    payment_transaction_id: Option<String>,
866
867    transaction_status: Option<u8>,
868
869    price: Option<BigDecimal>,
870
871    paid_price: Option<BigDecimal>,
872
873    merchant_commission_rate: Option<BigDecimal>,
874
875    merchant_commission_rate_amount: Option<BigDecimal>,
876
877    iyzi_commission_rate_amount: Option<BigDecimal>,
878
879    iyzi_commission_fee: Option<BigDecimal>,
880
881    blockage_rate: Option<BigDecimal>,
882
883    blockage_rate_amount_merchant: Option<BigDecimal>,
884
885    blockage_rate_amount_sub_merchant: Option<BigDecimal>,
886
887    blockage_resolved_date: Option<String>,
888
889    sub_merchant_key: Option<String>,
890
891    sub_merchant_price: Option<BigDecimal>,
892
893    sub_merchant_payout_rate: Option<BigDecimal>,
894
895    sub_merchant_payout_amount: Option<BigDecimal>,
896
897    merchant_payout_amount: Option<BigDecimal>,
898
899    converted_payout: Option<ConvertedPayout>,
900}
901
902impl PaymentItem {
903    pub fn update(req: &UpdatePaymentItemRequest, options: &Options) -> Result<PaymentItem> {
904        let request = serde_json::to_string(req)?;
905        debug!("RequestBody:{}", request);
906        let res = HttpClient::create().put(
907            format!("{}{}", options.base_url(), "/payment/item").as_str(),
908            request,
909            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
910        )?;
911        let response = res.json()?;
912        Ok(response)
913    }
914
915    pub fn set_item_id<T: Into<String>>(&mut self, item_id: T) {
916        self.item_id = Some(item_id.into());
917    }
918
919    pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
920        self.payment_transaction_id = Some(payment_transaction_id.into());
921    }
922
923    pub fn set_transaction_status<T: Into<u8>>(&mut self, transaction_status: T) {
924        self.transaction_status = Some(transaction_status.into());
925    }
926
927    pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
928        self.price = Some(price.into());
929    }
930
931    pub fn set_paid_price<T: Into<BigDecimal>>(&mut self, paid_price: T) {
932        self.paid_price = Some(paid_price.into());
933    }
934
935    pub fn set_merchant_commission_rate<T: Into<BigDecimal>>(
936        &mut self,
937        merchant_commission_rate: T,
938    ) {
939        self.merchant_commission_rate = Some(merchant_commission_rate.into());
940    }
941
942    pub fn set_merchant_commission_rate_amount<T: Into<BigDecimal>>(
943        &mut self,
944        merchant_commission_rate_amount: T,
945    ) {
946        self.merchant_commission_rate_amount = Some(merchant_commission_rate_amount.into());
947    }
948
949    pub fn set_iyzi_commission_rate_amount<T: Into<BigDecimal>>(
950        &mut self,
951        iyzi_commission_rate_amount: T,
952    ) {
953        self.iyzi_commission_rate_amount = Some(iyzi_commission_rate_amount.into());
954    }
955
956    pub fn set_iyzi_commission_fee<T: Into<BigDecimal>>(&mut self, iyzi_commission_fee: T) {
957        self.iyzi_commission_fee = Some(iyzi_commission_fee.into());
958    }
959
960    pub fn set_blockage_rate<T: Into<BigDecimal>>(&mut self, blockage_rate: T) {
961        self.blockage_rate = Some(blockage_rate.into());
962    }
963
964    pub fn set_blockage_rate_amount_merchant<T: Into<BigDecimal>>(
965        &mut self,
966        blockage_rate_amount_merchant: T,
967    ) {
968        self.blockage_rate_amount_merchant = Some(blockage_rate_amount_merchant.into());
969    }
970
971    pub fn set_blockage_rate_amount_sub_merchant<T: Into<BigDecimal>>(
972        &mut self,
973        blockage_rate_amount_sub_merchant: T,
974    ) {
975        self.blockage_rate_amount_sub_merchant = Some(blockage_rate_amount_sub_merchant.into());
976    }
977
978    pub fn set_blockage_resolved_date<T: Into<String>>(&mut self, blockage_resolved_date: T) {
979        self.blockage_resolved_date = Some(blockage_resolved_date.into());
980    }
981
982    pub fn set_sub_merchant_key<T: Into<String>>(&mut self, sub_merchant_key: T) {
983        self.sub_merchant_key = Some(sub_merchant_key.into());
984    }
985
986    pub fn set_sub_merchant_price<T: Into<BigDecimal>>(&mut self, sub_merchant_price: T) {
987        self.sub_merchant_price = Some(sub_merchant_price.into());
988    }
989
990    pub fn set_sub_merchant_payout_rate<T: Into<BigDecimal>>(
991        &mut self,
992        sub_merchant_payout_rate: T,
993    ) {
994        self.sub_merchant_payout_rate = Some(sub_merchant_payout_rate.into());
995    }
996
997    pub fn set_sub_merchant_payout_amount<T: Into<BigDecimal>>(
998        &mut self,
999        sub_merchant_payout_amount: T,
1000    ) {
1001        self.sub_merchant_payout_amount = Some(sub_merchant_payout_amount.into());
1002    }
1003
1004    pub fn set_merchant_payout_amount<T: Into<BigDecimal>>(&mut self, merchant_payout_amount: T) {
1005        self.merchant_payout_amount = Some(merchant_payout_amount.into());
1006    }
1007
1008    pub fn set_converted_payout<T: Into<ConvertedPayout>>(&mut self, converted_payout: T) {
1009        self.converted_payout = Some(converted_payout.into());
1010    }
1011
1012    pub fn item_id(&self) -> Option<&String> {
1013        self.item_id.as_ref()
1014    }
1015    pub fn payment_transaction_id(&self) -> Option<&String> {
1016        self.payment_transaction_id.as_ref()
1017    }
1018    pub fn transaction_status(&self) -> Option<&u8> {
1019        self.transaction_status.as_ref()
1020    }
1021    pub fn price(&self) -> Option<&BigDecimal> {
1022        self.price.as_ref()
1023    }
1024    pub fn paid_price(&self) -> Option<&BigDecimal> {
1025        self.paid_price.as_ref()
1026    }
1027    pub fn merchant_commission_rate(&self) -> Option<&BigDecimal> {
1028        self.merchant_commission_rate.as_ref()
1029    }
1030    pub fn merchant_commission_rate_amount(&self) -> Option<&BigDecimal> {
1031        self.merchant_commission_rate_amount.as_ref()
1032    }
1033    pub fn iyzi_commission_rate_amount(&self) -> Option<&BigDecimal> {
1034        self.iyzi_commission_rate_amount.as_ref()
1035    }
1036    pub fn iyzi_commission_fee(&self) -> Option<&BigDecimal> {
1037        self.iyzi_commission_fee.as_ref()
1038    }
1039    pub fn blockage_rate(&self) -> Option<&BigDecimal> {
1040        self.blockage_rate.as_ref()
1041    }
1042    pub fn blockage_rate_amount_merchant(&self) -> Option<&BigDecimal> {
1043        self.blockage_rate_amount_merchant.as_ref()
1044    }
1045    pub fn blockage_rate_amount_sub_merchant(&self) -> Option<&BigDecimal> {
1046        self.blockage_rate_amount_sub_merchant.as_ref()
1047    }
1048    pub fn blockage_resolved_date(&self) -> Option<&String> {
1049        self.blockage_resolved_date.as_ref()
1050    }
1051    pub fn sub_merchant_key(&self) -> Option<&String> {
1052        self.sub_merchant_key.as_ref()
1053    }
1054    pub fn sub_merchant_price(&self) -> Option<&BigDecimal> {
1055        self.sub_merchant_price.as_ref()
1056    }
1057    pub fn sub_merchant_payout_rate(&self) -> Option<&BigDecimal> {
1058        self.sub_merchant_payout_rate.as_ref()
1059    }
1060    pub fn sub_merchant_payout_amount(&self) -> Option<&BigDecimal> {
1061        self.sub_merchant_payout_amount.as_ref()
1062    }
1063    pub fn merchant_payout_amount(&self) -> Option<&BigDecimal> {
1064        self.merchant_payout_amount.as_ref()
1065    }
1066    pub fn converted_payout(&self) -> Option<&ConvertedPayout> {
1067        self.converted_payout.as_ref()
1068    }
1069}
1070
1071impl std::ops::Deref for PaymentItem {
1072    type Target = IyzipayResource;
1073    fn deref(&self) -> &Self::Target {
1074        &self.resource
1075    }
1076}
1077
1078#[derive(Debug, Default, Serialize, Deserialize)]
1079#[serde(rename_all = "camelCase")]
1080#[serde(default)]
1081pub struct ConvertedPayout {
1082    paid_price: Option<BigDecimal>,
1083
1084    iyzi_commission_rate_amount: Option<BigDecimal>,
1085
1086    iyzi_commission_fee: Option<BigDecimal>,
1087
1088    blockage_rate_amount_merchant: Option<BigDecimal>,
1089
1090    blockage_rate_amount_sub_merchant: Option<BigDecimal>,
1091
1092    sub_merchant_payout_amount: Option<BigDecimal>,
1093
1094    merchant_payout_amount: Option<BigDecimal>,
1095
1096    iyzi_conversion_rate: Option<BigDecimal>,
1097
1098    iyzi_conversion_rate_amount: Option<BigDecimal>,
1099
1100    currency: Option<String>,
1101}
1102
1103impl ConvertedPayout {
1104    pub fn set_paid_price<T: Into<BigDecimal>>(&mut self, paid_price: T) {
1105        self.paid_price = Some(paid_price.into());
1106    }
1107
1108    pub fn set_iyzi_commission_rate_amount<T: Into<BigDecimal>>(
1109        &mut self,
1110        iyzi_commission_rate_amount: T,
1111    ) {
1112        self.iyzi_commission_rate_amount = Some(iyzi_commission_rate_amount.into());
1113    }
1114
1115    pub fn set_iyzi_commission_fee<T: Into<BigDecimal>>(&mut self, iyzi_commission_fee: T) {
1116        self.iyzi_commission_fee = Some(iyzi_commission_fee.into());
1117    }
1118
1119    pub fn set_blockage_rate_amount_merchant<T: Into<BigDecimal>>(
1120        &mut self,
1121        blockage_rate_amount_merchant: T,
1122    ) {
1123        self.blockage_rate_amount_merchant = Some(blockage_rate_amount_merchant.into());
1124    }
1125
1126    pub fn set_blockage_rate_amount_sub_merchant<T: Into<BigDecimal>>(
1127        &mut self,
1128        blockage_rate_amount_sub_merchant: T,
1129    ) {
1130        self.blockage_rate_amount_sub_merchant = Some(blockage_rate_amount_sub_merchant.into());
1131    }
1132
1133    pub fn set_sub_merchant_payout_amount<T: Into<BigDecimal>>(
1134        &mut self,
1135        sub_merchant_payout_amount: T,
1136    ) {
1137        self.sub_merchant_payout_amount = Some(sub_merchant_payout_amount.into());
1138    }
1139
1140    pub fn set_merchant_payout_amount<T: Into<BigDecimal>>(&mut self, merchant_payout_amount: T) {
1141        self.merchant_payout_amount = Some(merchant_payout_amount.into());
1142    }
1143
1144    pub fn set_iyzi_conversion_rate<T: Into<BigDecimal>>(&mut self, iyzi_conversion_rate: T) {
1145        self.iyzi_conversion_rate = Some(iyzi_conversion_rate.into());
1146    }
1147
1148    pub fn set_iyzi_conversion_rate_amount<T: Into<BigDecimal>>(
1149        &mut self,
1150        iyzi_conversion_rate_amount: T,
1151    ) {
1152        self.iyzi_conversion_rate_amount = Some(iyzi_conversion_rate_amount.into());
1153    }
1154
1155    pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
1156        self.currency = Some(currency.into());
1157    }
1158
1159    pub fn paid_price(&self) -> Option<&BigDecimal> {
1160        self.paid_price.as_ref()
1161    }
1162    pub fn iyzi_commission_rate_amount(&self) -> Option<&BigDecimal> {
1163        self.iyzi_commission_rate_amount.as_ref()
1164    }
1165    pub fn iyzi_commission_fee(&self) -> Option<&BigDecimal> {
1166        self.iyzi_commission_fee.as_ref()
1167    }
1168    pub fn blockage_rate_amount_merchant(&self) -> Option<&BigDecimal> {
1169        self.blockage_rate_amount_merchant.as_ref()
1170    }
1171    pub fn blockage_rate_amount_sub_merchant(&self) -> Option<&BigDecimal> {
1172        self.blockage_rate_amount_sub_merchant.as_ref()
1173    }
1174    pub fn sub_merchant_payout_amount(&self) -> Option<&BigDecimal> {
1175        self.sub_merchant_payout_amount.as_ref()
1176    }
1177    pub fn merchant_payout_amount(&self) -> Option<&BigDecimal> {
1178        self.merchant_payout_amount.as_ref()
1179    }
1180    pub fn iyzi_conversion_rate(&self) -> Option<&BigDecimal> {
1181        self.iyzi_conversion_rate.as_ref()
1182    }
1183    pub fn iyzi_conversion_rate_amount(&self) -> Option<&BigDecimal> {
1184        self.iyzi_conversion_rate_amount.as_ref()
1185    }
1186    pub fn currency(&self) -> Option<&String> {
1187        self.currency.as_ref()
1188    }
1189}
1190
1191#[derive(Debug, Default, Serialize, Deserialize)]
1192#[serde(rename_all = "camelCase")]
1193#[serde(default)]
1194pub struct Cancel {
1195    #[serde(flatten)]
1196    resource: IyzipayResource,
1197
1198    payment_id: Option<String>,
1199
1200    price: Option<BigDecimal>,
1201
1202    currency: Option<String>,
1203
1204    connector_name: Option<String>,
1205
1206    auth_code: Option<String>,
1207
1208    host_reference: Option<String>,
1209}
1210
1211impl Cancel {
1212    pub fn create(req: &CreateCancelRequest, options: &Options) -> Result<Cancel> {
1213        let request = serde_json::to_string(req)?;
1214        debug!("RequestBody:{}", request);
1215        let res = HttpClient::create().post(
1216            format!("{}{}", options.base_url(), "/payment/cancel").as_str(),
1217            request,
1218            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1219        )?;
1220        let response = res.json()?;
1221        Ok(response)
1222    }
1223
1224    pub fn set_payment_id<T: Into<String>>(&mut self, payment_id: T) {
1225        self.payment_id = Some(payment_id.into());
1226    }
1227
1228    pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
1229        self.price = Some(price.into());
1230    }
1231
1232    pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
1233        self.currency = Some(currency.into());
1234    }
1235
1236    pub fn set_connector_name<T: Into<String>>(&mut self, connector_name: T) {
1237        self.connector_name = Some(connector_name.into());
1238    }
1239
1240    pub fn set_auth_code<T: Into<String>>(&mut self, auth_code: T) {
1241        self.auth_code = Some(auth_code.into());
1242    }
1243
1244    pub fn set_host_reference<T: Into<String>>(&mut self, host_reference: T) {
1245        self.host_reference = Some(host_reference.into());
1246    }
1247
1248    pub fn payment_id(&self) -> Option<&String> {
1249        self.payment_id.as_ref()
1250    }
1251    pub fn price(&self) -> Option<&BigDecimal> {
1252        self.price.as_ref()
1253    }
1254    pub fn currency(&self) -> Option<&String> {
1255        self.currency.as_ref()
1256    }
1257    pub fn connector_name(&self) -> Option<&String> {
1258        self.connector_name.as_ref()
1259    }
1260    pub fn auth_code(&self) -> Option<&String> {
1261        self.auth_code.as_ref()
1262    }
1263    pub fn host_reference(&self) -> Option<&String> {
1264        self.host_reference.as_ref()
1265    }
1266}
1267
1268impl std::ops::Deref for Cancel {
1269    type Target = IyzipayResource;
1270    fn deref(&self) -> &Self::Target {
1271        &self.resource
1272    }
1273}
1274
1275#[derive(Debug, Default, Serialize, Deserialize)]
1276#[serde(rename_all = "camelCase")]
1277#[serde(default)]
1278pub struct ThreedsInitialize {
1279    #[serde(flatten)]
1280    resource: IyzipayResource,
1281
1282    #[serde(rename = "threeDSHtmlContent")]
1283    pub html_content: Option<String>,
1284}
1285
1286impl ThreedsInitialize {
1287    pub fn create(req: &CreatePaymentRequest, options: &Options) -> Result<ThreedsInitialize> {
1288        let request = serde_json::to_string(req)?;
1289        debug!("RequestBody:{}", request);
1290        let res = HttpClient::create().post(
1291            format!("{}{}", options.base_url(), "/payment/3dsecure/initialize").as_str(),
1292            request,
1293            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1294        )?;
1295        let response = res.json()?;
1296        Ok(response)
1297    }
1298
1299    pub fn set_html_content<T: Into<String>>(&mut self, html_content: T) {
1300        self.html_content = Some(html_content.into());
1301    }
1302
1303    pub fn html_content(&self) -> Option<&String> {
1304        self.html_content.as_ref()
1305    }
1306}
1307
1308impl std::ops::Deref for ThreedsInitialize {
1309    type Target = IyzipayResource;
1310    fn deref(&self) -> &Self::Target {
1311        &self.resource
1312    }
1313}
1314
1315#[derive(Debug, Default, Serialize, Deserialize)]
1316#[serde(rename_all = "camelCase")]
1317#[serde(default)]
1318pub struct ThreedsPayment {
1319    #[serde(flatten)]
1320    resource: PaymentResource,
1321}
1322
1323impl ThreedsPayment {
1324    pub fn create(req: &CreateThreedsPaymentRequest, options: &Options) -> Result<ThreedsPayment> {
1325        let request = serde_json::to_string(req)?;
1326        debug!("RequestBody:{}", request);
1327        let res = HttpClient::create().post(
1328            format!("{}{}", options.base_url(), "/payment/3dsecure/auth").as_str(),
1329            request,
1330            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1331        )?;
1332        let response = res.json()?;
1333        Ok(response)
1334    }
1335
1336    pub fn retrieve(req: &RetrievePaymentRequest, options: &Options) -> Result<ThreedsPayment> {
1337        let request = serde_json::to_string(req)?;
1338        debug!("RequestBody:{}", request);
1339        let res = HttpClient::create().post(
1340            format!("{}{}", options.base_url(), "/payment/detail").as_str(),
1341            request,
1342            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1343        )?;
1344        let response = res.json()?;
1345        Ok(response)
1346    }
1347}
1348
1349impl std::ops::Deref for ThreedsPayment {
1350    type Target = PaymentResource;
1351    fn deref(&self) -> &Self::Target {
1352        &self.resource
1353    }
1354}
1355
1356#[derive(Debug, Default, Serialize, Deserialize)]
1357#[serde(rename_all = "camelCase")]
1358#[serde(default)]
1359pub struct Refund {
1360    #[serde(flatten)]
1361    resource: IyzipayResource,
1362
1363    payment_id: Option<String>,
1364
1365    payment_transaction_id: Option<String>,
1366
1367    price: Option<BigDecimal>,
1368
1369    currency: Option<String>,
1370
1371    connector_name: Option<String>,
1372
1373    auth_code: Option<String>,
1374
1375    host_reference: Option<String>,
1376}
1377
1378impl Refund {
1379    pub fn create(req: &CreateRefundRequest, options: &Options) -> Result<Refund> {
1380        let request = serde_json::to_string(req)?;
1381        debug!("RequestBody:{}", request);
1382        let res = HttpClient::create().post(
1383            format!("{}{}", options.base_url(), "/payment/refund").as_str(),
1384            request,
1385            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1386        )?;
1387        let response = res.json()?;
1388        Ok(response)
1389    }
1390
1391    pub fn set_payment_id<T: Into<String>>(&mut self, payment_id: T) {
1392        self.payment_id = Some(payment_id.into());
1393    }
1394
1395    pub fn set_payment_transaction_id<T: Into<String>>(&mut self, payment_transaction_id: T) {
1396        self.payment_transaction_id = Some(payment_transaction_id.into());
1397    }
1398
1399    pub fn set_price<T: Into<BigDecimal>>(&mut self, price: T) {
1400        self.price = Some(price.into());
1401    }
1402
1403    pub fn set_currency<T: Into<String>>(&mut self, currency: T) {
1404        self.currency = Some(currency.into());
1405    }
1406
1407    pub fn set_connector_name<T: Into<String>>(&mut self, connector_name: T) {
1408        self.connector_name = Some(connector_name.into());
1409    }
1410
1411    pub fn set_auth_code<T: Into<String>>(&mut self, auth_code: T) {
1412        self.auth_code = Some(auth_code.into());
1413    }
1414
1415    pub fn set_host_reference<T: Into<String>>(&mut self, host_reference: T) {
1416        self.host_reference = Some(host_reference.into());
1417    }
1418
1419    pub fn payment_id(&self) -> Option<&String> {
1420        self.payment_id.as_ref()
1421    }
1422    pub fn payment_transaction_id(&self) -> Option<&String> {
1423        self.payment_transaction_id.as_ref()
1424    }
1425    pub fn price(&self) -> Option<&BigDecimal> {
1426        self.price.as_ref()
1427    }
1428    pub fn currency(&self) -> Option<&String> {
1429        self.currency.as_ref()
1430    }
1431    pub fn connector_name(&self) -> Option<&String> {
1432        self.connector_name.as_ref()
1433    }
1434    pub fn auth_code(&self) -> Option<&String> {
1435        self.auth_code.as_ref()
1436    }
1437    pub fn host_reference(&self) -> Option<&String> {
1438        self.host_reference.as_ref()
1439    }
1440}
1441
1442impl std::ops::Deref for Refund {
1443    type Target = IyzipayResource;
1444    fn deref(&self) -> &Self::Target {
1445        &self.resource
1446    }
1447}
1448
1449#[derive(Debug, Default, Serialize, Deserialize)]
1450#[serde(rename_all = "camelCase")]
1451#[serde(default)]
1452pub struct BkmInitialize {
1453    #[serde(flatten)]
1454    resource: IyzipayResource,
1455
1456    html_content: Option<String>,
1457
1458    token: Option<String>,
1459}
1460
1461impl BkmInitialize {
1462    pub fn create(req: &CreateBkmInitializeRequest, options: &Options) -> Result<BkmInitialize> {
1463        let request = serde_json::to_string(req)?;
1464        debug!("RequestBody:{}", request);
1465        let res = HttpClient::create().post(
1466            format!("{}{}", options.base_url(), "/payment/bkm/initialize").as_str(),
1467            request,
1468            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1469        )?;
1470        let response = res.json()?;
1471        Ok(response)
1472    }
1473
1474    pub fn set_html_content<T: Into<String>>(&mut self, html_content: T) {
1475        self.html_content = Some(html_content.into());
1476    }
1477
1478    pub fn set_token<T: Into<String>>(&mut self, token: T) {
1479        self.token = Some(token.into());
1480    }
1481
1482    pub fn html_content(&self) -> Option<&String> {
1483        self.html_content.as_ref()
1484    }
1485    pub fn token(&self) -> Option<&String> {
1486        self.token.as_ref()
1487    }
1488}
1489
1490impl std::ops::Deref for BkmInitialize {
1491    type Target = IyzipayResource;
1492    fn deref(&self) -> &Self::Target {
1493        &self.resource
1494    }
1495}
1496
1497#[derive(Debug, Default, Serialize, Deserialize)]
1498#[serde(rename_all = "camelCase")]
1499#[serde(default)]
1500pub struct Bkm {
1501    #[serde(flatten)]
1502    resource: IyzipayResource,
1503
1504    token: Option<String>,
1505
1506    callback_url: Option<String>,
1507}
1508
1509impl Bkm {
1510    pub fn retrieve(req: &RetrieveBkmRequest, options: &Options) -> Result<Bkm> {
1511        let request = serde_json::to_string(req)?;
1512        debug!("RequestBody:{}", request);
1513        let res = HttpClient::create().post(
1514            format!("{}{}", options.base_url(), "/payment/bkm/auth/detail").as_str(),
1515            request,
1516            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1517        )?;
1518        let response = res.json()?;
1519        Ok(response)
1520    }
1521
1522    pub fn set_token<T: Into<String>>(&mut self, token: T) {
1523        self.token = Some(token.into());
1524    }
1525
1526    pub fn set_callback_url<T: Into<String>>(&mut self, callback_url: T) {
1527        self.callback_url = Some(callback_url.into());
1528    }
1529
1530    pub fn token(&self) -> Option<&String> {
1531        self.token.as_ref()
1532    }
1533    pub fn callback_url(&self) -> Option<&String> {
1534        self.callback_url.as_ref()
1535    }
1536}
1537
1538impl std::ops::Deref for Bkm {
1539    type Target = IyzipayResource;
1540    fn deref(&self) -> &Self::Target {
1541        &self.resource
1542    }
1543}
1544
1545#[derive(Debug, Default, Serialize, Deserialize)]
1546#[serde(rename_all = "camelCase")]
1547#[serde(default)]
1548pub struct PeccoInitialize {
1549    #[serde(flatten)]
1550    resource: IyzipayResource,
1551
1552    html_content: Option<String>,
1553
1554    redirect_url: Option<String>,
1555
1556    token: Option<String>,
1557
1558    token_expire_time: Option<i64>,
1559}
1560
1561impl PeccoInitialize {
1562    pub fn create(
1563        req: &CreatePeccoInitializeRequest,
1564        options: &Options,
1565    ) -> Result<PeccoInitialize> {
1566        let request = serde_json::to_string(req)?;
1567        debug!("RequestBody:{}", request);
1568        let res = HttpClient::create().post(
1569            format!("{}{}", options.base_url(), "/payment/pecco/initialize").as_str(),
1570            request,
1571            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1572        )?;
1573        let response = res.json()?;
1574        Ok(response)
1575    }
1576
1577    pub fn set_html_content<T: Into<String>>(&mut self, html_content: T) {
1578        self.html_content = Some(html_content.into());
1579    }
1580
1581    pub fn set_redirect_url<T: Into<String>>(&mut self, redirect_url: T) {
1582        self.redirect_url = Some(redirect_url.into());
1583    }
1584
1585    pub fn set_token<T: Into<String>>(&mut self, token: T) {
1586        self.token = Some(token.into());
1587    }
1588
1589    pub fn set_token_expire_time<T: Into<i64>>(&mut self, token_expire_time: T) {
1590        self.token_expire_time = Some(token_expire_time.into());
1591    }
1592
1593    pub fn html_content(&self) -> Option<&String> {
1594        self.html_content.as_ref()
1595    }
1596    pub fn redirect_url(&self) -> Option<&String> {
1597        self.redirect_url.as_ref()
1598    }
1599    pub fn token(&self) -> Option<&String> {
1600        self.token.as_ref()
1601    }
1602    pub fn token_expire_time(&self) -> Option<&i64> {
1603        self.token_expire_time.as_ref()
1604    }
1605}
1606
1607impl std::ops::Deref for PeccoInitialize {
1608    type Target = IyzipayResource;
1609    fn deref(&self) -> &Self::Target {
1610        &self.resource
1611    }
1612}
1613
1614#[derive(Debug, Default, Serialize, Deserialize)]
1615#[serde(rename_all = "camelCase")]
1616#[serde(default)]
1617pub struct PeccoPayment {
1618    #[serde(flatten)]
1619    resource: PaymentResource,
1620
1621    token: Option<String>,
1622}
1623
1624impl PeccoPayment {
1625    pub fn create(req: &CreatePeccoPaymentRequest, options: &Options) -> Result<PeccoPayment> {
1626        let request = serde_json::to_string(req)?;
1627        debug!("RequestBody:{}", request);
1628        let res = HttpClient::create().post(
1629            format!("{}{}", options.base_url(), "/payment/pecco/auth").as_str(),
1630            request,
1631            IyzipayResource::get_http_headers(req.serialize().unwrap_or_default(), &options),
1632        )?;
1633        let response = res.json()?;
1634        Ok(response)
1635    }
1636
1637    pub fn set_token<T: Into<String>>(&mut self, token: T) {
1638        self.token = Some(token.into());
1639    }
1640
1641    pub fn token(&self) -> Option<&String> {
1642        self.token.as_ref()
1643    }
1644}
1645
1646impl std::ops::Deref for PeccoPayment {
1647    type Target = PaymentResource;
1648    fn deref(&self) -> &Self::Target {
1649        &self.resource
1650    }
1651}