加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 我是否需要一个新的PayPal API来支持.Net服务器上的T

发布时间:2020-12-16 09:42:39 所属栏目:asp.Net 来源:网络整理
导读:我正在运行ASP.Net 4.5,但使用的是非常旧版本的PayPal SOAP api.引用的是paypal_base.dll,报告版本为4.3.1.0.调用API的代码具有引用的“using”语句: com.paypal.sdk.services com.paypal.soap.api. 我已经验证了PayPal api的调用,即此值 System.Net.Servic
我正在运行ASP.Net 4.5,但使用的是非常旧版本的PayPal SOAP api.引用的是paypal_base.dll,报告版本为4.3.1.0.调用API的代码具有引用的“using”语句:

com.paypal.sdk.services

com.paypal.soap.api.

我已经验证了PayPal api的调用,即此值

System.Net.ServicePointManager.SecurityProtocol

包括ssl3和tls1.2.

我指着“沙盒”模式.

但是当调用setExpressCheckout时,我得到一个运行时异常,说:
请求已中止:无法创建SSL / TLS安全通道.

我已经下载了PayPal API Samples项目并使用相同的沙箱凭据,它可以正常工作.看着Fiddler,除了示例API调用到api-3t.sandbox.paypal.com之外,调用几乎相同,而我的代码转到api-aa.sandbox.paypal.com,但根据TLS 1.2准备就绪的文档,两个apis应该工作.除了在“live”和“sandbox”之间切换之外,我在任一API中都没有看到设置端点的任何地方.

在小提琴响应中,两者都表明:
“找到了与SSLv3兼容的ServerHello握手.Fiddler提取了以下参数.
版本:3.3(TLS / 1.2)“
并且响应是相同的,除了“随机”参数.所以旧的API调用使用的是TLS 1.2

我的代码和Samples API代码略有不同,示例使用:

SetExpressCheckoutRequestType request = new SetExpressCheckoutRequestType();
        populateRequestObject(request); //populate request data
        SetExpressCheckoutReq wrapper = new SetExpressCheckoutReq();
        wrapper.SetExpressCheckoutRequest = request;
        Dictionary<string,string> configurationMap = Configuration.GetAcctAndConfig(); //set merchant config
        PayPalAPIInterfaceServiceService service = new PayPalAPIInterfaceServiceService(configurationMap);
        SetExpressCheckoutResponseType setECResponse = service.SetExpressCheckout(wrapper); //make the call

我的(再次,非常古老的代码看起来像这样):

CallerServices caller = new CallerServices();
    caller.APIProfile = SetProfile.ApplicationProfile; //set merchant config
    SetExpressCheckoutRequestType pp_request = new SetExpressCheckoutRequestType();
    // Create the request details object
    pp_request.SetExpressCheckoutRequestDetails = new SetExpressCheckoutRequestDetailsType();
    pp_request.SetExpressCheckoutRequestDetails.PaymentAction = paymentAction;
    pp_request.SetExpressCheckoutRequestDetails.PaymentActionSpecified = true;

    pp_request.SetExpressCheckoutRequestDetails.OrderTotal = new BasicAmountType();

    pp_request.SetExpressCheckoutRequestDetails.OrderTotal.currencyID = currencyCodeType;
    pp_request.SetExpressCheckoutRequestDetails.OrderTotal.Value = paymentAmount;

    pp_request.SetExpressCheckoutRequestDetails.CancelURL = cancelURL;
    pp_request.SetExpressCheckoutRequestDetails.ReturnURL = returnURL;
    return (SetExpressCheckoutResponseType) caller.Call("SetExpressCheckout",pp_request); //do the call

示例代码有效,我的代码抛出SSL / TLS错误.我尝试升级到最新的SDK,但是已经发生了很多变化,迁移所有代码将付出相当大的努力.

从fiddler看来,即使使用旧的API,它似乎也在使用TLS 1.2,但是我得到了关于SSL / TLS连接的运行时异常.是因为端点不同吗?旧的API太旧了吗?

在此先感谢任何帮助 – 我希望避免迁移所有古老的代码!

编辑:我应该提到我使用的是UserName / Password / Signature凭证,而不是基于证书的凭据.

解决方法

由于.Net4.5支持TLS1.2,但它不是默认协议.你需要选择使用它.以下代码将使TLS 1.2成为默认值,请确保在连接到安全资源之前执行它:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读