tango-app-api-payment-subscription 3.0.40-dev → 3.0.41-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
|
@@ -505,6 +505,32 @@ 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
|
+
} );
|
|
508
534
|
return res.sendSuccess( { message: 'Subscription Updated Successfully' } );
|
|
509
535
|
} else {
|
|
510
536
|
return res.sendError( 'Something went wrong', 500 );
|
|
@@ -863,6 +889,32 @@ export const trialApproval = async ( req, res ) => {
|
|
|
863
889
|
};
|
|
864
890
|
await sendEmailWithSES( params.toEmail, params.mailSubject, params.htmlBody, params.attachment, params.sourceEmail );
|
|
865
891
|
}
|
|
892
|
+
let products = clientProducts.planDetails.product.map( ( item ) => {
|
|
893
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
894
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
895
|
+
} );
|
|
896
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${requestData.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
897
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
898
|
+
existsProducts.forEach( ( item ) => {
|
|
899
|
+
if ( products.includes( item ) ) {
|
|
900
|
+
response.data.data.subscribed_features[item] = true;
|
|
901
|
+
} else {
|
|
902
|
+
response.data.data.subscribed_features[item] = false;
|
|
903
|
+
}
|
|
904
|
+
} );
|
|
905
|
+
products.forEach( ( item ) => {
|
|
906
|
+
if ( !existsProducts.includes( item ) ) {
|
|
907
|
+
response.data.data.subscribed_features[item] = true;
|
|
908
|
+
}
|
|
909
|
+
} );
|
|
910
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
911
|
+
logger.info( result.data );
|
|
912
|
+
} ).catch( ( error ) => {
|
|
913
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
914
|
+
} );
|
|
915
|
+
} ).catch( ( error ) => {
|
|
916
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
917
|
+
} );
|
|
866
918
|
}
|
|
867
919
|
const logObj = {
|
|
868
920
|
clientId: req.body.clientId,
|
|
@@ -1064,6 +1116,32 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
1064
1116
|
logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
|
|
1065
1117
|
} );
|
|
1066
1118
|
updatePricing( req, res, true );
|
|
1119
|
+
let products = clientInfo.planDetails.product.map( ( item ) => {
|
|
1120
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1121
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1122
|
+
} );
|
|
1123
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${clientInfo.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1124
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1125
|
+
existsProducts.forEach( ( item ) => {
|
|
1126
|
+
if ( products.includes( item ) ) {
|
|
1127
|
+
response.data.data.subscribed_features[item] = true;
|
|
1128
|
+
} else {
|
|
1129
|
+
response.data.data.subscribed_features[item] = false;
|
|
1130
|
+
}
|
|
1131
|
+
} );
|
|
1132
|
+
products.forEach( ( item ) => {
|
|
1133
|
+
if ( !existsProducts.includes( item ) ) {
|
|
1134
|
+
response.data.data.subscribed_features[item] = true;
|
|
1135
|
+
}
|
|
1136
|
+
} );
|
|
1137
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1138
|
+
logger.info( result.data );
|
|
1139
|
+
} ).catch( ( error ) => {
|
|
1140
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1141
|
+
} );
|
|
1142
|
+
} ).catch( ( error ) => {
|
|
1143
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1144
|
+
} );
|
|
1067
1145
|
} );
|
|
1068
1146
|
const logObj = {
|
|
1069
1147
|
clientId: req.body.clientId,
|
|
@@ -1474,6 +1552,32 @@ export const addStoreProduct = async ( req, res ) => {
|
|
|
1474
1552
|
eventType: 'update',
|
|
1475
1553
|
};
|
|
1476
1554
|
insertOpenSearchData( 'tango-retail-activity-logs', logObj );
|
|
1555
|
+
let products = clientInfo.planDetails.product.map( ( item ) => {
|
|
1556
|
+
let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
1557
|
+
return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
|
|
1558
|
+
} );
|
|
1559
|
+
await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${req.body.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
|
|
1560
|
+
let existsProducts = Object.keys( response.data.data.subscribed_features );
|
|
1561
|
+
existsProducts.forEach( ( item ) => {
|
|
1562
|
+
if ( products.includes( item ) ) {
|
|
1563
|
+
response.data.data.subscribed_features[item] = true;
|
|
1564
|
+
} else {
|
|
1565
|
+
response.data.data.subscribed_features[item] = false;
|
|
1566
|
+
}
|
|
1567
|
+
} );
|
|
1568
|
+
products.forEach( ( item ) => {
|
|
1569
|
+
if ( !existsProducts.includes( item ) ) {
|
|
1570
|
+
response.data.data.subscribed_features[item] = true;
|
|
1571
|
+
}
|
|
1572
|
+
} );
|
|
1573
|
+
await axios.post( `${appConfig.url.oldapidomain}/oldBrandUpdate/${response.data.data._id}`, response.data.data, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( result ) => {
|
|
1574
|
+
logger.info( result.data );
|
|
1575
|
+
} ).catch( ( error ) => {
|
|
1576
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1577
|
+
} );
|
|
1578
|
+
} ).catch( ( error ) => {
|
|
1579
|
+
logger.error( { error: error, function: 'old Product update' } );
|
|
1580
|
+
} );
|
|
1477
1581
|
return res.sendSuccess( 'product updated Successfully' );
|
|
1478
1582
|
} catch ( e ) {
|
|
1479
1583
|
logger.error( { error: e, function: 'addStoreProduct' } );
|
|
@@ -1892,9 +1996,10 @@ async function updatePricing( req, res, update ) {
|
|
|
1892
1996
|
let clientId = req.body.clientId;
|
|
1893
1997
|
let paymentInvoice = clientDetails.paymentInvoice;
|
|
1894
1998
|
if ( !update ) {
|
|
1895
|
-
let userDetails= await userService.findOne( { clientId:
|
|
1999
|
+
let userDetails= await userService.findOne( { clientId: req.body.clientId, role: 'superadmin' } );
|
|
1896
2000
|
paymentInvoice.invoiceTo = [ userDetails.email ];
|
|
1897
2001
|
paymentInvoice.paymentAgreementTo = [ userDetails.email ];
|
|
2002
|
+
paymentInvoice.currencyType = userDetails.countryCode == '91' ? 'inr': 'dollar';
|
|
1898
2003
|
clientDetails.planDetails.product.forEach( ( item ) => {
|
|
1899
2004
|
product.push( {
|
|
1900
2005
|
productName: item.productName,
|