mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-29 07:59:42 +01:00
pass payment method type
This commit is contained in:
parent
0b1abc9ab0
commit
4fc90984d8
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 9c44fc1329b9595560462ffb7cd4d32bb0e22a68
|
||||
Subproject commit 36e65f08cad6cebdb5b90c88a68360296e8ff2ec
|
@ -39,8 +39,9 @@ export class AdjustPaymentComponent {
|
||||
async submit() {
|
||||
try {
|
||||
const request = new PaymentRequest();
|
||||
this.formPromise = this.paymentComponent.createPaymentToken().then((token) => {
|
||||
request.paymentToken = token;
|
||||
this.formPromise = this.paymentComponent.createPaymentToken().then((result) => {
|
||||
request.paymentToken = result[0];
|
||||
request.paymentMethodType = result[1];
|
||||
if (this.organizationId == null) {
|
||||
return this.apiService.postAccountPayment(request);
|
||||
} else {
|
||||
|
@ -128,7 +128,7 @@ export class CreateOrganizationComponent implements OnInit {
|
||||
} else {
|
||||
return this.paymentComponent.createPaymentToken();
|
||||
}
|
||||
}).then((token: string) => {
|
||||
}).then((tokenResult) => {
|
||||
if (this.selfHosted) {
|
||||
const fd = new FormData();
|
||||
fd.append('license', files[0]);
|
||||
@ -145,7 +145,8 @@ export class CreateOrganizationComponent implements OnInit {
|
||||
if (this.plan === 'free') {
|
||||
request.planType = PlanType.Free;
|
||||
} else {
|
||||
request.paymentToken = token;
|
||||
request.paymentToken = tokenResult[0];
|
||||
request.paymentMethodType = tokenResult[1];
|
||||
request.businessName = this.ownedBusiness ? this.businessName : null;
|
||||
request.additionalSeats = this.additionalSeats;
|
||||
request.additionalStorageGb = this.additionalStorage;
|
||||
|
@ -4,6 +4,8 @@ import {
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { PaymentMethodType } from 'jslib/enums/paymentMethodType';
|
||||
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
|
||||
const Keys = {
|
||||
@ -149,20 +151,22 @@ export class PaymentComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
createPaymentToken(): Promise<string> {
|
||||
createPaymentToken(): Promise<[string, PaymentMethodType]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.method === 'paypal') {
|
||||
this.btInstance.requestPaymentMethod().then((payload: any) => {
|
||||
resolve(payload.nonce);
|
||||
resolve([payload.nonce, PaymentMethodType.PayPal]);
|
||||
}).catch((err: any) => {
|
||||
reject(err.message);
|
||||
});
|
||||
} else if (this.method === 'card' || this.method === 'bank') {
|
||||
let type = PaymentMethodType.Card;
|
||||
let sourceObj: any = null;
|
||||
let createObj: any = null;
|
||||
if (this.method === 'card') {
|
||||
sourceObj = this.stripeCardNumberElement;
|
||||
} else {
|
||||
type = PaymentMethodType.BankAccount;
|
||||
sourceObj = 'bank_account';
|
||||
createObj = this.bank;
|
||||
}
|
||||
@ -170,7 +174,7 @@ export class PaymentComponent implements OnInit {
|
||||
if (result.error) {
|
||||
reject(result.error.message);
|
||||
} else if (result.token && result.token.id != null) {
|
||||
resolve(result.token.id);
|
||||
resolve([result.token.id, type]);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
|
@ -76,9 +76,10 @@ export class PremiumComponent implements OnInit {
|
||||
return this.finalizePremium();
|
||||
});
|
||||
} else {
|
||||
this.formPromise = this.paymentComponent.createPaymentToken().then((token) => {
|
||||
this.formPromise = this.paymentComponent.createPaymentToken().then((result) => {
|
||||
const fd = new FormData();
|
||||
fd.append('paymentToken', token);
|
||||
fd.append('paymentMethodType', result[1].toString());
|
||||
fd.append('paymentToken', result[0]);
|
||||
fd.append('additionalStorageGb', (this.additionalStorage || 0).toString());
|
||||
return this.apiService.postPremium(fd);
|
||||
}).then(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user