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