Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 基础连接已关闭:发送时发生意外错误_C#_Paypal - Fatal编程技术网

C# 基础连接已关闭:发送时发生意外错误

C# 基础连接已关闭:发送时发生意外错误,c#,paypal,C#,Paypal,我试图在我的网站上使用直接付款方式 这就是我所指的样本: 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()

我试图在我的网站上使用直接付款方式

这就是我所指的样本:

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"];

        }
    }
}
这是链接:

当我传递适当的参数并尝试运行代码时,我收到以下错误:“基础连接已关闭:发送时发生意外错误。”第行:


SOAP服务调用位于dll内部。有人能告诉我发生了什么以及如何解决吗?

这是因为该示例似乎过时了,请在此处阅读更多内容:


    • 这是因为该样本似乎过时了,请在此处阅读更多内容:


      隐藏您的用户名和密码@亚历克斯:哪一个?这是来自网站的样本!不是我的用户名和密码。很抱歉,我以为它们是你的私人API密钥。隐藏你的用户名和密码@亚历克斯:哪一个?这是来自网站的样本!不是我的用户名和密码。很抱歉,我以为它们是你的私人API密钥。你提供的链接不包含任何名为“直接付款”的内容。他们停止支持了吗?@Jaggu如果你花时间查看网站,你会发现api文档,我已经用一个链接更新了我的答案,希望它有帮助,并且你明白你需要创建一个帐户才能测试api。谢谢Joakim。我还是找不到它。但是你的第三个链接帮了我。嗨,热糖果。你成功地解决了我的问题。不知道如何感谢你!!!谢谢!您提供的链接不包含任何名称为“直接付款”的内容。他们停止支持了吗?@Jaggu如果你花时间查看网站,你会发现api文档,我已经用一个链接更新了我的答案,希望它有帮助,并且你明白你需要创建一个帐户才能测试api。谢谢Joakim。我还是找不到它。但是你的第三个链接帮了我。嗨,热糖果。你成功地解决了我的问题。不知道如何感谢你!!!谢谢!
      pp_response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request);