src/app/components/payments/payment-create/payment-create.component.ts
selector | app-payment-create |
styleUrls | ./payment-create.component.css |
templateUrl | ./payment-create.component.html |
Properties |
Methods |
constructor(paymentService: PaymentService, templateService: TemplateService, app: AppStateStore, router: Router)
|
|||||||||||||||
Parameters :
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
submitPayment |
submitPayment()
|
Returns :
void
|
model |
Default value : new PaymentCreateVm()
|
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { PaymentService, TemplateService } from '../../../providers';
import { AppStateStore } from '../../../providers/stores/app-state.store';
import { PaymentCreateVm } from './payment-create.vm';
@Component({
selector: 'app-payment-create',
templateUrl: './payment-create.component.html',
styleUrls: ['./payment-create.component.css']
})
export class PaymentCreateComponent implements OnInit {
model = new PaymentCreateVm();
constructor(
private paymentService: PaymentService,
private templateService: TemplateService,
private app: AppStateStore,
private router: Router
) {}
ngOnInit() {
if (!this.app.amount) {
this.router.navigate(['/start']);
}
return this.submitPayment();
}
submitPayment() {
console.log('submit payment started');
this.paymentService
.createPayment(
this.app.amount,
this.app.memo,
this.app.debitTemplate,
this.app.creditTemplate
)
.subscribe(payment => {
if (!payment) {
return console.log('Failed to create payment!');
}
this.templateService
.loadTemplates()
.subscribe(() => console.log('Templates refreshed'));
this.app.hasPassedMfa = false;
this.app.payment = payment;
this.router.navigate(['/success-screen']);
});
}
}
<div class="scroller">
<app-loader [header]="model.loaderHeader" [message]="model.message"></app-loader>
</div>
./payment-create.component.css