0

I have a pop up payment gateway which I have a public push back url to know the success data from the bank.

mysite.com/push_back
// push back url gave to bank in order to send back data 
function push_back() {
    $content = file_get_contents("php://input");
    $obj = json_decode($content);
    $tran_id = $obj->tran_id;
    $status = $obj->status;
    //insert into db successfully
    //redirect code is not working. eg: header("Location: http://example.com/myOtherPage.php");
}

Note: I created a push back link and provide to bank which its running in background to send the data for me.

HTML FORM

<!— Modal content —>
<div class="modal-content">
    <form method="POST" target="webservice" action="payment-gateway-url" id="merchant_request">
        <input type="hidden" name="hash" value="asdfxc123sfd" id="hash"/>
        <input type="hidden" name="tran_id" value="123" id="tran_id"/>          
    </form>
</div>

<input type="button" value="confirm" id="button-confirm" class="btn btn-primary" /> 

<script type="text/javascript">
    $(document).on('click', '#button-confirm', function() {
        PaymentGateway.checkout();
    });
</script>

I have successfully got the push back data from the payment gateway. However, I cant write the execute redirect script it to another page. It seems like the code doesn't execute. I have tried to search google, but I haven't found the right solution.

jebas jay
  • 1
  • 2
  • 1
    Why can't you write that code? Is there any error message involved? – Nico Haase Mar 02 '18 at 14:53
  • @NicoHaase, the push back url is running in background which I don't know how to debug the code. – jebas jay Mar 02 '18 at 14:56
  • What do you mean saying "The push back url is running in background." – Gennadiy Litvinyuk Mar 02 '18 at 15:01
  • Somebody is obviously calling that URL - you should either inspect the calls happening to that ressource or add some file-based debugging. Either way, your webserver's error log could already contain some entries? – Nico Haase Mar 02 '18 at 15:03
  • 1
    If they simply call that URL without "follow redirects", then your redirect will be ignored. Why do you redirect that call in the first place? Why not just do all you need to do on that page? – M. Eriksson Mar 02 '18 at 15:04
  • @GennadiyLitvinyuk, it means that, I have created a url and provided to the bank, so the bank will push data success to me. – jebas jay Mar 02 '18 at 15:05
  • @MagnusEriksson, like I mentioned, the payment gateway is pop up. – jebas jay Mar 02 '18 at 15:09
  • There is nothing much you can do if the second page is not accessed. The redirect code is not something that happens on your server, but something that the client can respect. In your case, the payment gateway doesn't respect the redirect url. – Ibrahim Mar 02 '18 at 15:12
  • @lbrahim, why I can insert it to db? I have a solution is to check with ajax running, but I would like to try with php and I still wonder why the redirect code is not execute. – jebas jay Mar 02 '18 at 15:15
  • 2
    If it's in a popup, it isn't in "the background". Either way, you need to show us your actual code if you want us to be able to help. Also, make sure that you don't have any output (exho, var dump etc) before your header() – M. Eriksson Mar 02 '18 at 15:19
  • @MagnusEriksson, I have updated the question code – jebas jay Mar 02 '18 at 15:27
  • @Nico Hasse, the output from the bank can only write to a file and insert to db.. i have tried to debug it using wrire file and I can get data normally... – jebas jay Mar 03 '18 at 00:42

1 Answers1

0

Finally, I found the answer from the bank that they will provide a redirect link option for me.

jebas jay
  • 1
  • 2