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">
<div class="card-body">
<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">
<i class="fa fa-spinner fa-spin"></i>
<span>{{'submit' | i18n}}</span>

View File

@ -61,6 +61,6 @@ export class AdjustPaymentComponent {
}
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="form-group col-6">
<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 class="form-group col-6">
<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 class="form-group col-6">
<label for="account_holder_name">{{'accountHolderName' | i18n}}</label>

View File

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