tango-app-api-payment-subscription 3.0.40-dev → 3.0.42-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.
|
|
3
|
+
"version": "3.0.42-dev",
|
|
4
4
|
"description": "paymentSubscription",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"aws-sdk": "^2.1572.0",
|
|
17
|
+
"axios": "^1.6.8",
|
|
17
18
|
"dayjs": "^1.11.10",
|
|
18
19
|
"dotenv": "^16.4.5",
|
|
19
20
|
"express": "^4.18.3",
|
|
@@ -25,8 +26,8 @@
|
|
|
25
26
|
"nodemon": "^3.1.0",
|
|
26
27
|
"pdfmake": "^0.2.10",
|
|
27
28
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
-
"tango-api-schema": "^2.0.
|
|
29
|
-
"tango-app-api-middleware": "^1.0.
|
|
29
|
+
"tango-api-schema": "^2.0.91",
|
|
30
|
+
"tango-app-api-middleware": "^1.0.59-dev",
|
|
30
31
|
"winston": "^3.12.0",
|
|
31
32
|
"winston-daily-rotate-file": "^5.0.0"
|
|
32
33
|
},
|
|
@@ -505,6 +505,41 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
505
505
|
if ( result.modifiedCount ) {
|
|
506
506
|
req.body.clientId = req.params.clientId;
|
|
507
507
|
updatePricing( req, res, true );
|
|
508
|
+
let products = data.planDetails.product.map( ( item ) => {
|
|
509
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
510
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
511
|
+
} );
|
|
512
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${req.params.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
513
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
514
|
+
existsProducts.forEach( ( item ) => {
|
|
515
|
+
if ( products.includes( item ) ) {
|
|
516
|
+
response.data.data.subscribed_features[item] = true;
|
|
517
|
+
} else {
|
|
518
|
+
response.data.data.subscribed_features[item] = false;
|
|
519
|
+
}
|
|
520
|
+
} );
|
|
521
|
+
products.forEach( ( item ) => {
|
|
522
|
+
if ( !existsProducts.includes( item ) ) {
|
|
523
|
+
response.data.data.subscribed_features[item] = true;
|
|
524
|
+
}
|
|
525
|
+
} );
|
|
526
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
527
|
+
logger.info( result.data );
|
|
528
|
+
} ).catch( ( error ) => {
|
|
529
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
530
|
+
} );
|
|
531
|
+
} ).catch( ( error ) => {
|
|
532
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
533
|
+
} );
|
|
534
|
+
let storeProductDetails = await storeService.find( { clientId: req.params.clientId }, { _id: 0, storeId: 1, product: 1 } );
|
|
535
|
+
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
536
|
+
return { id: item.storeId, product: item.product };
|
|
537
|
+
} );
|
|
538
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
539
|
+
logger.info( 'store Updated Successfully' );
|
|
540
|
+
} ).catch( ( error ) => {
|
|
541
|
+
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
542
|
+
} );
|
|
508
543
|
return res.sendSuccess( { message: 'Subscription Updated Successfully' } );
|
|
509
544
|
} else {
|
|
510
545
|
return res.sendError( 'Something went wrong', 500 );
|
|
@@ -863,6 +898,41 @@ export const trialApproval = async ( req, res ) => {
|
|
|
863
898
|
};
|
|
864
899
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
865
900
|
}
|
|
901
|
+
let products = clientProducts.planDetails.product.map( ( item ) => {
|
|
902
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
903
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
904
|
+
} );
|
|
905
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${requestData.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
906
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
907
|
+
existsProducts.forEach( ( item ) => {
|
|
908
|
+
if ( products.includes( item ) ) {
|
|
909
|
+
response.data.data.subscribed_features[item] = true;
|
|
910
|
+
} else {
|
|
911
|
+
response.data.data.subscribed_features[item] = false;
|
|
912
|
+
}
|
|
913
|
+
} );
|
|
914
|
+
products.forEach( ( item ) => {
|
|
915
|
+
if ( !existsProducts.includes( item ) ) {
|
|
916
|
+
response.data.data.subscribed_features[item] = true;
|
|
917
|
+
}
|
|
918
|
+
} );
|
|
919
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
920
|
+
logger.info( result.data );
|
|
921
|
+
} ).catch( ( error ) => {
|
|
922
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
923
|
+
} );
|
|
924
|
+
} ).catch( ( error ) => {
|
|
925
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
926
|
+
} );
|
|
927
|
+
let storeProductDetails = await storeService.find( { clientId: requestData.clientId }, { _id: 0, storeId: 1, product: 1 } );
|
|
928
|
+
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
929
|
+
return { id: item.storeId, product: item.product };
|
|
930
|
+
} );
|
|
931
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
932
|
+
logger.info( 'store Updated Successfully' );
|
|
933
|
+
} ).catch( ( error ) => {
|
|
934
|
+
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
935
|
+
} );
|
|
866
936
|
}
|
|
867
937
|
const logObj = {
|
|
868
938
|
clientId: req.body.clientId,
|
|
@@ -1054,6 +1124,33 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1054
1124
|
}
|
|
1055
1125
|
clientInfo.planDetails.product = product;
|
|
1056
1126
|
clientInfo.save().then( async () => {
|
|
1127
|
+
updatePricing( req, res, true );
|
|
1128
|
+
let products = clientInfo.planDetails.product.map( ( item ) => {
|
|
1129
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1130
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1131
|
+
} );
|
|
1132
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${clientInfo.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1133
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1134
|
+
existsProducts.forEach( ( item ) => {
|
|
1135
|
+
if ( products.includes( item ) ) {
|
|
1136
|
+
response.data.data.subscribed_features[item] = true;
|
|
1137
|
+
} else {
|
|
1138
|
+
response.data.data.subscribed_features[item] = false;
|
|
1139
|
+
}
|
|
1140
|
+
} );
|
|
1141
|
+
products.forEach( ( item ) => {
|
|
1142
|
+
if ( !existsProducts.includes( item ) ) {
|
|
1143
|
+
response.data.data.subscribed_features[item] = true;
|
|
1144
|
+
}
|
|
1145
|
+
} );
|
|
1146
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1147
|
+
logger.info( result.data );
|
|
1148
|
+
} ).catch( ( error ) => {
|
|
1149
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1150
|
+
} );
|
|
1151
|
+
} ).catch( ( error ) => {
|
|
1152
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1153
|
+
} );
|
|
1057
1154
|
let storeProduct = await storeService.find( { clientId: clientInfo.clientId }, { _id: 0, storeId: 1, product: 1 } );
|
|
1058
1155
|
storeProduct = storeProduct.map( ( item ) => {
|
|
1059
1156
|
return { id: item.storeId, product: item.product };
|
|
@@ -1063,7 +1160,6 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1063
1160
|
} ).catch( ( error ) => {
|
|
1064
1161
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
1065
1162
|
} );
|
|
1066
|
-
updatePricing( req, res, true );
|
|
1067
1163
|
} );
|
|
1068
1164
|
const logObj = {
|
|
1069
1165
|
clientId: req.body.clientId,
|
|
@@ -1444,6 +1540,7 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1444
1540
|
}
|
|
1445
1541
|
clientInfo.planDetails.product = clientProduct;
|
|
1446
1542
|
clientInfo.save();
|
|
1543
|
+
let clientId = req.body.clientId;
|
|
1447
1544
|
storeDetails.forEach( async ( item ) => {
|
|
1448
1545
|
updatePricing( req, res, true );
|
|
1449
1546
|
let product;
|
|
@@ -1461,10 +1558,10 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1461
1558
|
}
|
|
1462
1559
|
} );
|
|
1463
1560
|
}
|
|
1464
|
-
await storeService.updateOne( { storeId: item.storeId, clientId:
|
|
1561
|
+
await storeService.updateOne( { storeId: item.storeId, clientId: clientId }, { product: product } );
|
|
1465
1562
|
} );
|
|
1466
1563
|
const logObj = {
|
|
1467
|
-
clientId:
|
|
1564
|
+
clientId: clientId,
|
|
1468
1565
|
userName: req.user?.userName,
|
|
1469
1566
|
email: req.user?.email,
|
|
1470
1567
|
date: new Date(),
|
|
@@ -1474,6 +1571,41 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1474
1571
|
eventType: 'update',
|
|
1475
1572
|
};
|
|
1476
1573
|
insertOpenSearchData( 'tango-retail-activity-logs', logObj );
|
|
1574
|
+
let products = clientInfo.planDetails.product.map( ( item ) => {
|
|
1575
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1576
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1577
|
+
} );
|
|
1578
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1579
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1580
|
+
existsProducts.forEach( ( item ) => {
|
|
1581
|
+
if ( products.includes( item ) ) {
|
|
1582
|
+
response.data.data.subscribed_features[item] = true;
|
|
1583
|
+
} else {
|
|
1584
|
+
response.data.data.subscribed_features[item] = false;
|
|
1585
|
+
}
|
|
1586
|
+
} );
|
|
1587
|
+
products.forEach( ( item ) => {
|
|
1588
|
+
if ( !existsProducts.includes( item ) ) {
|
|
1589
|
+
response.data.data.subscribed_features[item] = true;
|
|
1590
|
+
}
|
|
1591
|
+
} );
|
|
1592
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1593
|
+
logger.info( result.data );
|
|
1594
|
+
} ).catch( ( error ) => {
|
|
1595
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1596
|
+
} );
|
|
1597
|
+
} ).catch( ( error ) => {
|
|
1598
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1599
|
+
} );
|
|
1600
|
+
let storeProductDetails = await storeService.find( { clientId: clientId }, { _id: 0, storeId: 1, product: 1 } );
|
|
1601
|
+
storeProductDetails = storeProductDetails.map( ( item ) => {
|
|
1602
|
+
return { id: item.storeId, product: item.product };
|
|
1603
|
+
} );
|
|
1604
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProductDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
|
|
1605
|
+
logger.info( 'store Updated Successfully' );
|
|
1606
|
+
} ).catch( ( error ) => {
|
|
1607
|
+
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
1608
|
+
} );
|
|
1477
1609
|
return res.sendSuccess( 'product updated Successfully' );
|
|
1478
1610
|
} catch ( e ) {
|
|
1479
1611
|
logger.error( { error: e, function: 'addStoreProduct' } );
|
|
@@ -1892,9 +2024,10 @@ async function updatePricing( req, res, update ) {
|
|
|
1892
2024
|
let clientId = req.body.clientId;
|
|
1893
2025
|
let paymentInvoice = clientDetails.paymentInvoice;
|
|
1894
2026
|
if ( !update ) {
|
|
1895
|
-
let userDetails= await userService.findOne( { clientId:
|
|
2027
|
+
let userDetails= await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
|
|
1896
2028
|
paymentInvoice.invoiceTo = [ userDetails.email ];
|
|
1897
2029
|
paymentInvoice.paymentAgreementTo = [ userDetails.email ];
|
|
2030
|
+
paymentInvoice.currencyType = userDetails.countryCode == '91' ? 'inr': 'dollar';
|
|
1898
2031
|
clientDetails.planDetails.product.forEach( ( item ) => {
|
|
1899
2032
|
product.push( {
|
|
1900
2033
|
productName: item.productName,
|