Merge pull request #695 from ente-io/fix-buy-subscription-on-desktop

fix buy subscription on desktop
This commit is contained in:
Neeraj Gupta 2022-09-02 11:45:46 +05:30 committed by GitHub
commit d2d40e747f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View file

@ -0,0 +1 @@
export const DESKTOP_REDIRECT_URL = 'https://payments.ente.io/desktop-redirect';

View file

@ -5,6 +5,8 @@ import HTTPService from './HTTPService';
import { logError } from 'utils/sentry'; import { logError } from 'utils/sentry';
import { getPaymentToken } from './userService'; import { getPaymentToken } from './userService';
import { Plan, Subscription } from 'types/billing'; import { Plan, Subscription } from 'types/billing';
import isElectron from 'is-electron';
import { DESKTOP_REDIRECT_URL } from 'constants/billing';
const ENDPOINT = getEndpoint(); const ENDPOINT = getEndpoint();
@ -168,9 +170,13 @@ class billingService {
action: string action: string
) { ) {
try { try {
window.location.href = `${getPaymentsURL()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${ let redirectURL;
window.location.origin if (isElectron()) {
}/gallery`; redirectURL = DESKTOP_REDIRECT_URL;
} else {
redirectURL = `${window.location.origin}/gallery`;
}
window.location.href = `${getPaymentsURL()}?productID=${productID}&paymentToken=${paymentToken}&action=${action}&redirectURL=${redirectURL}`;
} catch (e) { } catch (e) {
logError(e, 'unable to get payments url'); logError(e, 'unable to get payments url');
throw e; throw e;