How to add Referer Header in case of Device Ionic App
Asked Answered
T

1

11

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);
}
Tenuto answered 23/4, 2018 at 6:33 Comment(12)
better do a ajax requestText
ajax request for what?Tenuto
for the paymentText
payment gateway do not allow this, I have implement it according to ionic v1.Tenuto
are you sure about that?Text
see #9517365 , you can't send header via html formText
I am in trouble then , i can not use another code for this because , in both case same code must work in onic v1. Any other suggestion pleaseTenuto
i suggest you use another payment provider, on for use in phone appsText
Let us continue this discussion in chat.Tenuto
No one can help me in this?Tenuto
I don't know if I understand your problem correctly. But changing (or adding in the case of an ionic app) the "Referer" header is just forbidden. See developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_nameBobbibobbie
I have myself solved the issue, in different ways, but no one answered here even provided bounty..Tenuto
S
2

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.

Salpingectomy answered 11/5, 2018 at 6:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.