1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Receive POST data inside angular component

Discussão em 'Angular' iniciado por Rohit, Novembro 10, 2024 às 03:33.

  1. Rohit

    Rohit Guest

    I am integrating Payment gateway in Angular version 7.

    Payment gateway needs data input like below

    requestParameter : MerchantId||CollaboratorID||Encrypted_string


    I tried to submit form using ngForm as below, but my request is not posting to Payment gateway url and getting error 404 not found for "http://localhost:4200/direcPayment/" and Session expired message of Payment gateway in a response of that. It's just like if anything is wrong in the request you get session expired message.

    <form (ngSubmit)="onSubmit()" method="POST" mt-3>


    Behind in the code, I am passing the parameter as required and making http.post call as below. On click of OnSubmit I have called formSubmit with encrypted string

    formSubmit( encryptedString) {
    const formData = new FormData();
    formData.append( 'requestParameter', encryptedString);

    this.http.post('direcPayment/', formData, httpFormDataOptions)
    .subscribe((resposne) => {
    console.log(resposne);
    });


    }

    Inside "httpFormDataOptions" I have added below headers

    const httpFormDataOptions = {
    headers: new HttpHeaders(),
    };
    httpFormDataOptions.headers.append('Access-Control-Allow-Origin', '*');
    httpFormDataOptions.headers.append('Access-Control-Allow-Methods', 'DELETE, POST, GET, OPTIONS');
    httpFormDataOptions.headers.append('Access-Control-Allow-Headers', 'Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With');


    /direcPayment refers to my Proxy.config.json file as below

    {
    "/direcPayment": {
    "target": "PaymentGatewayURL",
    "secure": true,
    "pathRewrite": {"^/direcPayment" : ""},
    "changeOrigin": true
    },
    }


    so currently I used ngNoForm and submit the form using action attribute.

    So I want to ask two queries


    1. Submitting form to payment gateway link using httpClient POST method


    2. Payment Gateway says, if payment is either successful/failure then they will redirect to success/failure URL as POST data in encrypted format, So how to receive data to a specific URL in angular? Is there any way to receive data if someone called my angular URL in both cases either using httpClient Call OR ngNoForm

    Thanks.

    Continue reading...

Compartilhe esta Página