tango-app-api-payment-subscription 3.0.21-dev → 3.0.22-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
|
@@ -39,12 +39,12 @@ export const addBilling = async ( req, res ) => {
|
|
|
39
39
|
// date: new Date(),
|
|
40
40
|
// logType: 'billing',
|
|
41
41
|
// logSubType: 'billingInfo',
|
|
42
|
-
// changes: [ 'billingAddress', 'gstNumber'
|
|
42
|
+
// changes: [ 'billingAddress', 'gstNumber' ],
|
|
43
43
|
// eventType: 'update',
|
|
44
44
|
// };
|
|
45
45
|
return res.sendSuccess( { message: 'Billing Details Added Successfully', data: resultData } );
|
|
46
46
|
} else {
|
|
47
|
-
logger.error( 'Error Occurs WHile updating billing
|
|
47
|
+
logger.error( 'Error Occurs WHile updating billing Details' );
|
|
48
48
|
return res.sendError( 'Something Went Wrong', 500 );
|
|
49
49
|
}
|
|
50
50
|
} catch ( e ) {
|
|
@@ -384,6 +384,10 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
384
384
|
if ( !requestBody?.products?.length ) {
|
|
385
385
|
return res.sendError( 'product is required', 400 );
|
|
386
386
|
}
|
|
387
|
+
let premiumType = requestBody.client.planDetails.subscriptionType;
|
|
388
|
+
if ( requestBody.client.planDetails.subscriptionType == 'free' ) {
|
|
389
|
+
premiumType = 'premium';
|
|
390
|
+
}
|
|
387
391
|
|
|
388
392
|
let clientProducts = requestBody.client.planDetails.product;
|
|
389
393
|
for ( let item of requestBody.products ) {
|
|
@@ -417,7 +421,7 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
417
421
|
}
|
|
418
422
|
|
|
419
423
|
let details = {
|
|
420
|
-
subscriptionType:
|
|
424
|
+
subscriptionType: premiumType,
|
|
421
425
|
subscriptionPeriod: requestBody.subscriptionPeriod,
|
|
422
426
|
totalCamera: requestBody.totalCamera,
|
|
423
427
|
totalStores: requestBody.totalStores,
|
|
@@ -425,9 +429,17 @@ export const updateSubscription = async ( req, res ) => {
|
|
|
425
429
|
product: clientProducts,
|
|
426
430
|
};
|
|
427
431
|
|
|
432
|
+
req.body = {
|
|
433
|
+
'camaraPerSqft': req.body.storeSize,
|
|
434
|
+
'storesCount': req.body.totalStores,
|
|
435
|
+
'planName': requestBody.subscriptionPeriod,
|
|
436
|
+
'products': clientProducts.map( ( item ) => item.productName ),
|
|
437
|
+
'currencyType': 'rupees',
|
|
438
|
+
};
|
|
439
|
+
let pricingDetails = await calculatePricing( req, res );
|
|
428
440
|
let data = {
|
|
429
441
|
planDetails: details,
|
|
430
|
-
price:
|
|
442
|
+
price: pricingDetails.price,
|
|
431
443
|
priceType: requestBody.priceType,
|
|
432
444
|
};
|
|
433
445
|
|
|
@@ -697,6 +709,9 @@ export const trialApproval = async ( req, res ) => {
|
|
|
697
709
|
requestData.save().then( async () => {
|
|
698
710
|
if ( req.body.type == 'approve' ) {
|
|
699
711
|
let clientProducts = await paymentService.findOne( { clientId: requestData.clientId, status: 'active' }, { planDetails: 1 } );
|
|
712
|
+
if ( clientProducts?.planDetails.subscriptionType == 'free' ) {
|
|
713
|
+
clientProducts.planDetails.subscriptionType = 'premium';
|
|
714
|
+
}
|
|
700
715
|
if ( !clientProducts ) {
|
|
701
716
|
return res.sendError( 'no data found', 204 );
|
|
702
717
|
}
|
|
@@ -852,6 +867,18 @@ export const productSubscribe = async ( req, res ) => {
|
|
|
852
867
|
}
|
|
853
868
|
}
|
|
854
869
|
product = product.filter( ( item ) => !removeProducts.includes( item.productName ) );
|
|
870
|
+
req.body = {
|
|
871
|
+
'camaraPerSqft': clientInfo.planDetails.storeSize,
|
|
872
|
+
'storesCount': clientInfo.planDetails.totalStores,
|
|
873
|
+
'planName': clientInfo.planDetails.subscriptionPeriod,
|
|
874
|
+
'products': product.map( ( item ) => item.productName ),
|
|
875
|
+
'currencyType': 'rupees',
|
|
876
|
+
};
|
|
877
|
+
let pricingDetails = await calculatePricing( req, res );
|
|
878
|
+
clientInfo.price = pricingDetails.price;
|
|
879
|
+
if ( product.length > 1 ) {
|
|
880
|
+
clientInfo.planDetails.subscriptionType = 'premium';
|
|
881
|
+
}
|
|
855
882
|
clientInfo.planDetails.product = product;
|
|
856
883
|
clientInfo.save().then( async () => {
|
|
857
884
|
let userDetails= await userService.findOne( { clientId: clientInfo.clientId, role: 'superadmin' } );
|