[英]Asp.net redirect to bank sms verification (3DPay) page after form post
我正在嘗試創建信用卡支付頁面。 我在 (C#) 后面的代碼中發布表單並成功從銀行獲取驗證短信。 但它不會重定向到銀行短信驗證頁面,所以沒有地方輸入驗證碼。 所以我該怎么做?
Here is my code under the Pay button:
String shopCode = "SHOPCODE";
String purchaseAmount = "ORDER PRICE";
String currency = "CURRENCY";
String orderId = "ORDERID";
String okUrl = "REDIRECT PAGE AFTER SMS VERIFICATION COMPLETED SUCCESSFULLY";
String failUrl = "REDIRECT PAGE IF SMS VERIFICATION FAILS";
String rnd = DateTime.Now.ToString();
String installmentCount = "3";
String txnType = "txnType";
String merchantPass = "merchantpass";
String str = shopCode + orderId + purchaseAmount + okUrl + failUrl + txnType + installmentCount + rnd + merchantPass;
System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
byte[] bytes = System.Text.Encoding.GetEncoding("ISO-8859-9").GetBytes(str);
byte[] hashingbytes = sha.ComputeHash(bytes);
String hash = Convert.ToBase64String(hashingbytes);
String cardnumber = "CREDIT CARD NUMBER";
String expiry = "EXPIRY DATE";
String CVCCVV = "CVCNUMBER";
String securetype = "3DPay";
String lang = "language";
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "Pan=" + cardnumber;
postData += ("&Expiry=" + expiry);
postData += ("&Cvv2=" + CVCCVV);
postData += ("&ShopCode=" + shopCode);
postData += ("&PurchAmount=" + purchaseAmount);
postData += ("&Currency=" + currency);
postData += ("&OrderId=" + orderId);
postData += ("&OkUrl=" + okUrl);
postData += ("&FailUrl=" + failUrl);
postData += ("&Rnd=" + rnd);
postData += ("&Hash=" + hash);
postData += ("&TxnType=" + txnType);
postData += ("&InstallmentCount=" + installmentCount);
postData += ("&SecureType=" + securetype);
postData += ("&Lang=" + lang);
byte[] data = encoding.GetBytes(postData);
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("POSURL");
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
編輯:如果我在客戶端(html)端做它工作正常,但我想在服務器端做。
我們需要來自銀行的 json 信息
try
{
HttpClient clients = new HttpClient();
clients.Timeout = TimeSpan.FromSeconds(2);
HttpResponseMessage _response = await clients.GetAsync("banksmspage");
_response.EnsureSuccessStatusCode();
string responseBody = await _response.Content.ReadAsStringAsync();
dynamic json = JObject.Parse(responseBody);
string smscode = json.jsontitle.smscode;
if (smscode != null)
{
if (smscode == UsersmsEnterString)
{
Response.Redirect("BankpageURL");
}
else
{
Response.Redirect("ErrorURL");
}
}
}
catch {}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.