Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -47,7 +47,7 @@
const PENNY_MULTIPLIER = 100;

interface ComposePaymentRequest extends express.Request {
query: ComposePaymentPayload & { [key: string]: any };

Check warning on line 50 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected any. Specify a different type
context: import('../types/graphql').ResolverContextBase;
};

Expand Down Expand Up @@ -209,7 +209,7 @@
});
}

/**

Check warning on line 212 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Missing JSDoc @returns for function
* Generates invoice id for payment
*
* @param tariffPlan - tariff plan to generate invoice id
Expand Down Expand Up @@ -326,7 +326,7 @@
telegram.sendMessage(`✅ [Billing / Check] All checks passed successfully «${workspace.name}»`, TelegramBotURLs.Money)
.catch(e => console.error('Error while sending message to Telegram: ' + e));

HawkCatcher.send(new Error('[Billing / Check] All checks passed successfully'), body as any);

Check warning on line 329 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected any. Specify a different type

res.json({
code: CheckCodes.SUCCESS,
Expand Down Expand Up @@ -557,14 +557,26 @@

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 @@ -656,7 +668,7 @@

this.handleSendingToTelegramError(telegram.sendMessage(`❌ [Billing / Fail] Transaction failed for «${workspace.name}»`, TelegramBotURLs.Money));

HawkCatcher.send(new Error('[Billing / Fail] Transaction failed'), body as any);

Check warning on line 671 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected any. Specify a different type

res.json({
code: FailCodes.SUCCESS,
Expand All @@ -676,14 +688,17 @@

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}
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 Expand Up @@ -835,7 +850,7 @@
* @param errorText - error description
* @param backtrace - request data and error data
*/
private sendError(res: express.Response, errorCode: CheckCodes | PayCodes | FailCodes | RecurrentCodes, errorText: string, backtrace: { [key: string]: any }): void {

Check warning on line 853 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Unexpected any. Specify a different type
res.json({
code: errorCode,
});
Expand Down Expand Up @@ -900,7 +915,7 @@
promise.catch(e => console.error('Error while sending message to Telegram: ' + e));
}

/**

Check warning on line 918 in src/billing/cloudpayments.ts

View workflow job for this annotation

GitHub Actions / ESlint

Missing JSDoc @returns for function
* Parses body and returns card data
* @param request - request body to parse
*/
Expand Down
Loading