2016-10-10 7 views
0

Pin Payments支払いゲートウェイを使用して自分のWebサイトに支払いを追加しようとしています。私のサイトはMVCで開発されており、私はAPIドキュメントで提案されているPinPayments C#ライブラリを使用しています。Pin Payments API - 「リモート側が転送ストリームを閉じたために認証に失敗しました」

私は、記載されているAPIのドキュメントはセキュアな接続のみを受け入れることを読んでいます。だから私は自分のソリューションでSSLを有効にしました。次に、IIS Expressが生成する自己署名証明書が自分の信頼できる証明書に追加されていることを確認しました。私は証明書を信頼した後に一度働いた。しかしそれ以来、それは失敗を続けました。そして、次のエラーメッセージが交互に表示されます。コードなしで、私はコードを変更しません。

既存の接続を強制的にリモートパーティがトランスポートストリームを閉じたので

認証が失敗したリモートホストによって閉じられました。

ここに私のコードがあります。カードとチャージはエラーなく構築され、ChargeResponse response = ps.Charge(charge);という行を実行します。その後、ピンペイメントライブラリのリクエスタコード(以下)にジャンプします。

[HttpPost] 
[ValidateAntiForgeryToken] 
public ActionResult CreditCard (CreditCardPayment model) 
{ 
    if (ModelState.IsValid) 
    { 
     // get application 
     Application application = db.Applications.Find(model.ApplicationdId); 

     if (application != null) 
     { 
      PinService ps = new PinService(ConfigurationManager.AppSettings["Secret_API"]); 

      var card = new Card(); 
      card.CardNumber = model.Number; 
      card.CVC = model.Cvn; 
      card.ExpiryMonth = model.ExpiryMonth; 
      card.ExpiryYear = model.ExpiryYear; 
      card.Name = model.Name; 
      card.Address1 = model.AddressLine1; 
      card.City = model.City; 
      card.Country = model.Country; 

      var charge = new PostCharge(); 
      charge.Description = "Visa Application " + application.Destination; 
      charge.Amount = Convert.ToInt64(application.Total) * 100; // Pin payments requires the value in cents 
      charge.Card = card; 
      charge.Currency = application.CurrencyCode; 
      charge.Email = application.Customer.Email; 
      charge.IPAddress = "127:0:0:1"; //Request.UserHostAddress; 

      ChargeResponse response = ps.Charge(charge); 

      if (response.Charge != null && response.Charge.Success) 
      { 
       // Update application with payment details. 
      } 
      else 
      { 
       // Do error stuff 
      } 
     } 
    } 

    return View(model); 
} 

これは、要求が失敗したPin Paymentsライブラリにあるコードです。最初の行を実行しますが、次にvarにジャンプします。requestStream = request.GetRequestStream();エラーメッセージが表示されます。

private static WebRequest GetWebRequest(string url, string method, string postData) 
{ 
    var request = HttpWebRequest.Create(url) as HttpWebRequest; 
    request.Method = method; 
    request.ContentType = "application/x-www-form-urlencoded"; 
    request.UserAgent = "C# API Wrapper v001"; 

    string apiKey = PinPaymentsConfig.GetApiKey(); 
    request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(apiKey + ":")); 

    if (postData != "") 
    { 
     var paramBytes = Encoding.UTF8.GetBytes(postData); 
     request.ContentLength = paramBytes.Length; 

     var requestStream = request.GetRequestStream(); 
     requestStream.Write(paramBytes, 0, paramBytes.Length); 
    } 
    return request; 
} 

答えて

1

ピン支払いは、あなたがTLS 1.1を介して、または上に接続している確認することができ、そのテストAPIにTLS 1.0のサポートを落とした、とJan 2017年に彼らのライブAPIにドロップされるのですか?

TLS 1.1および1.2のサポートは、.NET 4.5でのみ追加されています。

さらなるサポートについては、[email protected]​​n.net.auまでお気軽にお問い合わせください。

+0

ピンピン支払いありがとうございます。これが問題でした。ライブラリを.net 4.5として再構築し、GetWebRequestメソッドにTLS 1.2を使用させなければならなかった – Andrew

関連する問題