-1

I am trying to change the call back URL from one URL to another. Current callback URL is

header("Location: ".$gatewayParams['systemurl']."/viewinvoice.php?id=" . $merchant_order_id);

I wanted to change the URL to https://example.com/cart.php?a=complete When I tried replacing /viewinvoice.php?id= with /cart.php?a=complete I am getting redirected to https://example.com/cart.php, and the ?a=complete gets stripped.

Can someone tell me the way to reach https://example.com/cart.php?a=complete

Please Note: 1. I am not a PHP developer, so if you are suggesting something, kindly provide a full code snippet. 2. My goal is to redirect the user to the 'https://example.com/cart.php?a=complete'. It is Okay to make it hardcoded if it needs programmatic logic. 3. Please find the actual use case here

I found that if I can get this callback URL fixed, then it will solve my problem

11
  • just store it into a $_GET['variable'] variable before calling the header function and access it on viewinvoice.php Commented Sep 26, 2018 at 8:29
  • Note that some browsers like to hide those parameters from the url until you click the address bar. Maybe that is what's happening? Commented Sep 26, 2018 at 8:31
  • Possible duplicate of php redirect with HTTP query string variables Commented Sep 26, 2018 at 8:35
  • No @DirkScholten it is just an issue with the call back URL based on some criteria. I will edit the question to provide much more insight. Commented Sep 26, 2018 at 8:36
  • 1
    Do you really try to redirect to example.com or are you using your own domain? It's possible that the redirect works from PHP, but the query is "stripped" by the website settings. Commented Sep 26, 2018 at 8:43

2 Answers 2

0

You should try the following

$callback_url = $gatewayParams['systemurl']."/viewinvoice.php?id=" . $merchant_order_id;
$callback_url = str_replace('/viewinvoice.php?id=', '/cart.php?a=complete', $callback_url);
header("Location: ".$callback_url);
Sign up to request clarification or add additional context in comments.

1 Comment

Hi @AliRazaGhori, the same thing happening here. ?a=complete is not added to the URL
0

Not sure what exactly are you trying to do. Anyhow, if I were to redirect via header function to a URL with some extra params. I'd put it into a GET variable. So, if an http request comes to example.php

// example.php
<?php
$merchant_id = 123;
$_GET['merchant_id'] = $merchant_id;
header('Location: invoice.php');

And, in invoice.php

// invoice.php
if( isset($_GET['merchant_id']) ) {
  $merchant_id = $_GET['merchant_id'];
  unset($_GET['merchant_id']);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.