telbot_types/payment.rs
1use serde::{Deserialize, Serialize};
2
3use crate::user::User;
4
5/// This object contains information about an incoming shipping query.
6#[derive(Debug, Deserialize)]
7pub struct ShippingQuery {
8 /// Unique query identifier
9 pub id: String,
10 /// User who sent the query
11 pub from: User,
12 /// Bot specified invoice payload
13 pub invoice_payload: String,
14 /// User specified shipping address
15 pub shipping_address: ShippingAddress,
16}
17
18/// This object contains information about an incoming pre-checkout query.
19#[derive(Debug, Deserialize)]
20pub struct PreCheckoutQuery {
21 /// Unique query identifier
22 pub id: String,
23 /// User who sent the query
24 pub from: User,
25 /// Three-letter ISO 4217 [currency](https://core.telegram.org/bots/payments#supported-currencies) code
26 pub currency: String,
27 /// Total price in the smallest units of the currency (integer, *not* float/double).
28 /// For example, for a price of `US$ 1.45` pass `amount = 145`.
29 /// See the exp parameter in [currencies.json](https://core.telegram.org/bots/payments/currencies.json),
30 /// it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
31 pub total_amount: i32,
32 /// Bot specified invoice payload
33 pub invoice_payload: String,
34 /// Identifier of the shipping option chosen by the user
35 pub shipping_option_id: Option<String>,
36 /// Order info provided by the user
37 pub order_info: Option<OrderInfo>,
38}
39
40/// This object contains basic information about an invoice.
41#[derive(Debug, Deserialize)]
42pub struct Invoice {
43 /// Product name
44 pub title: String,
45 /// Product description
46 pub description: String,
47 /// Unique bot deep-linking parameter that can be used to generate this invoice
48 pub start_parameter: String,
49 /// Three-letter ISO 4217 [currency](https://core.telegram.org/bots/payments#supported-currencies) code
50 pub currency: String,
51 /// Total price in the smallest units of the currency (integer, **not** float/double).
52 /// For example, for a price of `US$ 1.45` pass `amount = 145`.
53 /// See the *exp* parameter in [currencies.json](https://core.telegram.org/bots/payments/currencies.json),
54 /// it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
55 pub total_amount: i32,
56}
57
58/// This object represents a shipping address.
59#[derive(Debug, Deserialize)]
60pub struct ShippingAddress {
61 /// ISO 3166-1 alpha-2 country code
62 pub country_code: String,
63 /// State, if applicable
64 pub state: String,
65 /// City
66 pub city: String,
67 /// First line for the address
68 pub street_line1: String,
69 /// Second line for the address
70 pub street_line2: String,
71 /// Address post code
72 pub post_code: String,
73}
74
75/// This object contains basic information about a successful payment.
76#[derive(Debug, Deserialize)]
77pub struct SuccessfulPayment {
78 /// Three-letter ISO 4217 [currency](https://core.telegram.org/bots/payments#supported-currencies) code
79 pub currency: String,
80 /// Total price in the smallest units of the currency (integer, **not** float/double).
81 /// For example, for a price of `US$ 1.45` pass `amount = 145`.
82 /// See the exp parameter in [currencies.json](https://core.telegram.org/bots/payments/currencies.json),
83 /// it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
84 pub total_amount: i32,
85 /// Bot specified invoice payload
86 pub invoice_payload: String,
87 /// Identifier of the shipping option chosen by the user
88 pub shipping_option_id: Option<String>,
89 /// Order info provided by the user
90 pub order_info: Option<OrderInfo>,
91 /// Telegram payment identifier
92 pub telegram_payment_charge_id: String,
93 /// Provider payment identifier
94 pub provider_payment_charge_id: String,
95}
96
97/// This object represents information about an order.
98#[derive(Debug, Deserialize)]
99pub struct OrderInfo {
100 /// User name
101 pub name: Option<String>,
102 /// User's phone number
103 pub phone_number: Option<String>,
104 /// User email
105 pub email: Option<String>,
106 /// User shipping address
107 pub shipping_address: Option<ShippingAddress>,
108}
109
110/// This object represents one shipping option.
111#[derive(Debug, Deserialize)]
112pub struct ShippingOption {
113 /// Shipping option identifier
114 pub id: String,
115 /// Option title
116 pub title: String,
117 /// List of price portions
118 pub prices: Vec<LabeledPrice>,
119}
120
121/// This object represents a portion of the price for goods or services.
122#[derive(Debug, Clone, Serialize, Deserialize)]
123pub struct LabeledPrice {
124 /// Portion label
125 label: String,
126 /// Price of the product in the smallest units of the currency (integer, **not** float/double).
127 // For example, for a price of `US$ 1.45` pass `amount = 145`.
128 /// See the exp parameter in [currencies.json](https://core.telegram.org/bots/payments/currencies.json),
129 /// it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
130 amount: i32,
131}