Skip to content

Commit d0f752d

Browse files
committed
Fix messages
1 parent 5eb4f34 commit d0f752d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

src/billing/cloudpayments.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,28 @@ plan monthly charge: ${data.cloudPayments?.recurrent.amount} ${body.Currency}`
557557

558558
await this.sendReceipt(workspace, tariffPlan, userEmail);
559559

560-
this.handleSendingToTelegramError(telegram.sendMessage(`✅ [Billing / Pay] New payment
560+
let messageText = ''
561+
562+
if (data.cloudPayments?.recurrent.startDate) {
563+
messageText = `✅ [Billing / Pay] New payment
561564
562565
amount: ${+body.Amount} ${body.Currency}
563566
next payment date: ${data.cloudPayments?.recurrent.startDate}
564567
workspace id: ${workspace._id}
565568
date of operation: ${body.DateTime}
566569
subscription id: ${body.SubscriptionId}`
567-
, TelegramBotURLs.Money));
570+
571+
} else {
572+
messageText = `✅ [Billing / Pay] New Recurrent payment
573+
574+
amount: ${+body.Amount} ${body.Currency}
575+
workspace id: ${workspace._id}
576+
date of operation: ${body.DateTime}
577+
subscription id: ${body.SubscriptionId}`
578+
579+
}
580+
581+
this.handleSendingToTelegramError(telegram.sendMessage(messageText, TelegramBotURLs.Money));
568582
}
569583
} catch (e) {
570584
const error = e as Error;
@@ -676,14 +690,17 @@ subscription id: ${body.SubscriptionId}`
676690

677691
console.log('💎 CloudPayments /recurrent request', body);
678692

679-
this.handleSendingToTelegramError(telegram.sendMessage(`✅ [Billing / Recurrent] New recurrent transaction
693+
const emoji = [SubscriptionStatus.CANCELLED, SubscriptionStatus.REJECTED].includes(body.Status) ? '❌' : '✅';
694+
695+
this.handleSendingToTelegramError(telegram.sendMessage(`${emoji} [Billing / Recurrent] New recurrent transaction
680696
681697
amount: ${+body.Amount} ${body.Currency}
682698
next payment date: ${body.NextTransactionDate}
683699
workspace id: ${body.AccountId}
684700
subscription id: ${body.Id}
685701
status: ${body.Status}`
686702
, TelegramBotURLs.Money));
703+
687704
HawkCatcher.send(new Error(`[Billing / Recurrent] New recurrent event with ${body.Status} status`), req.body);
688705

689706
switch (body.Status) {

0 commit comments

Comments
 (0)