diff --git a/package.json b/package.json index 4f47295e..f9b32ca1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hawk.api", - "version": "1.1.28", + "version": "1.1.29", "main": "index.ts", "license": "UNLICENSED", "scripts": { diff --git a/src/billing/cloudpayments.ts b/src/billing/cloudpayments.ts index 1c5150f7..0f54dee9 100644 --- a/src/billing/cloudpayments.ts +++ b/src/billing/cloudpayments.ts @@ -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; @@ -676,7 +688,9 @@ 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 event amount: ${+body.Amount} ${body.Currency} next payment date: ${body.NextTransactionDate} @@ -684,6 +698,7 @@ 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) {