1

Ok so i am trying to do a redirect with PHP with a PaymentID ...i am not sure how to do this ...here are the instructions and even some example asp.net code to help

Redirect to the Mercury HostedCheckout Page Mercury HostedCheckout URL: Test URL: https://hc.mercurydev.net/Checkout.aspx

Hidden Fields in HTML Form Post to HostedCheckout

Field Name   Description                                                          Required
PaymentID    The unique identifier returned by the InitiatePayment web service.   Yes

And here is the sample code in C# for asp.net

Redirect sample code This is sample code that will redirect the browser to Mercury’s HostedCheckout page. It is server side C# code used in an asp.net click event that creates an html response that will redirect to Mercury.

//Set the necessary variables before building html.
string hostedCheckoutURL = ConfigurationManager.AppSettings["HostedCheckoutURL"]; 
string paymentID = this.txtPaymentID.Text;
//Build an html form post to be sent back to the browser. 
//It will redirect the browser to the Mercury HostedCheckout page. 
Response.Clear(); 
Response.Write("<html><head>"); 
Response.Write("</head><body onload=\"document.frmCheckout.submit()\">"); 
Response.Write("<form name=\"frmCheckout\" method=\"Post\" action=\"" + hostedCheckoutURL + "\" >"); 
Response.Write("<input name=\"PaymentID\" type=\"hidden\" value=\"" + paymentID + "\">"); 
Response.Write("</form>"); 
Response.Write("</body></html>"); 
Response.End();

Basically I need to do the same request in PHP...any ideas

1 Answer 1

3

You have to include("config.php"); or such to get $hostedCheckoutURL, but I don't know from where do you get PaymentID.

<?php
//Set the necessary variables before building html.
$hostedCheckoutURL = "https://hc.mercurydev.net/Checkout.aspx"; 
$paymentID = "123456789";
//Build an html form post to be sent back to the browser. 
//It will redirect the browser to the Mercury HostedCheckout page. 
echo("<html><head>"); 
echo("</head><body onload=\"document.frmCheckout.submit()\">"); 
echo("<form name=\"frmCheckout\" method=\"Post\" action=\"".$hostedCheckoutURL."\" >"); 
echo("<input name=\"PaymentID\" type=\"hidden\" value=\"".$paymentID."\">"); 
echo("</form>"); 
echo("</body></html>");
?>
Sign up to request clarification or add additional context in comments.

4 Comments

I have the paymentID....does this request create a form or does it redirect...I thought i had to redirect...thanks again
nevermind this worked perfectly...thanks but what is this doing....is it writing the form or redirecting and if its redirecting how
this.txtPaymentID.Text I don't know what is this and how you set it, it is being redirected to URL you set in $hostedCheckoutURL, I'll edit the answer to make it more clearer.
I see now...I am writing the form via php and then with the onload automatically submiting to the url set in the config with the paymentID post data

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.