1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-02 12:47:41 +02:00

Server: Add link to Stripe subscription page to manage payment details

This commit is contained in:
Laurent Cozic 2021-09-13 12:30:36 +01:00
parent cd99e675d9
commit 4e7fe66883
4 changed files with 22 additions and 6 deletions

View File

@ -137,6 +137,14 @@ export const postHandlers: PostHandlers = {
// //
// - The public config is under packages/server/stripeConfig.json // - The public config is under packages/server/stripeConfig.json
// - The private config is in the server .env file // - The private config is in the server .env file
//
// # Failed Stripe cli login
//
// If the tool show this error, with code "api_key_expired":
//
// > FATAL Error while authenticating with Stripe: Authorization failed
//
// Need to logout and login again to refresh the CLI token - `stripe logout && stripe login`
webhook: async (stripe: Stripe, _path: SubPath, ctx: AppContext, event: Stripe.Event = null, logErrors: boolean = true) => { webhook: async (stripe: Stripe, _path: SubPath, ctx: AppContext, event: Stripe.Event = null, logErrors: boolean = true) => {
event = event ? event : await stripeEvent(stripe, ctx.req); event = event ? event : await stripeEvent(stripe, ctx.req);
@ -426,7 +434,7 @@ const getHandlers: Record<string, StripeRouteHandler> = {
<body> <body>
<button id="checkout">Subscribe</button> <button id="checkout">Subscribe</button>
<script> <script>
var PRICE_ID = ${basicPrice.id}; var PRICE_ID = ${JSON.stringify(basicPrice.id)};
function handleResult() { function handleResult() {
console.info('Redirected to checkout'); console.info('Redirected to checkout');

View File

@ -15,7 +15,7 @@ import uuidgen from '../../utils/uuidgen';
import { formatMaxItemSize, formatMaxTotalSize, formatTotalSize, formatTotalSizePercent, yesOrNo } from '../../utils/strings'; import { formatMaxItemSize, formatMaxTotalSize, formatTotalSize, formatTotalSizePercent, yesOrNo } from '../../utils/strings';
import { getCanShareFolder, totalSizeClass } from '../../models/utils/user'; import { getCanShareFolder, totalSizeClass } from '../../models/utils/user';
import { yesNoDefaultOptions, yesNoOptions } from '../../utils/views/select'; import { yesNoDefaultOptions, yesNoOptions } from '../../utils/views/select';
import { confirmUrl } from '../../utils/urlUtils'; import { confirmUrl, stripePortalUrl } from '../../utils/urlUtils';
import { cancelSubscriptionByUserId, updateSubscriptionType } from '../../utils/stripe'; import { cancelSubscriptionByUserId, updateSubscriptionType } from '../../utils/stripe';
import { createCsrfTag } from '../../utils/csrf'; import { createCsrfTag } from '../../utils/csrf';
import { formatDateTime } from '../../utils/time'; import { formatDateTime } from '../../utils/time';
@ -175,6 +175,7 @@ router.get('users/:id', async (path: SubPath, ctx: AppContext, user: User = null
view.content.canShareFolderOptions = yesNoDefaultOptions(user, 'can_share_folder'); view.content.canShareFolderOptions = yesNoDefaultOptions(user, 'can_share_folder');
view.content.canUploadOptions = yesNoOptions(user, 'can_upload'); view.content.canUploadOptions = yesNoOptions(user, 'can_upload');
view.content.userFlags = userFlags; view.content.userFlags = userFlags;
view.content.stripePortalUrl = stripePortalUrl();
view.jsFiles.push('zxcvbn'); view.jsFiles.push('zxcvbn');
view.cssFiles.push('index/user'); view.cssFiles.push('index/user');

View File

@ -4,16 +4,20 @@
Most of your details can be found in your Profile page. To open it, click on the Profile button - this is the button in the top right corner, with your name or email on it. Most of your details can be found in your Profile page. To open it, click on the Profile button - this is the button in the top right corner, with your name or email on it.
## How can I cancel my account?
Click on the [Profile button](#how-can-i-change-my-details), then scroll down and click on "Cancel subscription".
## How can I get more space? ## How can I get more space?
If you are on a Basic account, you may upgrade to a Pro account to get more space. Click on the [Profile button](#how-can-i-change-my-details), then scroll down and select "Upgrade account". If you are on a Basic account, you may upgrade to a Pro account to get more space. Click on the [Profile button](#how-can-i-change-my-details), then scroll down and select "Upgrade account".
If you are already on a Pro account, and you need more space for specific reasons, please contact us as we may increase the cap in some cases. If you are already on a Pro account, and you need more space for specific reasons, please contact us as we may increase the cap in some cases.
## How can I manage my payment details?
To update your card or other payment details, click on the [Profile button](#how-can-i-change-my-details), then scroll down and click on "Manage payment details".
## How can I cancel my account?
Click on the [Profile button](#how-can-i-change-my-details), then scroll down and click on "Cancel subscription".
## Further information ## Further information
- [Joplin Offical Website](https://joplinapp.org) - [Joplin Offical Website](https://joplinapp.org)

View File

@ -131,6 +131,9 @@
{{#showUpdateSubscriptionPro}} {{#showUpdateSubscriptionPro}}
<a href="{{{global.baseUrl}}}/upgrade" class="button is-warning block">Upgrade to Pro</a> <a href="{{{global.baseUrl}}}/upgrade" class="button is-warning block">Upgrade to Pro</a>
{{/showUpdateSubscriptionPro}} {{/showUpdateSubscriptionPro}}
{{#showCancelSubscription}}
<p class="block"><a href="{{stripePortalUrl}}">Manage payment details</a></p>
{{/showCancelSubscription}}
{{#showCancelSubscription}} {{#showCancelSubscription}}
<p id="user_cancel_subscription_link" class="block"><a href="#">Cancel subscription</a></p> <p id="user_cancel_subscription_link" class="block"><a href="#">Cancel subscription</a></p>
<input type="submit" id="user_cancel_subscription_button" name="user_cancel_subscription_button" class="button is-danger" value="Cancel subscription" /> <input type="submit" id="user_cancel_subscription_button" name="user_cancel_subscription_button" class="button is-danger" value="Cancel subscription" />