mirror of
https://github.com/bitwarden/desktop.git
synced 2024-11-28 12:35:40 +01:00
getReceiptUrl only when receipt available
This commit is contained in:
parent
7e01fcba2b
commit
dff1bb8144
@ -43,11 +43,11 @@ export class PremiumComponent extends BasePremiumComponent {
|
|||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await super.ngOnInit();
|
await super.ngOnInit();
|
||||||
if (this.isPremium || !this.platformUtilsService.isMacAppStore()) {
|
const isMacAppStore = this.platformUtilsService.isMacAppStore();
|
||||||
return;
|
if (isMacAppStore) {
|
||||||
|
this.canMakeMacAppStorePayments = remote.inAppPurchase.canMakePayments();
|
||||||
}
|
}
|
||||||
this.canMakeMacAppStorePayments = remote.inAppPurchase.canMakePayments();
|
if (this.isPremium || !isMacAppStore || !this.canMakeMacAppStorePayments) {
|
||||||
if (!this.canMakeMacAppStorePayments) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const pricePromise = new Promise((resolve) => {
|
const pricePromise = new Promise((resolve) => {
|
||||||
@ -147,7 +147,7 @@ export class PremiumComponent extends BasePremiumComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async manage() {
|
async manage() {
|
||||||
if (!this.canMakeMacAppStorePayments || remote.inAppPurchase.getReceiptURL() == null) {
|
if (!this.canMakeMacAppStorePayments || this.getReceiptUrl() == null) {
|
||||||
await super.manage();
|
await super.manage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ export class PremiumComponent extends BasePremiumComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async makePremium(restore: boolean) {
|
private async makePremium(restore: boolean) {
|
||||||
const receiptUrl = remote.inAppPurchase.getReceiptURL();
|
const receiptUrl = this.getReceiptUrl();
|
||||||
const receiptBuffer = fs.readFileSync(receiptUrl);
|
const receiptBuffer = fs.readFileSync(receiptUrl);
|
||||||
const receiptB64 = Utils.fromBufferToB64(receiptBuffer);
|
const receiptB64 = Utils.fromBufferToB64(receiptBuffer);
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
@ -193,10 +193,18 @@ export class PremiumComponent extends BasePremiumComponent {
|
|||||||
|
|
||||||
private setCanRestorePurchase() {
|
private setCanRestorePurchase() {
|
||||||
if (!this.isPremium && this.canMakeMacAppStorePayments) {
|
if (!this.isPremium && this.canMakeMacAppStorePayments) {
|
||||||
const receiptUrl = remote.inAppPurchase.getReceiptURL();
|
const receiptUrl = this.getReceiptUrl();
|
||||||
this.canRestorePurchase = receiptUrl != null;
|
this.canRestorePurchase = receiptUrl != null;
|
||||||
} else {
|
} else {
|
||||||
this.canRestorePurchase = false;
|
this.canRestorePurchase = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getReceiptUrl(): string {
|
||||||
|
const receiptUrl = remote.inAppPurchase.getReceiptURL();
|
||||||
|
if (receiptUrl != null) {
|
||||||
|
return fs.existsSync(receiptUrl) ? receiptUrl : null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user