tango-app-api-payment-subscription 3.0.12-dev → 3.0.13-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-payment-subscription",
3
- "version": "3.0.12-dev",
3
+ "version": "3.0.13-dev",
4
4
  "description": "paymentSubscription",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,10 +1,14 @@
1
- import { logger, download } from 'tango-app-api-middleware';
1
+ import { logger, download, sendEmailWithSES } from 'tango-app-api-middleware';
2
2
  import * as paymentService from '../services/clientPayment.services.js';
3
3
  import * as storeService from '../services/store.service.js';
4
4
  import * as basePricingService from '../services/basePrice.service.js';
5
5
  import * as clientRequestService from '../services/clientRequest.service.js';
6
6
  import * as invoiceService from '../services/invoice.service.js';
7
7
  import dayjs from 'dayjs';
8
+ import appConfig from '../../config/env/env.js';
9
+ import Handlebars from 'handlebars';
10
+ import fs from 'fs';
11
+ import path from 'path';
8
12
 
9
13
 
10
14
  export const addBilling = async ( req, res ) => {
@@ -317,7 +321,7 @@ export const updateSubscriptionOLD = async ( req, res ) => {
317
321
  }
318
322
  if ( element.type == 'trial' ) {
319
323
  let params = {
320
- user: '65e966e12b1991393cf8ce30', // need to login user id here
324
+ user: req.user._id, // need to login user id here
321
325
  clientId: req.body.clientId,
322
326
  name: element.productName,
323
327
  description: 'Request for Trial',
@@ -360,7 +364,7 @@ export const updateSubscription = async ( req, res ) => {
360
364
  let existsIndex = clientProducts.findIndex( ( ele ) => ele.productName == item.name );
361
365
  if ( item.type == 'startTrial' && existsIndex == -1 ) {
362
366
  let params = {
363
- user: '65e966e12b1991393cf8ce30', // need to login user id here
367
+ user: req.user._id, // need to login user id here
364
368
  clientId: requestBody.clientId,
365
369
  name: item.name,
366
370
  description: 'Request for Trial',
@@ -393,49 +397,6 @@ export const updateSubscription = async ( req, res ) => {
393
397
  product: clientProducts,
394
398
  };
395
399
 
396
- // for ( let i = 0; i < requestBody.product.length; i++ ) {
397
- // if ( requestBody.currentPlanInfo.product[i].status == 'live' && requestBody.currentPlanInfo.product[i].active == true ) {};
398
- // if ( requestBody.currentPlanInfo.product[i].status == 'trial' && requestBody.currentPlanInfo.product[i].active == true ) {
399
- // if ( requestBody.currentPlanInfo.product[i].confirmation == 'subscribenow' ) {
400
- // requestBody.currentPlanInfo.product[i].subscribedDate = new Date();
401
- // requestBody.currentPlanInfo.product[i].status = 'live';
402
- // requestBody.currentPlanInfo.product[i].trialStartDate = requestBody.currentPlanInfo.product[i]?.trialStartDate || '';
403
- // requestBody.currentPlanInfo.product[i].trialEndDate = requestBody.currentPlanInfo.product[i]?.trialEndDate || '';
404
- // }
405
- // };
406
- // if ( requestBody.currentPlanInfo.product[i].active == true && !requestBody.currentPlanInfo.product[i].hasOwnProperty( 'status' ) ) {
407
- // if ( requestBody.currentPlanInfo.product[i].confirmation == 'subscribenow' ) {
408
- // requestBody.currentPlanInfo.product[i].subscribedDate = new Date();
409
- // requestBody.currentPlanInfo.product[i].status = 'live';
410
- // requestBody.currentPlanInfo.product[i].trialStartDate = requestBody.currentPlanInfo.product[i]?.trialStartDate || '';
411
- // requestBody.currentPlanInfo.product[i].trialEndDate = requestBody.currentPlanInfo.product[i]?.trialEndDate || '';
412
- // }
413
- // if ( requestBody.currentPlanInfo.product[i].confirmation == 'starttrail' ) {
414
- // requestBody.currentPlanInfo.product[i].status = 'trial';
415
- // let params = {
416
- // user: '65e966e12b1991393cf8ce30', // need to login user id here
417
- // clientId: requestBody.clientId,
418
- // name: requestBody.currentPlanInfo.product[i].productName,
419
- // description: 'Request for Trial',
420
- // category: 'Trial',
421
- // status: 'pending',
422
- // };
423
- // await clientRequestService.insert( params );
424
- // }
425
- // if ( requestBody.currentPlanInfo.product[i].confirmation == 'doitlater' ) {
426
- // // need to do price changes
427
- // requestBody.currentPlanInfo.product.splice( i, 1 );
428
- // }
429
- // }
430
- // }
431
-
432
- // for ( let j = 0; j < requestBody.currentPlanInfo.product.length; j++ ) {
433
- // delete requestBody.currentPlanInfo.product[j]?.aliseProductName;
434
- // delete requestBody.currentPlanInfo.product[j]?.toolTip;
435
- // delete requestBody.currentPlanInfo.product[j]?.active;
436
- // delete requestBody.currentPlanInfo.product[j]?.confirmation;
437
- // }
438
-
439
400
  let data = {
440
401
  planDetails: details,
441
402
  price: requestBody.price,
@@ -507,7 +468,7 @@ export const unsubscribeProduct = async ( req, res ) => {
507
468
  return res.sendSuccess( 'Request is Already initiated waiting for admin approval' );
508
469
  }
509
470
  let params = {
510
- user: '65e966e12b1991393cf8ce30', // need to login user id here
471
+ user: req.user._id, // need to login user id here
511
472
  clientId: req.body.clientId,
512
473
  reason: req.body.reason,
513
474
  description: req.body.description,
@@ -530,7 +491,7 @@ export const trialExtendRequest = async ( req, res ) => {
530
491
  return res.sendSuccess( 'Request is Already initiated waiting for admin approval' );
531
492
  }
532
493
  let params = {
533
- user: '65e966e12b1991393cf8ce30', // need to login user id here
494
+ user: req.user._id, // need to login user id here
534
495
  clientId: req.body.clientId,
535
496
  name: req.body.product,
536
497
  description: 'Request for extend Trial',
@@ -554,7 +515,7 @@ export const trialRequest = async ( req, res ) => {
554
515
  return res.sendSuccess( 'Request is Already initiated waiting for admin approval' );
555
516
  }
556
517
  let params = {
557
- user: '65e966e12b1991393cf8ce30', // need to login user id here
518
+ user: req.user._id, // need to login user id here
558
519
  clientId: req.body.clientId,
559
520
  name: req.body.product,
560
521
  description: 'Request for Trial',
@@ -722,6 +683,17 @@ export const trialApproval = async ( req, res ) => {
722
683
  }
723
684
  clientProducts.save();
724
685
  await storeService.addremoveElement( { clientId: requestData.clientId, status: 'active' }, { $push: { product: requestData.name } } );
686
+ const templateHtml = fs.readFileSync( path.resolve( path.dirname( '' ) ) + '/src/hbs/trialInitiateEmail.hbs', 'utf8' );
687
+ const template = Handlebars.compile( templateHtml );
688
+ const html = template( { data: '' } );
689
+ let params = {
690
+ toEmail: 'sudha@tangotech.co.in',
691
+ mailSubject: 'test',
692
+ htmlBody: html,
693
+ attachment: '',
694
+ sourceEmail: appConfig.cloud.aws.ses.from,
695
+ };
696
+ sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
725
697
  }
726
698
  return res.sendSuccess( 'updated Successfully' );
727
699
  } );
@@ -1398,3 +1370,4 @@ export const getStoreProducts = async ( req, res ) => {
1398
1370
  return res.sendError( e, 500 );
1399
1371
  }
1400
1372
  };
1373
+
@@ -0,0 +1,322 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+
6
+ <meta charset="utf-8">
7
+ <meta http-equiv="x-ua-compatible" content="ie=edge">
8
+ <title>Batch Upload</title>
9
+ <meta name="viewport" content="width=device-width, initial-scale=1">
10
+ <style type="text/css">
11
+ @media screen {
12
+ @font-face {
13
+ font-family: 'Inter';
14
+ font-style: normal;
15
+ font-weight: 400;
16
+ font-display: swap;
17
+ src: local("Inter"), local("Inter-Regular"), url(https://fonts.gstatic.com/s/inter/v12/UcCO3FwrK3iLTeHuS_fvQtMwCp50KnMw2boKoduKmMEVuLyfAZJhiI2B.woff2) format('woff2');
18
+ unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
19
+ }
20
+ }
21
+
22
+ body {
23
+ font-family: "Inter", sans-serif !important;
24
+ }
25
+
26
+ body,
27
+ table,
28
+ td,
29
+ a {
30
+ -ms-text-size-adjust: 100%;
31
+ -webkit-text-size-adjust: 100%;
32
+ }
33
+
34
+ table,
35
+ td {
36
+ mso-table-rspace: 0pt;
37
+ mso-table-lspace: 0pt;
38
+ }
39
+
40
+ img {
41
+ -ms-interpolation-mode: bicubic;
42
+ }
43
+
44
+ a[x-apple-data-detectors] {
45
+ font-family: "inherit" !important;
46
+ font-size: inherit !important;
47
+ font-weight: inherit !important;
48
+ line-height: inherit !important;
49
+ color: inherit !important;
50
+ text-decoration: none !important;
51
+ }
52
+
53
+
54
+ div[style*="margin: 16px 0;"
55
+
56
+ ] {
57
+ margin: 0 !important;
58
+ }
59
+
60
+ body {
61
+ width: 100% !important;
62
+ height: 100% !important;
63
+ padding: 0 !important;
64
+ margin: 0 !important;
65
+ }
66
+
67
+
68
+ table {
69
+ border-collapse: collapse !important;
70
+ }
71
+
72
+ a {
73
+ color: #1a82e2;
74
+ }
75
+
76
+ img {
77
+ height: auto;
78
+ line-height: 100%;
79
+ text-decoration: none;
80
+ border: 0;
81
+ outline: none;
82
+ }
83
+ </style>
84
+
85
+ </head>
86
+
87
+ <body style="background-color: #dbe5ea;">
88
+
89
+ <div class="preheader"
90
+ style="display: none; max-width: 0; max-height: 0; overflow: hidden; font-size: 1px; line-height: 1px; color: #fff; opacity: 0;">
91
+ Email Summary (Hidden)
92
+ </div>
93
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-left:10px;padding-right:10px">
94
+ <tr>
95
+ <td bgcolor="#dbe5ea" style="padding:32px 10px 0 10px">
96
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;" align="center">
97
+ <tr>
98
+ <td class="o_bg-white o_px-md o_py-md o_sans o_text"
99
+ style="margin-top: 0px;margin-bottom: 0px;font-size: 16px;line-height: 24px;background-color: #ffffff;padding-left: 18px;padding-right: 24px;padding-top: 24px;padding-bottom: 24px;">
100
+ <p style="margin-top: 0px;margin-bottom: 0px;"><a class="o_text-white"
101
+ href="https://tangoeye.ai/"
102
+ style="text-decoration: none;outline: none;color: #ffffff;"><img
103
+ src="https://pub-f88985f8e0964d3d8cd7fa6f2dde6962.r2.dev/TangoLogo/Tango%20Eye%20Logo%20color%20option-01.png"
104
+ width="200" height="100" alt="SimpleApp"
105
+ style="-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;"></a>
106
+ </p>
107
+ </td>
108
+ </tr>
109
+ <tr>
110
+ <td align="left" bgcolor="#ffffff"
111
+ style="padding-left: 30px;padding-right: 24px; font-size: 14px; line-height: 24px;">
112
+ <p class="o_heading o_mb-xxs"
113
+ style="width: 624px;height: 0px;border: 1px solid #CBD5E1;flex: none;order: 1;flex-grow: 0;">
114
+ </p>
115
+ </td>
116
+ </tr>
117
+ <tr>
118
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md"
119
+ style="background-color: #ffffff;padding-left: 30px;padding-right: 24px;padding-bottom: 10px;">
120
+ <div class="o_col-6s o_sans o_text-md o_text-light o_center"
121
+ style="margin-top: 0px;margin-bottom: 0px;font-size: 24px;line-height: 28px;color: #82899a;">
122
+ <span class="o_heading o_text-dark o_mb-xxs"
123
+ style="font-weight: 700;margin-top: 0px;margin-bottom: 4px;color: #121A26;line-height: 140%;">
124
+ Welcome to Tango Zone Trial - Explore Premium Features! </span>
125
+ </div>
126
+ </td>
127
+ </tr>
128
+ </table>
129
+ </td>
130
+ </tr>
131
+ <tr>
132
+ <td align="center" bgcolor="#dbe5ea" style="padding:0 10px 0 10px">
133
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;">
134
+ <tr>
135
+ <td align="left" bgcolor="#ffffff"
136
+ style="padding-left: 30px; padding-right: 24px;padding-top:10px;padding-bottom: 10px;font-weight: 400;font-size: 16px;line-height: 150%;color:#384860">
137
+ <p style="margin: 0;">Dear test,</p>
138
+ </td>
139
+ </tr>
140
+ <tr>
141
+ <td align="left" bgcolor="#ffffff"
142
+ style="padding-left: 30px;padding-right: 24px;padding-top:10px; font-size: 16px; line-height: 24px;font-weight:400;color:#384860">
143
+ <p style="margin: 0;">Welcome to the Tango Eye family! Your trial has begun, unlocking
144
+ premium features for you to explore:
145
+ </p>
146
+ </td>
147
+ </tr>
148
+ </table>
149
+ </td>
150
+ </tr>
151
+ <tr>
152
+ <td align="center" bgcolor="#dbe5ea" style="padding:0 10px 0 10px">
153
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;">
154
+ <tr>
155
+ <td align="left" bgcolor="#ffffff">
156
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
157
+ <tr width="100">
158
+ <td bgcolor="#ffffff" style="padding:30px 20px 20px 30px;">
159
+ <div style="width:100% !important;background-color:#E2E8F0;">
160
+ <table border="0" cellpadding="0" cellspacing="0">
161
+ <tr>
162
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md"
163
+ style="background-color: #E2E8F0;padding:20px 24px 10px 25px;">
164
+ <div class="o_col-6s o_sans o_text-md o_text-light o_center"
165
+ style="margin-top: 0px;margin-bottom: 0px;font-size: 18px;line-height: 28px;">
166
+ <span class="o_heading o_text-dark o_mb-xxs"
167
+ style="font-weight: 700;margin-top: 0px;margin-bottom: 4px;color: #121A26;line-height: 150%;">
168
+ Trial Features
169
+ </span>
170
+ </div>
171
+ </td>
172
+ </tr>
173
+ <tr>
174
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md" align="center"
175
+ bgcolor="#E2E8F0"
176
+ style="background-color: #E2E8F0;padding:10px 24px 10px 25px;">
177
+ <div style="display:flex">
178
+ <div style="display:flex;width:280px;">
179
+ <div>
180
+ <img src="https://pub-f88985f8e0964d3d8cd7fa6f2dde6962.r2.dev/icons/email-check-success.png"
181
+ alt="SimpleApp"
182
+ style="-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;width: 25px;height:25px;">
183
+ </div>
184
+ <div style="margin:1px 0 0 10px">
185
+ <span
186
+ style="color:#121A26;font-size:16px;font-weight:500">Tag
187
+ zones of your choice</span>
188
+ </div>
189
+ </div>
190
+ <div style="display:flex;width:280px;">
191
+ <div>
192
+ <img src="https://pub-f88985f8e0964d3d8cd7fa6f2dde6962.r2.dev/icons/email-check-success.png"
193
+ alt="SimpleApp"
194
+ style="-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;width: 25px;height:25px;">
195
+ </div>
196
+ <div style="margin:1px 0 0 10px">
197
+ <span
198
+ style="color:#121A26;font-size:16px;font-weight:500">Plan
199
+ Merchandise </span>
200
+ </div>
201
+ </div>
202
+ </div>
203
+ </td>
204
+ </tr>
205
+ <tr>
206
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md" align="center"
207
+ bgcolor="#E2E8F0"
208
+ style="background-color: #E2E8F0;padding:10px 24px 30px 25px;">
209
+ <div style="display:flex">
210
+ <div style="display:flex;width:280px;">
211
+ <div>
212
+ <img src="https://pub-f88985f8e0964d3d8cd7fa6f2dde6962.r2.dev/icons/email-check-success.png"
213
+ alt="SimpleApp"
214
+ style="-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;width: 25px;height:25px;">
215
+ </div>
216
+ <div style="margin:1px 0 0 10px">
217
+ <span
218
+ style="color:#121A26;font-size:16px;font-weight:500">Identifying
219
+ Hot spots</span>
220
+ </div>
221
+ </div>
222
+ <div style="display:flex;width:280px;">
223
+ <div>
224
+ <img src="https://pub-f88985f8e0964d3d8cd7fa6f2dde6962.r2.dev/icons/email-check-success.png"
225
+ alt="SimpleApp"
226
+ style="-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;width: 25px;height:25px;">
227
+ </div>
228
+ <div style="margin:1px 0 0 10px">
229
+ <span
230
+ style="color:#121A26;font-size:16px;font-weight:500">Premium
231
+ Customer Support </span>
232
+ </div>
233
+ </div>
234
+ </div>
235
+ </td>
236
+ </tr>
237
+ </table>
238
+ </div>
239
+ </td>
240
+ </tr>
241
+ </table>
242
+ </td>
243
+ </tr>
244
+ </table>
245
+ </td>
246
+ </tr>
247
+ <tr>
248
+ <td align="center" bgcolor="#dbe5ea" style="padding:0 10px 0 10px">
249
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;">
250
+ <tr>
251
+ <td bgcolor="#ffffff" style="padding: 20px;padding-top:10px;padding-left:30px;">
252
+ <table border="0" cellpadding="0" cellspacing="0">
253
+ <tr>
254
+ <td align="center" bgcolor="#00A3FF" style="border-radius: 6px;">
255
+ <a href="data.uiDomainName" target="_blank"
256
+ style="display: inline-block; padding: 16px 36px; font-size: 16px; color: #ffffff; text-decoration: none; border-radius: 6px;">View
257
+ Dashboard
258
+ </a>
259
+ </td>
260
+ </tr>
261
+ </table>
262
+ </td>
263
+ </tr>
264
+ </table>
265
+ </td>
266
+ </tr>
267
+ <tr>
268
+ <td align="center" bgcolor="#dbe5ea" style="padding:0 10px 0 10px">
269
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;">
270
+ <tr>
271
+ <td align="left" bgcolor="#ffffff"
272
+ style="padding-left: 30px;padding-right: 24px;padding-top:10px; font-size: 16px; line-height: 24px;font-weight:400;color:#384860">
273
+ <p style="margin: 0;">Enjoy the full potential of Tango Zone Module. If you have any
274
+ questions or need assistance, our support team is here to help.
275
+ </p>
276
+ </td>
277
+ </tr>
278
+ <tr>
279
+ <td align="left" bgcolor="#ffffff"
280
+ style="padding-left: 30px;padding-right: 24px;padding-top:20px; font-size: 16px; line-height: 24px;font-weight:400;color:#384860">
281
+ <p style="margin: 0;">
282
+ Happy exploring!</p>
283
+ </td>
284
+ </tr>
285
+ </table>
286
+ </td>
287
+ </tr>
288
+ <tr>
289
+ <td align="center" bgcolor="#dbe5ea" style="padding:0 10px 32px 10px">
290
+ <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 680px;">
291
+ <tr>
292
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md"
293
+ style="background-color: #ffffff;padding-left: 30px;padding-right: 24px;padding-top:35px">
294
+ <div class="o_col-6s o_sans o_text-md o_text-light o_center"
295
+ style="margin-top: 0px;margin-bottom: 0px;font-size: 12px;color: #202B3C;font-style: normal;font-weight: 400;font-size: 12px;line-height: 150%;">
296
+ <p>
297
+ If you'd rather not receive this kind of email, Don’t want any more emails from
298
+ TangoEye? <a
299
+ style="color: var(--Primary-Base, #00A3FF); text-decoration-line: underline; letter-spacing: 0.2px;">Unsubscribe.</a>
300
+ </p>
301
+ </div>
302
+ </td>
303
+ </tr>
304
+ <tr>
305
+ <td class="o_bg-white o_px-md o_py-xl o_xs-py-md"
306
+ style="background-color: #ffffff;padding-left: 30px;padding-right: 24px;padding-bottom:15px">
307
+ <div class="o_col-6s o_sans o_text-md o_text-light o_center"
308
+ style="margin-top: 0px;margin-bottom: 0px;font-size: 12px;color: #202B3C;font-style: normal;font-weight: 400;font-size: 12px;line-height: 150%;">
309
+ <p>
310
+ © Tango Eye. All rights reserved.</p>
311
+ </div>
312
+ </td>
313
+ </tr>
314
+ </table>
315
+ </td>
316
+ </tr>
317
+
318
+ </table>
319
+
320
+ </body>
321
+
322
+ </html>
@@ -0,0 +1,14 @@
1
+ const Handlebars = require( 'handlebars' );
2
+
3
+
4
+ // Handlebars.registerHelper( 'eq', function( arg1, arg2, options ) {
5
+ // return ( arg1 == arg2 ) ? options.fn( this ) : options.inverse( this );
6
+ // } );
7
+
8
+
9
+ // Handlebars.registerHelper( 'neq', function( a, b, options ) {
10
+ // return a !== b ? options.fn( this ) : options.inverse( this );
11
+ // } );
12
+
13
+
14
+ module.exports = Handlebars;