【问题标题】:Express PayPal checkout, Could not create SSL/TLS secure channelExpress PayPal 结帐,无法创建 SSL/TLS 安全通道
【发布时间】:2013-04-28 01:55:47
【问题描述】:

我正在尝试在 ASP.NET C# 代码中使用 SOAP 2.0 API 设置 paypal express checkout。首先,我尝试使用沙盒,创建卖方/买方测试帐户,导入 Web 服务,然后尝试获取令牌,在我的 C# 代码中:

        // Create the request object
        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;

        SetExpressCheckoutResponseType response = (SetExpressCheckoutResponseType) caller.Call("SetExpressCheckout", pp_request);

但在该代码的最后一行会引发错误:

请求被中止:无法创建 SSL/TLS 安全通道。

我做错了吗? 谢谢。

【问题讨论】:

标签: c# asp.net paypal paypal-sandbox


【解决方案1】:

您的代码看起来确实是正确的,但 PayPal API 在涉及到一些事情时可能会很挑剔。需要注意的一件事是,当付款金额未四舍五入到小数点后 2 位时,它会产生异常 - 您可以尝试确保是这种情况吗?

还要确保您的配置值是正确的。除此之外,您发布的代码正是我用于 SOAP API 的代码。

不久前我停止使用 SOAP API,转而使用 NVP API,在我看来这更容易处理:https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_NVPAPIOverview

我提供了一个库来为您完成所有工作:https://github.com/davidduffett/Moolah

此处的说明准确显示了如何使用 PayPal Express Checkout:https://github.com/davidduffett/Moolah#paypal-express-checkout

【讨论】:

  • 嗨大卫,我试过你的图书馆,它给了我一个例外“请求被中止:无法创建 SSL/TLS 安全通道。”你能指导我解决这个问题吗?
  • 老兄,图书馆的工作真是太棒了!但请注意 Sarim 的评论。确实需要进行一些小的修改。 @SarimShekhani:看这里! stackoverflow.com/a/34950820/1057052
  • 等等!搞定了!太感谢了。还记得我之前评论的链接吗?好吧,我们只需要添加 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;在使用“SetExpressCheckout”之前。就我而言,为了安全起见,我在 var gateway = new PayPalExpressCheckout(configuration)
猜你喜欢
  • 2021-12-13
  • 2014-12-26
  • 2017-02-10
  • 2017-08-22
  • 2016-08-03
  • 2018-06-17
  • 1970-01-01
  • 2023-04-08
  • 1970-01-01
相关资源
最近更新 更多