Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Referer Header in case of Device Ionic App

Hi I have an App developed in Ionic v1 and its working fine while making payment from browser , but while making payment from device Android its not redirecting me to the payment gateway page.

https://test.sbiepay.com/secure/AggregatorHostedListener

The payment gateway team said that I need to pass extra header that is Referer in case of Android device then only they will allow the request from android device.

I did every trick to add extra header in case of device but nothing is working.

Can anybody help me in this how could I send extra header with request to payment gateway, in case of android device.

<form name="sendParam" method="post" 
 action="https://test.sbiepay.com/secure/AggregatorHostedListener">                       
            <input ng-repeat="(key, value) in fields" type="hidden" 
  name="{{key}}" value="{{value}}" />                                
            <input type="submit" value="enter" style="position: 
     absolute; left: -9999px"/>
</form>

Above form submit using js. In case of web these header added automatically.

var fields = {                        
    EncryptTrans: response.data.data.EncryptTrans,                                                      
    merchIdVal: appConfig.merchIdVal                           
};                        
if (appConfig.isDevice) {//Device
    console.log('Run in device');
    $http.defaults.headers.post['Referer'] = 
    "http://app.ptl.staging.edubold.com/";
    $http.defaults.headers.post['Origin'] = 
    "http://app.ptl.staging.edubold.com/";                            
    openInAppBrowser(fields);
}
like image 568
Sunil Rawat Avatar asked Apr 23 '18 06:04

Sunil Rawat


1 Answers

Instead of doing this, You need to use ajax.

Get all the response and save in db using ajax in the same file. Then using callback method fetch the data directly from db.

You cannot set origin header using HTML.

like image 200
Harkamal Avatar answered Nov 04 '22 08:11

Harkamal