File

integration-libs/digital-payments/src/checkout/cms-components/dp-payment-method/dp-payment-form/dp-payment-form.component.ts

Implements

OnInit

Metadata

selector cx-dp-payment-form
templateUrl ./dp-payment-form.component.html

Index

Properties
Methods
Outputs

Constructor

constructor(dpPaymentService: DpCheckoutPaymentService, dpStorageService: DpLocalStorageService, globalMsgService: GlobalMessageService, winRef: WindowRef)
Parameters :
Name Type Optional
dpPaymentService DpCheckoutPaymentService No
dpStorageService DpLocalStorageService No
globalMsgService GlobalMessageService No
winRef WindowRef No

Outputs

closeForm
Type : EventEmitter

Methods

ngOnInit
ngOnInit()
Returns : void
redirect
redirect(url: string)
Parameters :
Name Type Optional
url string No
Returns : void

Properties

closeForm
Default value : new EventEmitter<any>()
Decorators :
@Output()
import { DpLocalStorageService } from '../../../facade/dp-local-storage.service';
import {
  GlobalMessageService,
  GlobalMessageType,
  WindowRef,
} from '@spartacus/core';
import { DpCheckoutPaymentService } from '../../../facade';
import { Component, OnInit, Output, EventEmitter } from '@angular/core';

@Component({
  selector: 'cx-dp-payment-form',
  templateUrl: './dp-payment-form.component.html',
})
export class DpPaymentFormComponent implements OnInit {
  @Output()
  closeForm = new EventEmitter<any>();

  constructor(
    private dpPaymentService: DpCheckoutPaymentService,
    private dpStorageService: DpLocalStorageService,
    private globalMsgService: GlobalMessageService,
    private winRef: WindowRef
  ) {}

  ngOnInit(): void {
    this.dpPaymentService.getCardRegistrationDetails().subscribe((request) => {
      if (request?.url) {
        this.dpStorageService.syncCardRegistrationState(request);
        this.redirect(request.url);
      } else if (request) {
        this.globalMsgService.add(
          { key: 'dpPaymentForm.error.redirect' },
          GlobalMessageType.MSG_TYPE_ERROR
        );
        this.closeForm.emit();
      }
    });
  }

  redirect(url: string) {
    const window = this.winRef.nativeWindow;

    if (window?.location) {
      window.location.href = url;
    }
  }
}
<div class="text-center">{{ 'dpPaymentForm.redirect' | cxTranslate }}</div>
<div class="cx-spinner"><cx-spinner></cx-spinner></div>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""