Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hawk.api",
"version": "1.1.28",
"version": "1.1.29",
"main": "index.ts",
"license": "UNLICENSED",
"scripts": {
Expand Down
23 changes: 19 additions & 4 deletions src/billing/cloudpayments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,26 @@ plan monthly charge: ${data.cloudPayments?.recurrent.amount} ${body.Currency}`

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

this.handleSendingToTelegramError(telegram.sendMessage(`✅ [Billing / Pay] New payment
let messageText = '';

if (data.cloudPayments?.recurrent.startDate) {
messageText = `✅ [Billing / Pay] New payment

amount: ${+body.Amount} ${body.Currency}
next payment date: ${data.cloudPayments?.recurrent.startDate}
workspace id: ${workspace._id}
date of operation: ${body.DateTime}
subscription id: ${body.SubscriptionId}`
, TelegramBotURLs.Money));
subscription id: ${body.SubscriptionId}`;
} else {
messageText = `✅ [Billing / Pay] New Recurrent payment

amount: ${+body.Amount} ${body.Currency}
workspace id: ${workspace._id}
date of operation: ${body.DateTime}
subscription id: ${body.SubscriptionId}`;
}

this.handleSendingToTelegramError(telegram.sendMessage(messageText, TelegramBotURLs.Money));
}
} catch (e) {
const error = e as Error;
Expand Down Expand Up @@ -676,14 +688,17 @@ subscription id: ${body.SubscriptionId}`

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

this.handleSendingToTelegramError(telegram.sendMessage(`✅ [Billing / Recurrent] New recurrent transaction
const emoji = [SubscriptionStatus.CANCELLED, SubscriptionStatus.REJECTED].includes(body.Status) ? '❌' : '✅';

this.handleSendingToTelegramError(telegram.sendMessage(`${emoji} [Billing / Recurrent] New recurrent transaction

amount: ${+body.Amount} ${body.Currency}
next payment date: ${body.NextTransactionDate}
workspace id: ${body.AccountId}
subscription id: ${body.Id}
status: ${body.Status}`
, TelegramBotURLs.Money));

HawkCatcher.send(new Error(`[Billing / Recurrent] New recurrent event with ${body.Status} status`), req.body);

switch (body.Status) {
Expand Down