2021-03-23 12:34:34 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Payments::Ui {
|
|
|
|
|
|
|
|
struct LabeledPrice {
|
|
|
|
QString label;
|
2021-03-23 16:06:59 +00:00
|
|
|
int64 price = 0;
|
2021-03-23 12:34:34 +00:00
|
|
|
};
|
|
|
|
|
2021-03-26 13:05:31 +00:00
|
|
|
struct Cover {
|
|
|
|
QString title;
|
|
|
|
QString description;
|
|
|
|
QString seller;
|
|
|
|
QImage thumbnail;
|
|
|
|
};
|
|
|
|
|
2021-03-30 06:01:31 +00:00
|
|
|
struct Receipt {
|
|
|
|
TimeId date = 0;
|
|
|
|
int64 totalAmount = 0;
|
|
|
|
QString currency;
|
|
|
|
bool paid = false;
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
return !paid;
|
|
|
|
}
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:34:34 +00:00
|
|
|
struct Invoice {
|
2021-03-26 13:05:31 +00:00
|
|
|
Cover cover;
|
|
|
|
|
2021-03-23 12:34:34 +00:00
|
|
|
std::vector<LabeledPrice> prices;
|
2021-04-01 11:58:39 +00:00
|
|
|
std::vector<int64> suggestedTips;
|
2021-03-30 14:49:41 +00:00
|
|
|
int64 tipsMax = 0;
|
|
|
|
int64 tipsSelected = 0;
|
2021-03-23 12:34:34 +00:00
|
|
|
QString currency;
|
2021-03-30 06:01:31 +00:00
|
|
|
Receipt receipt;
|
2021-03-23 12:34:34 +00:00
|
|
|
|
|
|
|
bool isNameRequested = false;
|
|
|
|
bool isPhoneRequested = false;
|
|
|
|
bool isEmailRequested = false;
|
|
|
|
bool isShippingAddressRequested = false;
|
|
|
|
bool isFlexible = false;
|
|
|
|
bool isTest = false;
|
|
|
|
|
2021-04-01 14:05:46 +00:00
|
|
|
QString provider;
|
2021-03-23 12:34:34 +00:00
|
|
|
bool phoneSentToProvider = false;
|
|
|
|
bool emailSentToProvider = false;
|
|
|
|
|
|
|
|
[[nodiscard]] bool valid() const {
|
2021-03-30 14:49:41 +00:00
|
|
|
return !currency.isEmpty() && (!prices.empty() || tipsMax);
|
2021-03-23 12:34:34 +00:00
|
|
|
}
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return valid();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-23 16:06:59 +00:00
|
|
|
struct ShippingOption {
|
|
|
|
QString id;
|
|
|
|
QString title;
|
|
|
|
std::vector<LabeledPrice> prices;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ShippingOptions {
|
2021-03-30 17:18:39 +00:00
|
|
|
QString currency;
|
2021-03-23 16:06:59 +00:00
|
|
|
std::vector<ShippingOption> list;
|
|
|
|
QString selectedId;
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:34:34 +00:00
|
|
|
struct Address {
|
|
|
|
QString address1;
|
|
|
|
QString address2;
|
|
|
|
QString city;
|
|
|
|
QString state;
|
|
|
|
QString countryIso2;
|
2021-03-24 11:30:01 +00:00
|
|
|
QString postcode;
|
2021-03-23 12:34:34 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool valid() const {
|
|
|
|
return !address1.isEmpty()
|
|
|
|
&& !city.isEmpty()
|
|
|
|
&& !countryIso2.isEmpty();
|
|
|
|
}
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return valid();
|
|
|
|
}
|
2021-03-23 16:06:59 +00:00
|
|
|
|
|
|
|
inline bool operator==(const Address &other) const {
|
|
|
|
return (address1 == other.address1)
|
|
|
|
&& (address2 == other.address2)
|
|
|
|
&& (city == other.city)
|
|
|
|
&& (state == other.state)
|
|
|
|
&& (countryIso2 == other.countryIso2)
|
2021-03-24 11:30:01 +00:00
|
|
|
&& (postcode == other.postcode);
|
2021-03-23 16:06:59 +00:00
|
|
|
}
|
|
|
|
inline bool operator!=(const Address &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2021-03-23 12:34:34 +00:00
|
|
|
};
|
|
|
|
|
2021-03-23 16:06:59 +00:00
|
|
|
struct RequestedInformation {
|
2021-03-29 12:16:54 +00:00
|
|
|
QString defaultPhone;
|
2021-03-26 17:09:09 +00:00
|
|
|
QString defaultCountry;
|
2021-03-30 17:18:39 +00:00
|
|
|
bool save = true;
|
2021-03-26 17:09:09 +00:00
|
|
|
|
2021-03-23 12:34:34 +00:00
|
|
|
QString name;
|
|
|
|
QString phone;
|
|
|
|
QString email;
|
|
|
|
Address shippingAddress;
|
|
|
|
|
|
|
|
[[nodiscard]] bool empty() const {
|
|
|
|
return name.isEmpty()
|
|
|
|
&& phone.isEmpty()
|
|
|
|
&& email.isEmpty()
|
|
|
|
&& !shippingAddress;
|
|
|
|
}
|
|
|
|
[[nodiscard]] explicit operator bool() const {
|
|
|
|
return !empty();
|
|
|
|
}
|
2021-03-23 16:06:59 +00:00
|
|
|
|
|
|
|
inline bool operator==(const RequestedInformation &other) const {
|
|
|
|
return (name == other.name)
|
|
|
|
&& (phone == other.phone)
|
|
|
|
&& (email == other.email)
|
|
|
|
&& (shippingAddress == other.shippingAddress);
|
|
|
|
}
|
|
|
|
inline bool operator!=(const RequestedInformation &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
2021-03-23 12:34:34 +00:00
|
|
|
};
|
|
|
|
|
2021-03-25 15:27:30 +00:00
|
|
|
enum class InformationField {
|
2021-03-24 11:30:01 +00:00
|
|
|
ShippingStreet,
|
|
|
|
ShippingCity,
|
|
|
|
ShippingState,
|
|
|
|
ShippingCountry,
|
|
|
|
ShippingPostcode,
|
2021-03-23 16:06:59 +00:00
|
|
|
Name,
|
|
|
|
Email,
|
|
|
|
Phone,
|
|
|
|
};
|
|
|
|
|
2021-03-25 16:58:52 +00:00
|
|
|
struct NativeMethodDetails {
|
2021-03-26 17:09:09 +00:00
|
|
|
QString defaultCountry;
|
|
|
|
|
2021-03-25 15:27:30 +00:00
|
|
|
bool supported = false;
|
|
|
|
bool needCountry = false;
|
|
|
|
bool needZip = false;
|
|
|
|
bool needCardholderName = false;
|
2021-03-31 17:15:49 +00:00
|
|
|
bool canSaveInformation = false;
|
2021-03-25 15:27:30 +00:00
|
|
|
};
|
|
|
|
|
2021-03-25 16:58:52 +00:00
|
|
|
struct PaymentMethodDetails {
|
|
|
|
QString title;
|
|
|
|
NativeMethodDetails native;
|
|
|
|
QString url;
|
2021-04-01 14:39:44 +00:00
|
|
|
QString provider;
|
2021-03-25 16:58:52 +00:00
|
|
|
bool ready = false;
|
2021-03-31 17:15:49 +00:00
|
|
|
bool canSaveInformation = false;
|
2021-03-25 16:58:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-25 15:27:30 +00:00
|
|
|
enum class CardField {
|
|
|
|
Number,
|
2021-03-29 12:16:54 +00:00
|
|
|
Cvc,
|
2021-03-25 15:27:30 +00:00
|
|
|
ExpireDate,
|
|
|
|
Name,
|
|
|
|
AddressCountry,
|
|
|
|
AddressZip,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct UncheckedCardDetails {
|
|
|
|
QString number;
|
|
|
|
QString cvc;
|
|
|
|
uint32 expireYear = 0;
|
|
|
|
uint32 expireMonth = 0;
|
|
|
|
QString cardholderName;
|
|
|
|
QString addressCountry;
|
|
|
|
QString addressZip;
|
|
|
|
};
|
|
|
|
|
2021-03-23 12:34:34 +00:00
|
|
|
} // namespace Payments::Ui
|