mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Support recurring payment phrases.
This commit is contained in:
parent
1ba2bdab21
commit
092474fdb9
7 changed files with 55 additions and 18 deletions
|
@ -1426,6 +1426,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_action_game_you_scored_no_game#other" = "You scored {count}";
|
"lng_action_game_you_scored_no_game#other" = "You scored {count}";
|
||||||
"lng_action_payment_done" = "You have just successfully transferred {amount} to {user}";
|
"lng_action_payment_done" = "You have just successfully transferred {amount} to {user}";
|
||||||
"lng_action_payment_done_for" = "You have just successfully transferred {amount} to {user} for {invoice}";
|
"lng_action_payment_done_for" = "You have just successfully transferred {amount} to {user} for {invoice}";
|
||||||
|
"lng_action_payment_init_recurring_for" = "You have just successfully transferred {amount} to {user} for {invoice} and allowed future recurring payments";
|
||||||
|
"lng_action_payment_init_recurring" = "You have just successfully transferred {amount} to {user} and allowed future recurring payments";
|
||||||
|
"lng_action_payment_used_recurring" = "You were charged {amount} via recurring payment";
|
||||||
"lng_action_took_screenshot" = "{from} took a screenshot!";
|
"lng_action_took_screenshot" = "{from} took a screenshot!";
|
||||||
"lng_action_you_took_screenshot" = "You took a screenshot!";
|
"lng_action_you_took_screenshot" = "You took a screenshot!";
|
||||||
"lng_action_bot_allowed_from_domain" = "You allowed this bot to message you when you logged in on {domain}.";
|
"lng_action_bot_allowed_from_domain" = "You allowed this bot to message you when you logged in on {domain}.";
|
||||||
|
|
|
@ -1023,6 +1023,8 @@ ServiceAction ParseServiceAction(
|
||||||
auto content = ActionPaymentSent();
|
auto content = ActionPaymentSent();
|
||||||
content.currency = ParseString(data.vcurrency());
|
content.currency = ParseString(data.vcurrency());
|
||||||
content.amount = data.vtotal_amount().v;
|
content.amount = data.vtotal_amount().v;
|
||||||
|
content.recurringInit = data.is_recurring_init();
|
||||||
|
content.recurringUsed = data.is_recurring_used();
|
||||||
result.content = content;
|
result.content = content;
|
||||||
}, [&](const MTPDmessageActionPhoneCall &data) {
|
}, [&](const MTPDmessageActionPhoneCall &data) {
|
||||||
auto content = ActionPhoneCall();
|
auto content = ActionPhoneCall();
|
||||||
|
|
|
@ -401,6 +401,8 @@ struct ActionGameScore {
|
||||||
struct ActionPaymentSent {
|
struct ActionPaymentSent {
|
||||||
Utf8String currency;
|
Utf8String currency;
|
||||||
uint64 amount = 0;
|
uint64 amount = 0;
|
||||||
|
bool recurringInit = false;
|
||||||
|
bool recurringUsed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ActionPhoneCall {
|
struct ActionPhoneCall {
|
||||||
|
|
|
@ -1001,10 +1001,18 @@ auto HtmlWriter::Wrap::pushMessage(
|
||||||
+ " in "
|
+ " in "
|
||||||
+ wrapReplyToLink("this game");
|
+ wrapReplyToLink("this game");
|
||||||
}, [&](const ActionPaymentSent &data) {
|
}, [&](const ActionPaymentSent &data) {
|
||||||
return "You have successfully transferred "
|
const auto amount = FormatMoneyAmount(data.amount, data.currency);
|
||||||
+ FormatMoneyAmount(data.amount, data.currency)
|
if (data.recurringUsed) {
|
||||||
|
return "You were charged " + amount + " via recurring payment";
|
||||||
|
}
|
||||||
|
auto result = "You have successfully transferred "
|
||||||
|
+ amount
|
||||||
+ " for "
|
+ " for "
|
||||||
+ wrapReplyToLink("this invoice");
|
+ wrapReplyToLink("this invoice");
|
||||||
|
if (data.recurringInit) {
|
||||||
|
result += " and allowed future recurring payments";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}, [&](const ActionPhoneCall &data) {
|
}, [&](const ActionPhoneCall &data) {
|
||||||
return QByteArray();
|
return QByteArray();
|
||||||
}, [&](const ActionScreenshotTaken &data) {
|
}, [&](const ActionScreenshotTaken &data) {
|
||||||
|
|
|
@ -430,7 +430,13 @@ QByteArray SerializeMessage(
|
||||||
pushAction("send_payment");
|
pushAction("send_payment");
|
||||||
push("amount", data.amount);
|
push("amount", data.amount);
|
||||||
push("currency", data.currency);
|
push("currency", data.currency);
|
||||||
|
const auto amount = FormatMoneyAmount(data.amount, data.currency);
|
||||||
pushReplyToMsgId("invoice_message_id");
|
pushReplyToMsgId("invoice_message_id");
|
||||||
|
if (data.recurringUsed) {
|
||||||
|
push("recurring", "used");
|
||||||
|
} else if (data.recurringInit) {
|
||||||
|
push("recurring", "init");
|
||||||
|
}
|
||||||
}, [&](const ActionPhoneCall &data) {
|
}, [&](const ActionPhoneCall &data) {
|
||||||
pushActor();
|
pushActor();
|
||||||
pushAction("phone_call");
|
pushAction("phone_call");
|
||||||
|
|
|
@ -1048,23 +1048,35 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
if (invoiceTitle.text.isEmpty()) {
|
if (invoiceTitle.text.isEmpty()) {
|
||||||
result.text = tr::lng_action_payment_done(
|
if (payment->recurringUsed) {
|
||||||
tr::now,
|
result.text = tr::lng_action_payment_used_recurring(
|
||||||
lt_amount,
|
tr::now,
|
||||||
{ .text = payment->amount },
|
lt_amount,
|
||||||
lt_user,
|
{ .text = payment->amount },
|
||||||
{ .text = history()->peer->name },
|
Ui::Text::WithEntities);
|
||||||
Ui::Text::WithEntities);
|
} else {
|
||||||
|
result.text = (payment->recurringInit
|
||||||
|
? tr::lng_action_payment_init_recurring
|
||||||
|
: tr::lng_action_payment_done)(
|
||||||
|
tr::now,
|
||||||
|
lt_amount,
|
||||||
|
{ .text = payment->amount },
|
||||||
|
lt_user,
|
||||||
|
{ .text = history()->peer->name },
|
||||||
|
Ui::Text::WithEntities);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
result.text = tr::lng_action_payment_done_for(
|
result.text = (payment->recurringInit
|
||||||
tr::now,
|
? tr::lng_action_payment_init_recurring_for
|
||||||
lt_amount,
|
: tr::lng_action_payment_done_for)(
|
||||||
{ .text = payment->amount },
|
tr::now,
|
||||||
lt_user,
|
lt_amount,
|
||||||
{ .text = history()->peer->name },
|
{ .text = payment->amount },
|
||||||
lt_invoice,
|
lt_user,
|
||||||
invoiceTitle,
|
{ .text = history()->peer->name },
|
||||||
Ui::Text::WithEntities);
|
lt_invoice,
|
||||||
|
invoiceTitle,
|
||||||
|
Ui::Text::WithEntities);
|
||||||
if (payment->msg) {
|
if (payment->msg) {
|
||||||
result.links.push_back(payment->lnk);
|
result.links.push_back(payment->lnk);
|
||||||
}
|
}
|
||||||
|
@ -1363,6 +1375,8 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) {
|
||||||
const auto id = fullId();
|
const auto id = fullId();
|
||||||
const auto owner = &history()->owner();
|
const auto owner = &history()->owner();
|
||||||
payment->slug = data.vinvoice_slug().value_or_empty();
|
payment->slug = data.vinvoice_slug().value_or_empty();
|
||||||
|
payment->recurringInit = data.is_recurring_init();
|
||||||
|
payment->recurringUsed = data.is_recurring_used();
|
||||||
payment->amount = Ui::FillAmountAndCurrency(amount, currency);
|
payment->amount = Ui::FillAmountAndCurrency(amount, currency);
|
||||||
payment->invoiceLink = std::make_shared<LambdaClickHandler>([=](
|
payment->invoiceLink = std::make_shared<LambdaClickHandler>([=](
|
||||||
ClickContext context) {
|
ClickContext context) {
|
||||||
|
|
|
@ -37,6 +37,8 @@ struct HistoryServicePayment
|
||||||
QString slug;
|
QString slug;
|
||||||
QString amount;
|
QString amount;
|
||||||
ClickHandlerPtr invoiceLink;
|
ClickHandlerPtr invoiceLink;
|
||||||
|
bool recurringInit = false;
|
||||||
|
bool recurringUsed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HistoryServiceSelfDestruct
|
struct HistoryServiceSelfDestruct
|
||||||
|
|
Loading…
Add table
Reference in a new issue