import * as React from 'react'; import { Form, Button } from 'reactstrap'; import Select from 'react-select'; import sabpaisaService from "../../../services/sabpaisa-service"; import { getPaymentModeByName } from '../../../helpers/common-helper'; import { CashPaymentInterface, MappingBeanInterface } from '../../../services/Models/sabpaisa-payment-types'; export interface Props { updateState: (arg: number) => void; paymentData: { [key: string]: any }, makeApiReqCardFeeCalculation: (arg: MappingBeanInterface) => void, updateStateWithError: (resError: any, screenId: number) => void, } export interface State { readonly isClearable: boolean; readonly isDisabled: boolean; readonly isLoading: boolean; readonly isRtl: boolean; readonly isSearchable: boolean; processing: boolean, mappingBeans: MappingBeanInterface selectedMapping: { [key: string]: any } } export default class Neft extends React.Component { constructor(props: Props) { super(props); this.state = { isClearable: true, isDisabled: false, isLoading: false, isRtl: false, isSearchable: true, processing: false, mappingBeans: { mappingId: "", feeForward: "", clientId: "", paymodeId: "", endpointId: "", active: "", paymode: { paymodeId: "", paymodeType: "", paymodeName: "", }, endpoint: { epId: "", bankName: "", bankId: "", agrName: "", epType: "", } }, selectedMapping: {} }; } onChange = (e: any) => { if (!e) { this.setState({ selectedMapping: {} }) } else { const { value } = e; let data = { ...value } this.props.makeApiReqCardFeeCalculation(data); this.setState({ mappingBeans: value, selectedMapping: e }) } } makeApiReqNeftPayment = (e: any) => { e.preventDefault(); const { amountBean, amountType, clientCode, clientId, clientName, clientTxnid, payerEmail, payerMobNumber, requestAmount, spTxnId, } = this.props.paymentData; const { mappingBeans } = this.state; this.setState({ processing: true }) let finalData: CashPaymentInterface = { "txnId": spTxnId, "clientId": clientId, "clientTxnId": clientTxnid, "requestAmount": requestAmount, "mappingBean": mappingBeans, "payeeEmail": payerEmail, "payeeMobile": payerMobNumber, "udf1": "chrome", "amountType": amountType, "payMode": mappingBeans.paymode, "endPoint": mappingBeans.endpoint, "paidAmount": amountBean.paidAmount, clientName, clientCode } sabpaisaService.cashPayment(finalData) .then((response: any) => { this.setState({ processing: false }) if (response.data.bankUrl) { window.location.href = response.data.bankUrl; } }).catch((e: Error) => { this.props.updateStateWithError(e, 400); this.setState({ processing: false }) }); } render() { const { paymentData } = this.props; const { isClearable, isSearchable, isDisabled, isLoading, isRtl, selectedMapping, processing } = this.state; const neft_bank_details = (paymentData && paymentData.activeMapping.length) ? getPaymentModeByName("neft_rtgs", paymentData.activeMapping) : []; const isShowButton: boolean = Object.keys(selectedMapping).length ? true : false; return (

NEFT Payment

this.props.updateState(54)} className="paymentMethod"> Cash this.props.updateState(51)} className="paymentMethod"> E-RTGS this.props.updateState(52)} className="paymentMethod"> E-NEFT this.props.updateState(53)} className="paymentMethod"> E-IMPS