<commit_before>import { PaymentMode } from './../../../core/models/payment_mode';
import { Observable } from 'rxjs/Rx';
import { PaymentService } from './../services/payment.service';
import { CheckoutService } from './../../../core/services/checkout.service';
import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-payment-modes-list',
  templateUrl: './payment-modes-list.component.html',
  styleUrls: ['./payment-modes-list.component.scss']
})
export class PaymentModesListComponent implements OnInit {

  @Input() paymentAmount: number;
  paymentModes: PaymentMode[];
  selectedMode: PaymentMode = new PaymentMode;

  constructor(private checkoutService: CheckoutService,
    private paymentService: PaymentService) {
      this.fetchAllPayments();
  }

  ngOnInit() {
  }

  selectedPaymentMode(mode) {
    this.selectedMode = mode;
  }

  private fetchAllPayments() {
    this.checkoutService.availablePaymentMethods()
      .subscribe((payment) => {
        this.paymentModes = payment.payment_methods;
        this.selectedMode = this.paymentService.setCODAsSelectedMode(this.paymentModes);
      });
  }

  makePayment() {
    const paymentModeId = this.selectedMode.id;
    this.checkoutService.createNewPayment(paymentModeId, this.paymentAmount)
      .subscribe();
  }

}<commit_msg>redirect to home page after payment confirmation<commit_after>import { Router } from '@angular/router';
import { PaymentMode } from './../../../core/models/payment_mode';
import { Observable } from 'rxjs/Rx';
import { PaymentService } from './../services/payment.service';
import { CheckoutService } from './../../../core/services/checkout.service';
import { Component, OnInit, Input } from '@angular/core';

@Component({
  selector: 'app-payment-modes-list',
  templateUrl: './payment-modes-list.component.html',
  styleUrls: ['./payment-modes-list.component.scss']
})
export class PaymentModesListComponent implements OnInit {

  @Input() paymentAmount: number;
  paymentModes: PaymentMode[];
  selectedMode: PaymentMode = new PaymentMode;

  constructor(private checkoutService: CheckoutService,
    private paymentService: PaymentService,
    private router: Router) {
      this.fetchAllPayments();
  }

  ngOnInit() {
  }

  selectedPaymentMode(mode) {
    this.selectedMode = mode;
  }

  private fetchAllPayments() {
    this.checkoutService.availablePaymentMethods()
      .subscribe((payment) => {
        this.paymentModes = payment.payment_methods;
        this.selectedMode = this.paymentService.setCODAsSelectedMode(this.paymentModes);
      });
  }

  makePayment() {
    const paymentModeId = this.selectedMode.id;
    this.checkoutService.createNewPayment(paymentModeId, this.paymentAmount)
      .subscribe();
    this.router.navigate(['/']);
  }

}
{'fraction_non_alphanumeric': 0.13841201716738197, 'fraction_numerical': 0.0, 'mean_word_length': 3.9680284191829487, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5014548', 'n_tokens_mistral': 814, 'n_tokens_neox': 796, 'n_words': 152}