feat: add purchase url (#695)

* feat: add purchase url

* chore: bump snjs

* fix: reuse existing function
This commit is contained in:
Mo
2021-10-21 12:41:58 -05:00
committed by GitHub
parent 397e4963bd
commit e79811afda
8 changed files with 31 additions and 22 deletions

View File

@@ -3,7 +3,7 @@ import { LinkButton, Text } from '@/preferences/components';
import { Button } from '@/components/Button';
import { WebApplication } from "@/ui_models/application";
import { useState } from "preact/hooks";
import { isDesktopApplication } from "@/utils";
import { loadPurchaseFlowUrl } from "@/purchaseFlow/PurchaseFlowWrapper";
export const NoSubscription: FunctionalComponent<{
application: WebApplication;
@@ -15,12 +15,7 @@ export const NoSubscription: FunctionalComponent<{
const errorMessage = 'There was an error when attempting to redirect you to the subscription page.';
setIsLoadingPurchaseFlow(true);
try {
const url = await application.getPurchaseFlowUrl();
if (url) {
const currentUrl = window.location.href;
const successUrl = isDesktopApplication() ? `standardnotes://${currentUrl}` : currentUrl;
window.location.assign(`${url}&success_url=${successUrl}`);
} else {
if (!await loadPurchaseFlowUrl(application)) {
setPurchaseFlowError(errorMessage);
}
} catch (e) {