protected string BaseURL
{
get
{
string baseUrl = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "") +
Request.ApplicationPath;
if (!baseUrl.EndsWith("/"))
{
baseUrl = baseUrl + "/";
}
return baseUrl;
}
if (Session["ShoppingCart"] != null)
{
DataTable dt = (DataTable)Session["ShoppingCart"];
decimal orderTotal = Convert.ToDecimal(dt.Compute("Sum(SubTotal)", "SubTotal > 0"));
decimal shipping = Convert.ToDecimal(ConfigurationManager.AppSettings["shipingcharge"]);
string merchantId = ConfigurationManager.AppSettings["merchantId"];//The merchant ID we provide to you
string orderRef = DateTime.Now.Ticks.ToString();//Merchant‘s Order Reference Number
string currCode = "344";//The currency of the payment
string amount = (orderTotal + shipping).ToString();//The total amount your want to charge the customer (up to 2 decimal place)
string paymentType = "N";//The payment type:“N” – Normal Payment (Sales)“H” – Hold Payment (Authorize only)
string lang = "E";//The language of the payment page
string failUrl = BaseURL + "Fail.aspx";//A Web page address you want us to redirect upon the transaction being rejected by us (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string successUrl = BaseURL + "orderconfirmed.aspx"; //A Web page address you want us to redirect upon the transaction being accepted by us (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string errorUrl = BaseURL + "Error.aspx"; //A Web page address you want us to redirect when unexpected error occur (e.g. parameter incorrect) (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string secureHashSecret = "bZe67kcltBHsrmW9EvnnscrdMuNc1HPU";//offered by paydollar
string secureHash = null;
bool isSecureHash = false;
if (isSecureHash)
{//if secureHash is used
SHAPaydollarSecure sha1 = new SHAPaydollarSecure();
secureHash = sha1.generatePaymentSecureHash(merchantId, orderRef, currCode, amount, paymentType, secureHashSecret);
}
string Url = "https://test.paydollar.com/b2cDemo/eng/payment/payForm.jsp";
string formId = "myForm1";
StringBuilder htmlForm = new StringBuilder();
htmlForm.AppendLine("<html>");
htmlForm.AppendFormat("<body onload='document.forms[\"{0}\"].submit()'>", formId);
htmlForm.AppendFormat("<form id='{0}' method='POST' action='{1}'>", formId, Url);
htmlForm.AppendFormat("<input type='hidden' name='merchantId' value='{0}'/>", merchantId);
htmlForm.AppendFormat("<input type='hidden' name='amount' value='{0}' />", amount);
htmlForm.AppendFormat("<input type='hidden' name='orderRef' value='{0}' />", orderRef);
htmlForm.AppendFormat("<input type='hidden' name='currCode' value='{0}' />", currCode);
htmlForm.AppendFormat("<input type='hidden' name='successUrl' value='{0}' />", successUrl);
htmlForm.AppendFormat("<input type='hidden' name='failUrl' value='{0}' />", failUrl);
htmlForm.AppendFormat("<input type='hidden' name='errorUrl' value='{0}' />", errorUrl);
htmlForm.AppendFormat("<input type='hidden' name='payType' value='{0}' />", paymentType);
htmlForm.AppendFormat("<input type='hidden' name='lang' value='{0}' />", lang);
htmlForm.AppendFormat("<input type='hidden' name='secureHash' value='{0}' /> ", secureHash);
htmlForm.AppendLine("</form>");
htmlForm.AppendLine("</body>");
htmlForm.AppendLine("</html>");
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(htmlForm.ToString());
HttpContext.Current.Response.End();
}
/**/
//InsertDetail();
//Response.Redirect("orderconfirmed.aspx");
}
{
get
{
string baseUrl = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, "") +
Request.ApplicationPath;
if (!baseUrl.EndsWith("/"))
{
baseUrl = baseUrl + "/";
}
return baseUrl;
}
if (Session["ShoppingCart"] != null)
{
DataTable dt = (DataTable)Session["ShoppingCart"];
decimal orderTotal = Convert.ToDecimal(dt.Compute("Sum(SubTotal)", "SubTotal > 0"));
decimal shipping = Convert.ToDecimal(ConfigurationManager.AppSettings["shipingcharge"]);
string merchantId = ConfigurationManager.AppSettings["merchantId"];//The merchant ID we provide to you
string orderRef = DateTime.Now.Ticks.ToString();//Merchant‘s Order Reference Number
string currCode = "344";//The currency of the payment
string amount = (orderTotal + shipping).ToString();//The total amount your want to charge the customer (up to 2 decimal place)
string paymentType = "N";//The payment type:“N” – Normal Payment (Sales)“H” – Hold Payment (Authorize only)
string lang = "E";//The language of the payment page
string failUrl = BaseURL + "Fail.aspx";//A Web page address you want us to redirect upon the transaction being rejected by us (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string successUrl = BaseURL + "orderconfirmed.aspx"; //A Web page address you want us to redirect upon the transaction being accepted by us (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string errorUrl = BaseURL + "Error.aspx"; //A Web page address you want us to redirect when unexpected error occur (e.g. parameter incorrect) (For display purpose only. DO NOT use this URL to update your system. Please use DataFeed for this purpose.)
string secureHashSecret = "bZe67kcltBHsrmW9EvnnscrdMuNc1HPU";//offered by paydollar
string secureHash = null;
bool isSecureHash = false;
if (isSecureHash)
{//if secureHash is used
SHAPaydollarSecure sha1 = new SHAPaydollarSecure();
secureHash = sha1.generatePaymentSecureHash(merchantId, orderRef, currCode, amount, paymentType, secureHashSecret);
}
string Url = "https://test.paydollar.com/b2cDemo/eng/payment/payForm.jsp";
string formId = "myForm1";
StringBuilder htmlForm = new StringBuilder();
htmlForm.AppendLine("<html>");
htmlForm.AppendFormat("<body onload='document.forms[\"{0}\"].submit()'>", formId);
htmlForm.AppendFormat("<form id='{0}' method='POST' action='{1}'>", formId, Url);
htmlForm.AppendFormat("<input type='hidden' name='merchantId' value='{0}'/>", merchantId);
htmlForm.AppendFormat("<input type='hidden' name='amount' value='{0}' />", amount);
htmlForm.AppendFormat("<input type='hidden' name='orderRef' value='{0}' />", orderRef);
htmlForm.AppendFormat("<input type='hidden' name='currCode' value='{0}' />", currCode);
htmlForm.AppendFormat("<input type='hidden' name='successUrl' value='{0}' />", successUrl);
htmlForm.AppendFormat("<input type='hidden' name='failUrl' value='{0}' />", failUrl);
htmlForm.AppendFormat("<input type='hidden' name='errorUrl' value='{0}' />", errorUrl);
htmlForm.AppendFormat("<input type='hidden' name='payType' value='{0}' />", paymentType);
htmlForm.AppendFormat("<input type='hidden' name='lang' value='{0}' />", lang);
htmlForm.AppendFormat("<input type='hidden' name='secureHash' value='{0}' /> ", secureHash);
htmlForm.AppendLine("</form>");
htmlForm.AppendLine("</body>");
htmlForm.AppendLine("</html>");
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write(htmlForm.ToString());
HttpContext.Current.Response.End();
}
/**/
//InsertDetail();
//Response.Redirect("orderconfirmed.aspx");
}
No comments:
Post a Comment