Braintree 多次请求错误
Braintree Multiple Requests Error
我目前正在与 Braintree API 合作,尝试使用他们的网关功能将用户作为客户的数据库上传到他们的服务器。现在我可以通过我们的 C# 代码创建一个客户。
但是每当我尝试在进入循环的下一阶段时第二次调用请求时,我都会在这一行收到未处理的 Web 异常:
Result<Customer> result = gateway.Customer.Create(request);
An unhandled exception of type 'System.Net.WebException' occurred in Braintree-2.59.0.dll
Additional information: The request was aborted: Could not create SSL/TLS secure channel.
我已经更改了代码,以便我们每次都在我们的 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);
}
}
}
}
我能够解决这个问题。事实证明,我们遇到了防火墙问题,导致我们无法在收到第一个响应后收到进一步的响应。
我目前正在与 Braintree API 合作,尝试使用他们的网关功能将用户作为客户的数据库上传到他们的服务器。现在我可以通过我们的 C# 代码创建一个客户。
但是每当我尝试在进入循环的下一阶段时第二次调用请求时,我都会在这一行收到未处理的 Web 异常:
Result<Customer> result = gateway.Customer.Create(request);
An unhandled exception of type 'System.Net.WebException' occurred in Braintree-2.59.0.dll Additional information: The request was aborted: Could not create SSL/TLS secure channel.
我已经更改了代码,以便我们每次都在我们的 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);
}
}
}
}
我能够解决这个问题。事实证明,我们遇到了防火墙问题,导致我们无法在收到第一个响应后收到进一步的响应。