2016-05-19 28 views
0

我目前正在使用Braintree API尝试使用网关功能将用户数据库作为客户上传到他们的服务器。现在我可以通过我们的C#代码创建一个客户。Braintree Multiple Requests Error

但是,任何时候我尝试并调用请求第二次,当我们到达循环的下一个阶段,我就在这行未处理的网络异常:

Result<Customer> result = gateway.Customer.Create(request); 

类型的未处理的异常Braintree-2.59.0.dll中发生'System.Net.WebException' 其他信息:请求已中止:无法创建SSL/TLS安全通道。

我已经更改了代码,以便我们每次在我们的foreach循环内设置网关连接,但仍然出错。我们推测,我们可能需要拆除连接并重新初始化,但我找不到任何关于此的文档。

任何想法?

编辑:这里是一个测试用例,重现错误,你需要有一个沙箱帐户与你自己的MerchantId,PublicKey和PrivateKey来测试。我也已经测试过创建拥有相同公司名称并且工作正常的客户,Braintree仍然会为我创建一个具有唯一ID的新帐户,这不是问题。

using Braintree; 
using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Configuration; 

namespace BraintreeFailExample 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      string companyName = "Test Company"; 

      for (int i = 0; i < 3; i++) 
      { 
       // Initialization information (Replace with AppConfig settings) 
       var gateway = new BraintreeGateway 
       { 
        Environment = Braintree.Environment.SANDBOX, 
        MerchantId = "Insert Sandbox MerchantId here", 
        PublicKey = "Insert Sandbox PublicKey here", 
        PrivateKey = "Insert Sandbox PrivateKey here" 
       }; 

       // setup data for a customer request object 
       var request = new CustomerRequest 
       { 
        Company = companyName 
       }; 

       // send the request to the Braintree gateway 
       // Braintree doesn't care about duplicate company requests for new customer 
       Result<Customer> result = gateway.Customer.Create(request); 

      } 

     } 
    } 
} 
+1

您能提供一个独立的完整示例,重现您的环境中的成功和随后的失败吗? –

+0

错误情况在,并且应该可重复使用沙盒帐户,只需替换您自己的沙盒信息。 – tokyo0709

+0

我无法重现您遇到的问题。请与[Braintree支持](https://support.braintreepayments.com/)联系,寻求进一步解决问题的帮助。 – pblesi

回答

0

我能解决这个问题。事实证明,我们遇到了防火墙问题,阻止了我们在第一个问题后收到进一步的答复。