SagePay - 接收时发生意外错误

时间:2016-03-25 12:14:04

标签: c# transactions httpwebrequest integration sagepay

按照The SagePay Documentation

上的说明操作

我收到以下错误:

  

基础连接已关闭:接收

发生意外错误
  1. 创建包含所有必需值的POST的URL(VPSProtocol,TxType,Vendor,Crypt)

  2. 使用表单集成加密密码作为密钥和IV加密Crypt字段(包含所有必需的值)(RijndaelManaged)

  3. 实例化HttpWebRequest(KeepAlive = false; Method =“POST”(也尝试过GET))

  4. SecurityProtocol = Tls12(也尝试过Ssl3和Tls)

  5. 最初我的主叫网站不是Https(没有SSL证书)

  6. 尝试创建自签名证书

  7. 加密过程使用MemoryStream / CryptoStream / StreamWriter加密要在Crypt参数中传递的数据

  8. url复制Apendix A Crypt Field Example

  9. Sagepay Url - https://test.sagepay.com/gateway/service/vspform-register.vsp我将这些参数附加到。

  10. 响应

      

    基础连接已关闭:接收时发生意外错误。

    string valsToCrypt = "VendorTxCode= ....etc
    
    using (RijndaelManaged myRijndael = new RijndaelManaged())
    {
        var passToBytes = System.Text.Encoding.UTF8.GetBytes("pass val");
        myRijndael.Key = passToBytes;
        myRijndael.IV = passToBytes;
    
        // Encrypt the string to an array of bytes. 
        byte[] encrypted = EncryptStringToBytes(valsToCrypt, myRijndael.Key, myRijndael.IV);
    
        string cryptEncrypted = "";
    
        foreach (byte item in encrypted)
        {
            cryptEncrypted += item;
        }
    
        string uri = "https://test.sagepay.com/gateway/service/vspform-register.vsp";
        uri += "?VPSProtocol=3.00&TxType=PAYMENT&Vendor=vendorname&Crypt=@" + cryptEncrypted;
        var webRequest = (HttpWebRequest)WebRequest.Create(uri);
        webRequest.KeepAlive = false;
        webRequest.Method = "POST";
    

    几乎没有想法。

0 个答案:

没有答案