File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -496,7 +496,29 @@ export default class CloudPaymentsWebhooks {
496496 */
497497 if ( data . cloudPayments ?. recurrent ?. startDate ) {
498498 this . handleSendingToTelegramError ( telegram . sendMessage ( `✅ [Billing / Pay] Recurrent payments activated for «${ workspace . name } ». 1 RUB charged` , TelegramBotURLs . Money ) ) ;
499+
499500 await cloudPaymentsApi . cancelPayment ( body . TransactionId ) ;
501+
502+ const member = await this . getMember ( data . userId , workspace ) ;
503+ const plan = await this . getPlan ( req , planId ) ;
504+
505+ /**
506+ * Create business operation about refund
507+ */
508+ await req . context . factories . businessOperationsFactory . create < PayloadOfWorkspacePlanPurchase > ( {
509+ transactionId : body . TransactionId . toString ( ) ,
510+ type : BusinessOperationType . CardLinkRefund ,
511+ status : BusinessOperationStatus . Confirmed ,
512+ payload : {
513+ workspaceId : workspace . _id ,
514+ amount : + body . Amount * PENNY_MULTIPLIER * - 1 ,
515+ currency : body . Currency ,
516+ userId : member . _id ,
517+ tariffPlanId : plan . _id ,
518+ } ,
519+ dtCreated : new Date ( ) ,
520+ } ) ;
521+
500522 this . handleSendingToTelegramError ( telegram . sendMessage ( `✅ [Billing / Pay] Recurrent payments activated for «${ workspace . name } ». 1 RUB returned` , TelegramBotURLs . Money ) ) ;
501523 } else {
502524 /**
You can’t perform that action at this time.
0 commit comments