mercadopago_sdk_rust/payments/
responses.rs

1use serde::{Deserialize, Serialize};
2
3use crate::common_types::{Card, CurrencyId};
4use crate::payments::requests::{AdditionalInfo, BuyerIdentification};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct CreatePaymentResponse {
8    pub additional_info: Option<AdditionalInfo>,
9    pub card: Card,
10    pub collector_id: i64,
11    pub coupon_amount: i64,
12    pub currency_id: CurrencyId,
13    pub date_approved: String,
14    pub date_created: String,
15    pub date_last_updated: String,
16    pub description: String,
17    pub external_reference: String,
18    pub fee_details: Vec<FeeDetail>,
19    pub id: i64,
20    pub installments: i64,
21    pub issuer_id: i64,
22    pub metadata: Option<serde_json::Value>,
23    pub money_release_date: String,
24    pub notification_url: String,
25    pub order: Order,
26    pub payer: BuyerIdentification,
27    pub payment_method_id: String,
28    pub payment_type_id: String,
29    pub point_of_interaction: PointOfInteraction,
30    pub processing_mode: String,
31    pub shipping_amount: i64,
32    pub statement_descriptor: String,
33    pub status: String,
34    pub status_detail: String,
35    pub taxes_amount: i64,
36    pub transaction_amount: f64,
37    pub transaction_amount_refunded: i64,
38    pub transaction_details: TransactionDetails,
39}
40
41#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
42pub struct Order {}
43
44#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
45pub struct TransactionDetails {
46    pub net_received_amount: f64,
47    pub total_paid_amount: f64,
48    pub overpaid_amount: i64,
49    pub installment_amount: f64,
50}
51
52#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
53pub struct FeeDetail {
54    #[serde(rename = "type")]
55    pub type_field: String,
56    pub amount: f64,
57    pub fee_payer: String,
58}
59
60#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
61pub struct PointOfInteraction {
62    #[serde(rename = "type")]
63    pub type_field: String,
64    pub application_data: ApplicationData,
65    pub transaction_data: TransactionData,
66}
67
68#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
69pub struct ApplicationData {
70    pub name: String,
71    pub version: String,
72}
73
74#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
75pub struct TransactionData {
76    pub qr_code_base64: String,
77    pub qr_code: String,
78    pub ticket_url: String,
79}
80#[cfg(test)]
81mod tests {
82    use super::*;
83
84    #[test]
85    fn t_payload_serialization() {
86        let payload = serde_json::from_slice::<CreatePaymentResponse>(include_bytes!(
87            "../../tests/assets/create_payment_response.json"
88        ))
89        .unwrap();
90        println!("{:?}", payload);
91    }
92}