@@ -45,10 +45,9 @@ import PlanModel from '../models/plan';
4545import { ClientApi , ClientService , CustomerReceiptItem , ReceiptApi , ReceiptTypes , TaxationSystem } from 'cloudpayments' ;
4646import { ComposePaymentPayload } from './types/composePaymentPayload' ;
4747
48-
4948interface ComposePaymentRequest extends express . Request {
5049 query : ComposePaymentPayload & { [ key : string ] : any } ;
51- context : import ( '../types/graphql' ) . ResolverContextBase
50+ context : import ( '../types/graphql' ) . ResolverContextBase ;
5251} ;
5352
5453/**
@@ -129,13 +128,13 @@ export default class CloudPaymentsWebhooks {
129128 await this . getMember ( userId , workspace ) ;
130129 } catch ( e ) {
131130 const error = e as Error ;
132-
131+
133132 this . sendError ( res , 1 , `[Billing / Compose payment] Can't compose payment due to error: ${ error . toString ( ) } ` , req . query ) ;
134-
133+
135134 return ;
136135 }
137136 const invoiceId = this . generateInvoiceId ( tariffPlan , workspace ) ;
138-
137+
139138 const isCardLinkOperation = workspace . tariffPlanId . toString ( ) === tariffPlanId && ! this . isPlanExpired ( workspace ) ;
140139
141140 let checksum ;
@@ -150,7 +149,7 @@ export default class CloudPaymentsWebhooks {
150149 userId : userId ,
151150 tariffPlanId : tariffPlan . _id . toString ( ) ,
152151 shouldSaveCard : shouldSaveCard === 'true' ,
153- }
152+ } ;
154153
155154 checksum = await checksumService . generateChecksum ( checksumData ) ;
156155 } catch ( e ) {
@@ -187,9 +186,8 @@ export default class CloudPaymentsWebhooks {
187186 planExpiracyDate = lastChargeDate . setDate ( lastChargeDate . getDate ( ) + 1 ) ;
188187 } else {
189188 planExpiracyDate = lastChargeDate . setMonth ( lastChargeDate . getMonth ( ) + 1 ) ;
190-
191189 }
192-
190+
193191 const isPlanExpired = planExpiracyDate < Date . now ( ) ;
194192
195193 return isPlanExpired ;
@@ -803,7 +801,7 @@ export default class CloudPaymentsWebhooks {
803801 tariffPlanId : workspace . tariffPlanId . toString ( ) ,
804802 userId,
805803 shouldSaveCard : false ,
806- isCardLinkOperation : false
804+ isCardLinkOperation : false ,
807805 } ;
808806 }
809807
0 commit comments