mirror of
https://github.com/bitwarden/desktop.git
synced 2025-01-18 20:31:32 +01:00
in-app purchase pre-check
This commit is contained in:
parent
0e52c0d164
commit
a092631fa4
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit ec012c99341ee65c0d5a7a7fdf153e79bfb274be
|
||||
Subproject commit 575a28e25fd27969d0335f06b1778027f1214c3e
|
@ -15,6 +15,10 @@ import { TokenService } from 'jslib/abstractions/token.service';
|
||||
|
||||
import { PremiumComponent as BasePremiumComponent } from 'jslib/angular/components/premium.component';
|
||||
|
||||
import { PaymentMethodType } from 'jslib/enums/paymentMethodType';
|
||||
|
||||
import { IapCheckRequest } from 'jslib/models/request/iapCheckRequest';
|
||||
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
@Component({
|
||||
@ -64,7 +68,7 @@ export class PremiumComponent extends BasePremiumComponent {
|
||||
const receiptBuffer = fs.readFileSync(receiptUrl);
|
||||
const receiptB64 = Utils.fromBufferToB64(receiptBuffer);
|
||||
const fd = new FormData();
|
||||
fd.append('paymentMethodType', '1');
|
||||
fd.append('paymentMethodType', '6');
|
||||
fd.append('paymentToken', receiptB64);
|
||||
fd.append('additionalStorageGb', '0');
|
||||
try {
|
||||
@ -104,11 +108,16 @@ export class PremiumComponent extends BasePremiumComponent {
|
||||
await super.purchase();
|
||||
return;
|
||||
}
|
||||
remote.inAppPurchase.purchaseProduct('premium_annually', 1, (isValid) => {
|
||||
if (!isValid) {
|
||||
// TODO?
|
||||
}
|
||||
});
|
||||
try {
|
||||
const request = new IapCheckRequest();
|
||||
request.paymentMethodType = PaymentMethodType.AppleInApp;
|
||||
await this.apiService.postIapCheck(request);
|
||||
remote.inAppPurchase.purchaseProduct('premium_annually', 1, (isValid) => {
|
||||
if (!isValid) {
|
||||
// TODO?
|
||||
}
|
||||
});
|
||||
} catch { }
|
||||
}
|
||||
|
||||
private async finalizePremium() {
|
||||
|
Loading…
Reference in New Issue
Block a user