Click here to Skip to main content
15,905,068 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This Is my Payment Response Page
C#
protected void Page_Load(object sender, EventArgs e)
{
try
{
    if (!IsPostBack)
    {
    NameValueCollection nvc = Request.Form;
    string mmp_Transaction = nvc["mmp_txn"].ToString();
    string PaymentStatus = nvc["f_code"].ToString();
    string MerchantTransactionId = Request.Form["mer_txn"];

    string Amount = Request.Form["amt"];
    string Product = Request.Form["prod"];
    string TransactionDate = Request.Form["date"];
    string BankTransactionId = Request.Form["bank_txn"];
    string ClientCode = Request.Form["clientcode"]; // Encrypted User Information
    string BankName = Request.Form["bank_name"];

    //User Details
    string Udf1 = Request.Form["udf1"]; //First Name
    string Udf2 = Request.Form["udf2"]; //Email
    string Udf3 = Request.Form["udf3"]; //Mobile
    string Udf4 = Request.Form["udf4"]; //Address
    string Udf5 = Request.Form["udf5"]; //Bank Name
    string Udf6 = Request.Form["udf6"]; //EMI Option

    string strResponceIP = HttpContext.Current.Request.UserHostAddress;
    string strRemarks = "txnId:" + MerchantTransactionId + ", txnStatus:" + PaymentStatus + ", amount:" + Amount + ", pgTxnId:" + mmp_Transaction + ", BankTransactionId:" + BankTransactionId + ", Udf1:" + Udf1 + ", Udf2:" + Udf2 + ", Udf3:" + Udf3 + ", Udf4:" + Udf4 + ", Udf5:" + Udf5 + ", Udf6:" + Udf6;


    string ATOMPaymentIP = ConfigurationManager.AppSettings["ATOMPaymentIP"].ToString();//203.114.240.183--Stage
    //Verify the Response Server
    if (Request.UrlReferrer.Host.Trim() != ATOMPaymentIP)
    {
        // REDIRECT TO ERROR PAGE IF RESPONSE IP IS NOT VERIFIED
    }

    // CHECK THE PAYMENT STATUS AND VALIDATE THE TRANSACTION ID
    if (PaymentStatus.ToUpper().Trim() == "OK" && transactionid.Trim()==MerchantTransactionId.Trim())
    {
        //"Transaction proceed successfully."

        // UPDATE THE TRANSACTION STATUS IN DB
        //
        // CODE FOR UPDATE STATUS
        //
        //

        // REDIRECT TO SUCCESS PAGE OR SHOW THE PAYMENT RESPONSE ON SAME PAGE

    }
    else
    {
        // PAYMENT STATUS IS NOT SUCCESS OR TRANSACTION ID IS NOT VERIFIED
        // REDIRECT TO ERROR PAGE
    }
    }
}
catch (Exception ex)
{
    // HANDLE ERROR
}
}
Posted
Comments
F-ES Sitecore 7-Aug-15 5:33am    
Ask the payment provider or consult their documentation.

1 solution

Never, ever, accept code from a insecure website to handle anything to do with real money.
You do not know who is giving you the code, you do not know what it does, you do not know that it places the monies correctly into the appropriate account, without passing the details to any third parties.

Only get such code from your payment gateway company - the scope for fraud otherwise is far too large. And remember, you personally could be liable for any monies lost if your action is seen to be negligent - which getting your code from a public forum would most certainly be!
 
Share this answer
 
Comments
Arasappan 7-Aug-15 7:07am    
Awesome..Griff

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900