public ActionResult InitiatePayment([Bind(Include = "vpc_Amount, vpc_MerchTxnRef, vpc_OrderInfo, vpc_ReturnURL")] string vpc_Amount, string vpc_MerchTxnRef, string vpc_OrderInfo, string vpc_ReturnURL) { try { //region parameters var VPC_URL = "https://migs.mastercard.com.au/vpcpay"; var paymentRequest = new PaymentRequest { Amount = vpc_Amount, MerchTxnRef = vpc_MerchTxnRef, OrderInfo = vpc_OrderInfo, ReturnUrl = vpc_ReturnURL }; var transactionData = paymentRequest.GetParameters().OrderBy(t => t.Key, new VPCStringComparer()).ToList(); var redirectUrl = VPC_URL + "?" + string.Join("&", transactionData.Select(item => HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value))); transactionData = transactionData.Where(x => x.Key != "vpc_SecureHashType").ToList(); string shaKey = ConfigurationManager.AppSettings["MigsSecureHashSecret"]; string shaData = string.Join("&", transactionData.Select(item => item.Key + "=" + item.Value)); redirectUrl += "&vpc_SecureHash=" + HttpUtility.UrlEncode(PaymentHelperMethods.CreateSHA256Signature(shaKey, shaData)); return(Redirect(redirectUrl)); } catch (Exception ex) { var message = "Exception encountered. " + ex.Message; return(View("Error", ex)); } }
public ActionResult InitiatePayment([Bind(Include = "vpc_Amount, vpc_MerchTxnRef, vpc_OrderInfo, vpc_ReturnURL")] string vpc_Amount, string vpc_MerchTxnRef, string vpc_OrderInfo, string vpc_ReturnURL) { try { //region parameters var VPC_URL = "https://migs.mastercard.com.au/vpcpay"; var paymentRequest = new PaymentRequest { Amount = vpc_Amount, MerchTxnRef = vpc_MerchTxnRef, OrderInfo = vpc_OrderInfo, ReturnUrl = vpc_ReturnURL }; string hashSecret = ConfigurationManager.AppSettings["MigsSecureHashSecret"]; //endregion //region redirect to payment gateway var transactionData = paymentRequest.GetParameters().OrderBy(t => t.Key, new VPCStringComparer()).ToList(); // Add custom data, transactionData.Add(new KeyValuePair<string, string>("Title", title)); var redirectUrl = VPC_URL + "?" + string.Join("&", transactionData.Select(item => HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value))); if (!string.IsNullOrEmpty(hashSecret)) { redirectUrl += "&vpc_SecureHash=" + PaymentHelperMethods.CreateMD5Signature(hashSecret + string.Join("", transactionData.Select(item => item.Value))); } return(Redirect(redirectUrl)); //endregion } catch (Exception ex) { var message = "Exception encountered. " + ex.Message; return(View("Error", ex)); } }
public ActionResult InitiatePayment() { try { #region parameters var VPC_URL = "https://migs.mastercard.com.au/vpcpay"; string returnURL = ""; string url = System.Web.HttpContext.Current.Request.Url.Scheme + "://" + System.Web.HttpContext.Current.Request.Url.Authority + returnURL; var paymentRequest = new PaymentRequest { Amount = "100", ReturnUrl = "http://localhost/demo2/payment/paymentconfirm", OrderInfo = "Visa Assessment", }; // SECURE_SECRET can be found in Merchant Administration/Setup page string hashSecrest = "FE7555C9D2C35C2552934E8DB1D73D43"; #endregion #region redirect to payment gateway var transactionData = paymentRequest.GetParameters().OrderBy(t => t.Key, new VPCStringComparer()).ToList(); // Add custom data, transactionData.Add(new KeyValuePair<string, string>("Title", title)); var redirectUrl = VPC_URL + "?" + string.Join("&", transactionData.Select(item => HttpUtility.UrlEncode(item.Key) + "=" + HttpUtility.UrlEncode(item.Value))); if (!string.IsNullOrEmpty(hashSecrest)) { redirectUrl += "&vpc_SecureHash=" + PaymentHelperMethods.CreateMD5Signature(hashSecrest + string.Join("", transactionData.Select(item => item.Value))); } return(Redirect(redirectUrl)); #endregion } catch (Exception ex) { var message = "(51) Exception encountered. " + ex.Message; return(View("PaymentError", ex)); } }