1
0
mirror of https://github.com/bitwarden/web synced 2026-02-27 09:53:36 +00:00

restrict changing payment method with iap

This commit is contained in:
Kyle Spearrin
2019-09-19 15:46:33 -04:00
parent a1c9c47c89
commit 6cb48c186e
6 changed files with 37 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import { BillingResponse } from 'jslib/models/response/billingResponse';
import { ApiService } from 'jslib/abstractions/api.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { PaymentMethodType } from 'jslib/enums/paymentMethodType';
import { TransactionType } from 'jslib/enums/transactionType';
@@ -34,7 +35,8 @@ export class UserBillingComponent implements OnInit {
verifyBankPromise: Promise<any>;
constructor(protected apiService: ApiService, protected i18nService: I18nService,
protected analytics: Angulartics2, protected toasterService: ToasterService) { }
protected analytics: Angulartics2, protected toasterService: ToasterService,
protected platformUtilsService: PlatformUtilsService) { }
async ngOnInit() {
await this.load();
@@ -72,6 +74,10 @@ export class UserBillingComponent implements OnInit {
}
addCredit() {
if (this.paymentSourceInApp) {
this.platformUtilsService.showDialog(this.i18nService.t('cannotPerformInAppPurchase'));
return;
}
this.showAddCredit = true;
}
@@ -83,6 +89,10 @@ export class UserBillingComponent implements OnInit {
}
changePayment() {
if (this.paymentSourceInApp) {
this.platformUtilsService.showDialog(this.i18nService.t('cannotPerformInAppPurchase'));
return;
}
this.showAdjustPayment = true;
}
@@ -105,6 +115,12 @@ export class UserBillingComponent implements OnInit {
return this.billing != null ? this.billing.paymentSource : null;
}
get paymentSourceInApp() {
return this.paymentSource != null &&
(this.paymentSource.type === PaymentMethodType.AppleInApp ||
this.paymentSource.type === PaymentMethodType.GoogleInApp);
}
get invoices() {
return this.billing != null ? this.billing.invoices : null;
}