@@ -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
562565amount: ${ + body . Amount } ${ body . Currency }
563566next payment date: ${ data . cloudPayments ?. recurrent . startDate }
564567workspace id: ${ workspace . _id }
565568date of operation: ${ body . DateTime }
566569subscription 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
681697amount: ${ + body . Amount } ${ body . Currency }
682698next payment date: ${ body . NextTransactionDate }
683699workspace id: ${ body . AccountId }
684700subscription id: ${ body . Id }
685701status: ${ 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