首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >表单发布后,Asp.net重定向至银行短信验证(3DPay)页面

表单发布后,Asp.net重定向至银行短信验证(3DPay)页面
EN

Stack Overflow用户
提问于 2021-05-16 22:42:44
回答 1查看 22关注 0票数 0

我正在尝试创建信用卡支付页面。我正在张贴在代码背后(C#)的表格,并成功地从银行获得验证短信。但不会跳转到银行短信验证码页面,无法输入验证码。那么我该怎么做呢?

代码语言:javascript
复制
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)做,它工作得很好,但我想在服务器端做。

EN

回答 1

Stack Overflow用户

发布于 2021-05-16 22:58:38

我们需要从银行得到json信息。

代码语言:javascript
复制
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 {}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67557963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档