mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 00:03:56 +00:00
org billing settings setup
This commit is contained in:
@@ -20,8 +20,10 @@ const Keys = {
|
||||
})
|
||||
export class PaymentComponent implements OnInit {
|
||||
@Input() showOptions = true;
|
||||
@Input() method = 'card';
|
||||
@Input() hideBank = false;
|
||||
@Input() hidePaypal = false;
|
||||
|
||||
method = 'card';
|
||||
card: any = {
|
||||
number: null,
|
||||
exp_month: null,
|
||||
@@ -29,6 +31,14 @@ export class PaymentComponent implements OnInit {
|
||||
address_country: '',
|
||||
address_zip: null,
|
||||
};
|
||||
bank: any = {
|
||||
routing_number: null,
|
||||
account_number: null,
|
||||
account_holder_name: null,
|
||||
account_holder_type: '',
|
||||
currency: 'USD',
|
||||
country: 'US',
|
||||
};
|
||||
cardExpMonthOptions: any[];
|
||||
cardExpYearOptions: any[];
|
||||
|
||||
@@ -68,24 +78,32 @@ export class PaymentComponent implements OnInit {
|
||||
{ name: '-- ' + i18nService.t('select') + ' --', value: null },
|
||||
];
|
||||
const year = (new Date()).getFullYear();
|
||||
for (let i = year; i < (year + 10); i++) {
|
||||
for (let i = year; i < (year + 15); i++) {
|
||||
this.cardExpYearOptions.push({ name: i.toString(), value: i.toString().slice(-2) });
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (!this.showOptions) {
|
||||
this.hidePaypal = this.method !== 'paypal';
|
||||
this.hideBank = this.method !== 'bank';
|
||||
}
|
||||
window.document.head.appendChild(this.stripeScript);
|
||||
window.document.head.appendChild(this.btScript);
|
||||
if (!this.hidePaypal) {
|
||||
window.document.head.appendChild(this.btScript);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
window.document.head.removeChild(this.stripeScript);
|
||||
window.document.head.removeChild(this.btScript);
|
||||
Array.from(window.document.querySelectorAll('iframe')).forEach((el) => {
|
||||
if (el.src != null && el.src.indexOf('stripe') > -1) {
|
||||
window.document.body.removeChild(el);
|
||||
}
|
||||
});
|
||||
if (!this.hidePaypal) {
|
||||
window.document.head.removeChild(this.btScript);
|
||||
}
|
||||
}
|
||||
|
||||
changeMethod() {
|
||||
@@ -127,7 +145,7 @@ export class PaymentComponent implements OnInit {
|
||||
}).catch((err: any) => {
|
||||
reject(err.message);
|
||||
});
|
||||
} else {
|
||||
} else if (this.method === 'card') {
|
||||
(window as any).Stripe.card.createToken(this.card, (status: number, response: any) => {
|
||||
if (status === 200 && response.id != null) {
|
||||
resolve(response.id);
|
||||
@@ -137,6 +155,16 @@ export class PaymentComponent implements OnInit {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
} else if (this.method === 'bank') {
|
||||
(window as any).Stripe.bankAccount.createToken(this.bank, (status: number, response: any) => {
|
||||
if (status === 200 && response.id != null) {
|
||||
resolve(response.id);
|
||||
} else if (response.error != null) {
|
||||
reject(response.error.message);
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user