1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-06 18:57:56 +01:00

adjust payment for orgs

This commit is contained in:
Kyle Spearrin 2018-07-17 15:07:32 -04:00
parent e4a684ff10
commit 56b9cb5c9e
4 changed files with 12 additions and 17 deletions

View File

@ -10,7 +10,7 @@
<form #form class="card" (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="canChange"> <form #form class="card" (ngSubmit)="submit()" [appApiAction]="formPromise" ngNativeValidate *ngIf="canChange">
<div class="card-body"> <div class="card-body">
<h3 class="card-body-header">{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}</h3> <h3 class="card-body-header">{{(currentType != null ? 'changePaymentMethod' : 'addPaymentMethod') | i18n}}</h3>
<app-payment [showOptions]="!organizationId || currentType == null" [hidePaypal]="true" [hideBank]="!organizationId"></app-payment> <app-payment [showOptions]="organizationId || currentType == null" [hidePaypal]="true" [hideBank]="!organizationId"></app-payment>
<button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading"> <button type="submit" class="btn btn-primary btn-submit" [disabled]="form.loading">
<i class="fa fa-spinner fa-spin"></i> <i class="fa fa-spinner fa-spin"></i>
<span>{{'submit' | i18n}}</span> <span>{{'submit' | i18n}}</span>

View File

@ -61,6 +61,6 @@ export class AdjustPaymentComponent {
} }
get canChange() { get canChange() {
return this.currentType == null || this.currentType === PaymentMethodType.Card; return this.currentType == null || this.currentType === PaymentMethodType.Card || this.organizationId != null;
} }
} }

View File

@ -321,11 +321,13 @@
<div class="row"> <div class="row">
<div class="form-group col-6"> <div class="form-group col-6">
<label for="routing_number">{{'routingNumber' | i18n}}</label> <label for="routing_number">{{'routingNumber' | i18n}}</label>
<input id="routing_number" class="form-control" type="text" name="routing_number" [(ngModel)]="bank.routing_number" required> <input id="routing_number" class="form-control" type="text" name="routing_number" [(ngModel)]="bank.routing_number" required
appInputVerbatim>
</div> </div>
<div class="form-group col-6"> <div class="form-group col-6">
<label for="account_number">{{'accountNumber' | i18n}}</label> <label for="account_number">{{'accountNumber' | i18n}}</label>
<input id="account_number" class="form-control" type="text" name="account_number" [(ngModel)]="bank.account_number" required> <input id="account_number" class="form-control" type="text" name="account_number" [(ngModel)]="bank.account_number" required
appInputVerbatim>
</div> </div>
<div class="form-group col-6"> <div class="form-group col-6">
<label for="account_holder_name">{{'accountHolderName' | i18n}}</label> <label for="account_holder_name">{{'accountHolderName' | i18n}}</label>

View File

@ -20,7 +20,7 @@ const Keys = {
}) })
export class PaymentComponent implements OnInit { export class PaymentComponent implements OnInit {
@Input() showOptions = true; @Input() showOptions = true;
@Input() method = 'card'; @Input() method: 'card' | 'paypal' | 'bank' = 'card';
@Input() hideBank = false; @Input() hideBank = false;
@Input() hidePaypal = false; @Input() hidePaypal = false;
@ -145,18 +145,11 @@ export class PaymentComponent implements OnInit {
}).catch((err: any) => { }).catch((err: any) => {
reject(err.message); reject(err.message);
}); });
} else if (this.method === 'card') { } else if (this.method === 'card' || this.method === 'bank') {
(window as any).Stripe.card.createToken(this.card, (status: number, response: any) => { const createObj: any = this.method === 'card' ? (window as any).Stripe.card :
if (status === 200 && response.id != null) { (window as any).Stripe.bankAccount;
resolve(response.id); const sourceObj = this.method === 'card' ? this.card : this.bank;
} else if (response.error != null) { createObj.createToken(sourceObj, (status: number, response: any) => {
reject(response.error.message);
} else {
reject();
}
});
} else if (this.method === 'bank') {
(window as any).Stripe.bankAccount.createToken(this.bank, (status: number, response: any) => {
if (status === 200 && response.id != null) { if (status === 200 && response.id != null) {
resolve(response.id); resolve(response.id);
} else if (response.error != null) { } else if (response.error != null) {