tango-app-api-payment-subscription 3.0.41-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.41-dev",
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.89",
29
- "tango-app-api-middleware": "^1.0.58-dev",
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
  },
@@ -531,6 +531,15 @@ export const updateSubscription = async ( req, res ) => {
531
531
  } ).catch( ( error ) => {
532
532
  logger.error( { error: error, function: 'old Product update' } );
533
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
+ } );
534
543
  return res.sendSuccess( { message: 'Subscription Updated Successfully' } );
535
544
  } else {
536
545
  return res.sendError( 'Something went wrong', 500 );
@@ -915,6 +924,15 @@ export const trialApproval = async ( req, res ) => {
915
924
  } ).catch( ( error ) => {
916
925
  logger.error( { error: error, function: 'old Product update' } );
917
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
+ } );
918
936
  }
919
937
  const logObj = {
920
938
  clientId: req.body.clientId,
@@ -1106,15 +1124,6 @@ export const productSubscribe = async ( req, res ) => {
1106
1124
  }
1107
1125
  clientInfo.planDetails.product = product;
1108
1126
  clientInfo.save().then( async () => {
1109
- let storeProduct = await storeService.find( { clientId: clientInfo.clientId }, { _id: 0, storeId: 1, product: 1 } );
1110
- storeProduct = storeProduct.map( ( item ) => {
1111
- return { id: item.storeId, product: item.product };
1112
- } );
1113
- await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProduct, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
1114
- logger.info( 'store Updated Successfully' );
1115
- } ).catch( ( error ) => {
1116
- logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
1117
- } );
1118
1127
  updatePricing( req, res, true );
1119
1128
  let products = clientInfo.planDetails.product.map( ( item ) => {
1120
1129
  let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
@@ -1142,6 +1151,15 @@ export const productSubscribe = async ( req, res ) => {
1142
1151
  } ).catch( ( error ) => {
1143
1152
  logger.error( { error: error, function: 'old Product update' } );
1144
1153
  } );
1154
+ let storeProduct = await storeService.find( { clientId: clientInfo.clientId }, { _id: 0, storeId: 1, product: 1 } );
1155
+ storeProduct = storeProduct.map( ( item ) => {
1156
+ return { id: item.storeId, product: item.product };
1157
+ } );
1158
+ await axios.post( `${appConfig.url.oldapidomain}/oldBulkStoreUpdate`, storeProduct, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( response ) => {
1159
+ logger.info( 'store Updated Successfully' );
1160
+ } ).catch( ( error ) => {
1161
+ logger.error( { error: error, function: 'oldBulkStoreUpdate' } );
1162
+ } );
1145
1163
  } );
1146
1164
  const logObj = {
1147
1165
  clientId: req.body.clientId,
@@ -1522,6 +1540,7 @@ export const addStoreProduct = async ( req, res ) => {
1522
1540
  }
1523
1541
  clientInfo.planDetails.product = clientProduct;
1524
1542
  clientInfo.save();
1543
+ let clientId = req.body.clientId;
1525
1544
  storeDetails.forEach( async ( item ) => {
1526
1545
  updatePricing( req, res, true );
1527
1546
  let product;
@@ -1539,10 +1558,10 @@ export const addStoreProduct = async ( req, res ) => {
1539
1558
  }
1540
1559
  } );
1541
1560
  }
1542
- await storeService.updateOne( { storeId: item.storeId, clientId: req.body.clientId }, { product: product } );
1561
+ await storeService.updateOne( { storeId: item.storeId, clientId: clientId }, { product: product } );
1543
1562
  } );
1544
1563
  const logObj = {
1545
- clientId: req.body.clientId,
1564
+ clientId: clientId,
1546
1565
  userName: req.user?.userName,
1547
1566
  email: req.user?.email,
1548
1567
  date: new Date(),
@@ -1556,7 +1575,7 @@ export const addStoreProduct = async ( req, res ) => {
1556
1575
  let [ firstWord, secondWord ] = item.productName.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
1557
1576
  return firstWord.toLowerCase() + '_' + secondWord.toLowerCase();
1558
1577
  } );
1559
- await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${req.body.clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
1578
+ await axios.get( `${appConfig.url.oldapidomain}/oldBrandGet/${clientId}`, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( async ( response ) => {
1560
1579
  let existsProducts = Object.keys( response.data.data.subscribed_features );
1561
1580
  existsProducts.forEach( ( item ) => {
1562
1581
  if ( products.includes( item ) ) {
@@ -1578,6 +1597,15 @@ export const addStoreProduct = async ( req, res ) => {
1578
1597
  } ).catch( ( error ) => {
1579
1598
  logger.error( { error: error, function: 'old Product update' } );
1580
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
+ } );
1581
1609
  return res.sendSuccess( 'product updated Successfully' );
1582
1610
  } catch ( e ) {
1583
1611
  logger.error( { error: e, function: 'addStoreProduct' } );