diff --git a/apps/OpenSign/src/json/plansArr.js b/apps/OpenSign/src/json/plansArr.js index 293be04ef..32540041c 100644 --- a/apps/OpenSign/src/json/plansArr.js +++ b/apps/OpenSign/src/json/plansArr.js @@ -3,6 +3,7 @@ import { isStaging } from "../constant/const"; const plans = [ { planName: "OPENSIGN™ FREE", + code: { monthly: "freeplan", yearly: "freeplan" }, img: "free.png", currency: "", monthlyPrice: "Free", @@ -52,6 +53,9 @@ const plans = [ }, { planName: "OPENSIGN™ PROFESSIONAL", + code: isStaging + ? { monthly: "pro-weekly", yearly: "pro-yearly" } + : { monthly: "professional-monthly", yearly: "professional-yearly" }, img: "professional.png", currency: "$", monthlyPrice: "29.99", @@ -98,6 +102,7 @@ const plans = [ }, { planName: "OPENSIGN™ TEAMS", + code: { monthly: "teams-monthly", yearly: "teams-yearly" }, img: "teams.png", currency: "$", monthlyPrice: `39.99/user`, @@ -206,7 +211,9 @@ export const paidUrl = (plan) => { : ""; const phone = user && user.phone ? "&mobile=" + encodeURIComponent(user.phone) : ""; - const allowedUsers = localStorage.getItem("allowedUsers"); + const allowedUsers = localStorage.getItem("allowedUsers") + ? localStorage.getItem("allowedUsers") - 1 + : ""; const quantity = allowedUsers ? `addon_code%5B0%5D=extra-teams-users-${period}&addon_quantity%5B0%5D=${allowedUsers}&` : ""; diff --git a/apps/OpenSign/src/pages/PlanSubscriptions.js b/apps/OpenSign/src/pages/PlanSubscriptions.js index 105221ee7..c27385212 100644 --- a/apps/OpenSign/src/pages/PlanSubscriptions.js +++ b/apps/OpenSign/src/pages/PlanSubscriptions.js @@ -53,12 +53,6 @@ const PlanSubscriptions = () => { ? "&mobile=" + encodeURIComponent(userDetails.phone) : ""; - const details = - "?shipping_country_code=US&billing_country_code=US&billing_state_code=CA&" + - name + - email + - company + - phone; useEffect(() => { setIsLoader(false); detectLanguage(); @@ -72,6 +66,30 @@ const PlanSubscriptions = () => { const handleFreePlan = async (item) => { if (item.url) { + const code = yearlyVisible ? item.code.yearly : item.code.monthly; + const allowedUsers = localStorage.getItem("allowedUsers") + ? localStorage.getItem("allowedUsers") - 1 + : ""; + const teamperiod = { + "team-weekly": "monthly", + "team-yearly": "yearly", + "teams-monthly": "monthly", + "teams-yearly": "yearly" + }; + const period = teamperiod[code] || ""; + + const quantity = + allowedUsers && period + ? `addon_code%5B0%5D=extra-teams-users-${period}&addon_quantity%5B0%5D=${allowedUsers}&` + : ""; + + const details = + "?shipping_country_code=US&billing_country_code=US&billing_state_code=CA&" + + quantity + + name + + email + + company + + phone; const url = yearlyVisible ? item.yearlyUrl + details : item.url + details; if (user) { localStorage.setItem("userDetails", JSON.stringify(user)); diff --git a/apps/OpenSignServer/cloud/parsefunction/saveSubscription.js b/apps/OpenSignServer/cloud/parsefunction/saveSubscription.js index b761e2792..3fac359fc 100644 --- a/apps/OpenSignServer/cloud/parsefunction/saveSubscription.js +++ b/apps/OpenSignServer/cloud/parsefunction/saveSubscription.js @@ -31,12 +31,12 @@ export default async function saveSubscription(request) { className: 'partners_Tenant', objectId: extUser.get('TenantId').id, }); - const subscription = await subcriptionCls.first({ useMasterKey: true }); + const resSubscription = await subcriptionCls.first({ useMasterKey: true }); const addons = subscription?.data?.subscription?.addons || []; const existAddon = addons.reduce((acc, curr) => acc + curr.quantity, 1); - if (subscription) { + if (resSubscription) { const updateSubscription = new Parse.Object('contracts_Subscriptions'); - updateSubscription.id = subscription.id; + updateSubscription.id = resSubscription.id; updateSubscription.set('SubscriptionId', SubscriptionId); updateSubscription.set('SubscriptionDetails', body); updateSubscription.set('Next_billing_date', new Date(Next_billing_date));