Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fixed subscription cancellation issues, added ability to update payment details

Blue Mouse98ba82c386f7
diff --git a/public/locales/en.json b/public/locales/en.json
index fb4ab042e..2360f6ec3 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -301,7 +301,8 @@
"billing": {
"title": "Billing & Plans",
"desc": "It is free to get started and use our services.\nIf you need to handle more traffic, you probably need to upgrade your plan.\nBelow is a list of available plans. No hidden fees or other BS, everything is clear and transparent!",
- "contact": "Need to track more than 1 million events per month?\nContact us at <mail>{{email}}</mail> to discuss your needs."
+ "contact": "Need to track more than 1 million events per month?\nContact us at <mail>{{email}}</mail> to discuss your needs.",
+ "update": "Update payment details"
},
"pricing": {
"title": "Pricing Plans",
diff --git a/src/pages/Billing/index.jsx b/src/pages/Billing/index.jsx
index 9d02d4362..71bdaea86 100644
--- a/src/pages/Billing/index.jsx
+++ b/src/pages/Billing/index.jsx
@@ -1,22 +1,54 @@
/* eslint-disable jsx-a11y/anchor-has-content */
-import React from 'react'
+import React, { memo } from 'react'
import { useTranslation, Trans } from 'react-i18next'
+import { useSelector } from 'react-redux'
import Pricing from '../MainPage/Pricing'
-import { CONTACT_EMAIL } from 'redux/constants'
+import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'
import { withAuthentication, auth } from 'hoc/protected'
import Title from 'components/Title'
const Features = () => {
+ const { user } = useSelector(state => state.auth)
+ const { theme } = useSelector(state => state.ui.theme)
const { t, i18n: { language } } = useTranslation('common')
+ const isFree = user.planCode === 'free'
+
+ const onUpdatePaymentDetails = () => {
+ if (!window.Paddle) {
+ window.location.replace(user.subUpdateURL)
+ return
+ }
+
+ window.Paddle.Checkout.open({
+ override: user.subUpdateURL,
+ method: 'inline',
+ frameTarget: 'checkout-container',
+ frameInitialHeight: 416,
+ frameStyle: 'width:100%; min-width:312px; background-color: #f9fafb; border: none; border-radius: 10px; margin-top: 10px;',
+ locale: paddleLanguageMapping[language] || language,
+ displayModeTheme: theme,
+ })
+ setTimeout(() => {
+ document.querySelector('#checkout-container').scrollIntoView()
+ }, 500)
+ }
+
return (
<Title title={t('titles.billing')}>
<div className='bg-gray-50 dark:bg-gray-800'>
<div className='w-11/12 md:w-4/5 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 whitespace-pre-line'>
- <h1 className='text-4xl mb-4 font-extrabold text-gray-900 dark:text-gray-50 tracking-tight'>
- {t('billing.title')}
- </h1>
+ <div className='flex justify-between flex-wrap gap-y-2 mb-4'>
+ <h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50 tracking-tight mr-2'>
+ {t('billing.title')}
+ </h1>
+ {!isFree && (
+ <span onClick={onUpdatePaymentDetails} className='inline-flex cursor-pointer items-center border border-transparent leading-4 font-medium rounded-md focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 px-4 py-2 text-sm'>
+ {t('billing.update')}
+ </span>
+ )}
+ </div>
<p className='text-lg text-gray-900 dark:text-gray-50 tracking-tight'>
{t('billing.desc')}
</p>
@@ -37,4 +69,4 @@ const Features = () => {
)
}
-export default withAuthentication(Features, auth.authenticated)
+export default memo(withAuthentication(Features, auth.authenticated))
diff --git a/src/pages/MainPage/Pricing.jsx b/src/pages/MainPage/Pricing.jsx
index 1bfd5f53f..895c9a486 100644
--- a/src/pages/MainPage/Pricing.jsx
+++ b/src/pages/MainPage/Pricing.jsx
@@ -10,7 +10,7 @@ import cx from 'clsx'
import Modal from 'ui/Modal'
import Spin from '../../ui/icons/Spin'
-import { CONTACT_EMAIL } from 'redux/constants'
+import { CONTACT_EMAIL, paddleLanguageMapping } from 'redux/constants'
import { errorsActions } from 'redux/actions/errors'
import { alertsActions } from 'redux/actions/alerts'
import { authActions } from 'redux/actions/auth'
@@ -68,11 +68,6 @@ const getTiers = (t) => [
},
]
-const paddleLanguageMapping = {
- zh: 'zh-Hans',
- uk: 'ru',
-}
-
const Pricing = ({ t, language }) => {
const dispatch = useDispatch()
const { authenticated, user } = useSelector(state => state.auth)
@@ -102,7 +97,7 @@ const Pricing = ({ t, language }) => {
}
dispatch(alertsActions.accountUpdated('The subscription has been upgraded.'))
- }, 1000)
+ }, 3000)
setPlanCodeLoading(null)
setDowngradeTo(null)
} else if (data.event === 'Checkout.Close') {
@@ -128,12 +123,15 @@ const Pricing = ({ t, language }) => {
window.Paddle.Checkout.open({
override: user.subCancelURL,
method: 'inline',
- // frameTarget: 'checkout-container',
- // frameInitialHeight: 416,
- // frameStyle: 'width:100%; min-width:312px; background-color: transparent; border: none;',
+ frameTarget: 'checkout-container',
+ frameInitialHeight: 416,
+ frameStyle: 'width:100%; min-width:312px; background-color: #f9fafb; border: none; border-radius: 10px; margin-top: 10px;',
locale: paddleLanguageMapping[language] || language,
displayModeTheme: theme,
})
+ setTimeout(() => {
+ document.querySelector('#checkout-container').scrollIntoView()
+ }, 500)
return
}
@@ -268,6 +266,7 @@ const Pricing = ({ t, language }) => {
})}
</div>
</div>
+ <div className='checkout-container' id='checkout-container' />
</div>
<Modal
onClose={() => {
diff --git a/src/redux/constants/index.js b/src/redux/constants/index.js
index db5917269..261dbe897 100644
--- a/src/redux/constants/index.js
+++ b/src/redux/constants/index.js
@@ -86,3 +86,8 @@ export const languageFlag = {
hi: 'IN',
zh: 'CN',
}
+
+export const paddleLanguageMapping = {
+ zh: 'zh-Hans',
+ uk: 'ru',
+}
diff --git a/src/ui/Modal.jsx b/src/ui/Modal.jsx
index e6df5df5a..fcfe87ded 100644
--- a/src/ui/Modal.jsx
+++ b/src/ui/Modal.jsx
@@ -106,7 +106,9 @@ Modal.propTypes = {
type: PropTypes.oneOf(['error', 'success', 'info', 'warning']),
title: PropTypes.string.isRequired,
onClose: PropTypes.func.isRequired,
- message: PropTypes.string,
+ message: PropTypes.oneOfType([
+ PropTypes.string, PropTypes.node,
+ ]),
className: PropTypes.string,
isOpened: PropTypes.bool,
onSubmit: PropTypes.func,