tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
SuccessfulPayment.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
9 SuccessfulPayment() = default;
10 explicit SuccessfulPayment(const nl::json& json) {
11 fromJson(json);
12 }
13
16 std::string currency;
17
22 std::int32_t totalAmount{};
23
25 std::string invoicePayload;
26
28 std::string shippingOptionId;
29
32
35
38
39
42 nl::json toJson() const {
43 nl::json json = nl::json::object();
44 OBJECT_SERIALIZE_FIELD(json, "currency", currency);
45 OBJECT_SERIALIZE_FIELD(json, "total_amount", totalAmount);
46 OBJECT_SERIALIZE_FIELD(json, "invoice_payload", invoicePayload);
47 OBJECT_SERIALIZE_FIELD(json, "shipping_option_id", shippingOptionId);
48 OBJECT_SERIALIZE_FIELD_PTR(json, "order_info", orderInfo);
49 OBJECT_SERIALIZE_FIELD(json, "telegram_payment_charge_id", telegramPaymentChargeId);
50 OBJECT_SERIALIZE_FIELD(json, "provider_payment_charge_id", providerPaymentChargeId);
51 return json;
52 }
53
55 void fromJson(const nl::json& json) {
56 OBJECT_DESERIALIZE_FIELD(json, "currency", currency, "", false);
57 OBJECT_DESERIALIZE_FIELD(json, "total_amount", totalAmount, 0, false);
58 OBJECT_DESERIALIZE_FIELD(json, "invoice_payload", invoicePayload, "", false);
59 OBJECT_DESERIALIZE_FIELD(json, "shipping_option_id", shippingOptionId, "", true);
60 OBJECT_DESERIALIZE_FIELD_PTR(json, "order_info", orderInfo, true);
61 OBJECT_DESERIALIZE_FIELD(json, "telegram_payment_charge_id", telegramPaymentChargeId, "", false);
62 OBJECT_DESERIALIZE_FIELD(json, "provider_payment_charge_id", providerPaymentChargeId, "", false);
63 }
64 };
65}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:70
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:44
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object contains basic information about a successful payment. https://core.telegram....
std::string providerPaymentChargeId
Provider payment identifier.
nl::json toJson() const
Serializes this object to JSON.
std::string currency
Three-letter ISO 4217 currency code https://core.telegram.org/bots/payments#supported-currencies .
std::string shippingOptionId
Optional. Identifier of the shipping option chosen by the user.
Ptr< OrderInfo > orderInfo
Optional. Order information provided by the user.
SuccessfulPayment(const nl::json &json)
std::int32_t totalAmount
Total price in the smallest units of the currency (integer, not float/double). For example,...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string telegramPaymentChargeId
Telegram payment identifier.
std::string invoicePayload
Bot specified invoice payload.