mercadopago_sdk_rust/preferences/
responses.rs

1use serde::{Deserialize, Serialize};
2use serde_aux::prelude::*;
3
4use crate::common_types::{BackUrls, CheckoutProPayer, Item, PaymentMethods, Shipments};
5
6#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7pub struct CheckoutProPreferencesResponse {
8    #[serde(deserialize_with = "deserialize_number_from_string")]
9    pub client_id: i64,
10    pub collector_id: i64,
11
12    pub items: Vec<Item>,
13    pub payer: CheckoutProPayer,
14    pub back_urls: BackUrls,
15    pub payment_methods: PaymentMethods,
16    pub marketplace: String,
17    pub marketplace_fee: i64,
18    pub shipments: Shipments,
19
20    /// Description that the payment will appear with in the card statement.
21    pub statement_descriptor: Option<String>,
22
23    #[serde(with = "time::serde::rfc3339")]
24    pub date_created: time::OffsetDateTime,
25
26    /// Autogenerated unique ID that identifies the preference.
27    /// For example: 036151801-2484cd71-7140-4c51-985a-d4cfcf133baf
28    #[serde(rename = "id")]
29    pub preference_id: String,
30
31    /// Automatically generated URL to open the Checkout.
32    #[serde(rename = "init_point")]
33    pub checkout_url: String,
34
35    /// Automatically generated URL to open the Checkout in sandbox mode. Real users are used here,
36    /// but transactions are executed using test credentials.
37    #[serde(rename = "sandbox_init_point")]
38    pub checkout_sandbox_url: String,
39
40    /// Website locale. Example: MLB
41    pub site_id: Option<String>,
42
43    /// Valid JSON that can be added to the payment to save additional attributes
44    pub metadata: Option<serde_json::Value>,
45}
46
47#[cfg(test)]
48mod tests {
49    use super::*;
50
51    #[test]
52    fn t_deserialization() {
53        let response = serde_json::from_slice::<CheckoutProPreferencesResponse>(include_bytes!(
54            "../../tests/assets/checkout_preferences_response.json"
55        ));
56
57        assert!(response.is_ok())
58    }
59}