【问题标题】:The underlying connection was closed: An unexpected error occurred on a send底层连接已关闭:发送时发生意外错误
【发布时间】:2011-09-23 10:02:15
【问题描述】:

我正在尝试在我的网站中使用 DoDirectPayment 方法。

这是我指的示例:

using com.paypal.sdk.services;
using com.paypal.sdk.profiles;
using com.paypal.sdk.util;
using com.paypal.soap.api;

namespace ASPDotNetSamples
{
    public class DoDirectPayment
    {
        public DoDirectPayment()
        {
        }
        public string DoDirectPaymentCode(string paymentAction, string amount, string creditCardType, string creditCardNumber, string expdate_month, string cvv2Number, string firstName, string lastName, string address1, string city, string state, string zip, string countryCode, string currencyCode)
        {

            com.paypal.soap.api.DoDirectPaymentReq req = new com.paypal.soap.api.DoDirectPaymentReq();


            NVPCallerServices caller = new NVPCallerServices();
            IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();

            // Set up your API credentials, PayPal end point, API operation and version.
            profile.APIUsername = "sdk-three_api1.sdk.com";
            profile.APIPassword = "xxxxxxxxxxxxx";
            profile.APISignature = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
            profile.Environment = "sandbox";
            caller.APIProfile = profile;

            NVPCodec encoder = new NVPCodec();
            encoder["VERSION"] = "51.0";
            encoder["METHOD"] = "DoDirectPayment";

            // Add request-specific fields to the request.
            encoder["PAYMENTACTION"] = paymentAction;
            encoder["AMT"] = amount;
            encoder["CREDITCARDTYPE"] = creditCardType;
            encoder["ACCT"] = creditCardNumber;
            encoder["EXPDATE"] = expdate_month;
            encoder["CVV2"] = cvv2Number;
            encoder["FIRSTNAME"] = firstName;
            encoder["LASTNAME"] = lastName;
            encoder["STREET"] = address1;
            encoder["CITY"] = city;
            encoder["STATE"] = state;
            encoder["ZIP"] = zip;
            encoder["COUNTRYCODE"] = countryCode;
            encoder["CURRENCYCODE"] = currencyCode;

            // Execute the API operation and obtain the response.
            string pStrrequestforNvp = encoder.Encode();
            string pStresponsenvp = caller.Call(pStrrequestforNvp);

            NVPCodec decoder = new NVPCodec();
            decoder.Decode(pStresponsenvp);
            return decoder["ACK"];

        }
    }
}

这是链接:

https://cms.paypal.com/cms_content/US/en_US/files/developer/nvp_DoDirectPayment_cs.txt

当我传递适当的参数并尝试运行代码时,我收到此错误:“底层连接已关闭:发送时发生意外错误。”上线:

pp_response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request);

SOAP 服务调用在 dll 中。谁能指导我发生了什么以及如何解决它?

【问题讨论】:

  • 隐藏您的用户名和密码!
  • @Alex:哪一个?这是来自网站的样本!不是我的用户名和密码。
  • 抱歉,我以为它们是你的 API 私钥。

标签: c# paypal


【解决方案1】:

【讨论】:

  • 您提供的链接不包含任何名称为“直接付款”的内容。他们停止支持了吗?
  • @Jaggu 如果您花时间查看您会找到 api 文档的网站,我已经用另一个链接更新了我的答案,希望它有所帮助,并且您了解您需要制作一个能够测试 api 的帐户。
  • 感谢乔金。我仍然无法找到它。但是您的第三个链接帮助了我。
  • 嗨,热糖。你已经成功解决了我的问题。不知道怎么感谢!!!非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-02
  • 2015-11-22
  • 2015-07-05
  • 1970-01-01
相关资源
最近更新 更多