1

这发生在沙盒或生产中。在沙箱中,如果我输入带有代码和到期日期的 4111111111111111 签证...当我点击 payment.Creat(token) 行时,会引发异常,“流不可读”。如果我输入一些其他的 CC 号码,例如 4234567890123456,付款就可以了。在生产中,如果我使用那个 4234... 我得到流不可读错误。我了解测试卡并不总是有效,但我希望收到信用卡无效响应。我遇到的问题是我的一些客户遇到了流错误......所以有时它会正确发回,有时是 Stream 错误......我最近使用 Nuget 将包更新为最新和最好的 API,

这是我的相关代码 try { var token = GetAPIToken();

            var creditCard = new CreditCard();
            creditCard.number = req.CardNumber;
            creditCard.expire_month = req.ExpMonth;
            creditCard.expire_year = req.ExpYear;
            creditCard.first_name = req.FirstName;
            creditCard.last_name = req.LastName;
            creditCard.type = req.CardType;
            creditCard.payer_id = req.UserId.ToString();
            creditCard.cvv2 = req.SecurityCode;

            creditCard.billing_address = new Address()
            {
                line1 = req.Address1,
                city = req.City,
                state = req.State,
                postal_code = req.ZipCode,
                country_code = "US"
            };


            var payment = new Payment();
            payment.intent = "sale";

            payment.payer = new Payer();
            payment.transactions = new List<Transaction>();

            var t = new Transaction()
            {
                description = req.Description,
                amount = new Amount()
                {
                    total = req.TotalPayment.ToString("N2"),
                    currency = "USD",
                },
            };

            t.item_list = new ItemList();
            t.item_list.items = new List<Item>();
            t.item_list.items.Add(new Item()
                {
                    name = req.Description,
                    quantity = "1",
                    price = req.TotalPayment.ToString("N2"),
                    currency = "USD",
                });
            payment.transactions.Add(t);

            payment.payer.funding_instruments = new List<FundingInstrument>();
            payment.payer.payment_method = "credit_card";

            var fundingInstrument = new FundingInstrument();
            fundingInstrument.credit_card = creditCard;


                payment.payer.funding_instruments.Add(fundingInstrument);

            var pay = payment.Create(token);
            if (req.PaymentOption != PayOption.UsePayPal && pay.state == PayPalStateApproved
                    && pay.transactions.Any() && pay.transactions[0].related_resources.Any()
                    && pay.transactions[0].related_resources[0].sale != null
                    && !String.IsNullOrEmpty(pay.transactions[0].related_resources[0].sale.id))
            {
                resp.TransactionID = pay.transactions[0].related_resources[0].sale.id;
            }
            else
            {
                resp.Status = Status.Error;
                resp.Messages.Add(new Message { Code = "paypal", Text = pay.state });
            }
        }
        catch (Exception ex)
        {
            var err = CheckPayPalError(ex);
            resp.Messages.Add(new Message { Code = "paypal", Text = String.IsNullOrEmpty(err) ? ex.Message : err });

            resp.Status = Status.Error;
        }

        return resp;

这是日志条目,第一个是如果重试设置为> 0,第二个是不重试 2013-08-29 09:41:45,852 [33] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK /rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052;bit=64;os=Windows 7 6.1.7601.65536; 2013-08-29 09:41:45,852 [33] 调试 PayPal.PayPalResource [(null)] PayPal-Request-Id:a781e6bb-c0b0-4f06-abf8-1202dbc17a59 2013-08-29 09:41:45,920 [33]调试 PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456 ","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"2520071cde1ca"} 2013-08-29 09:41:49,506 [33] INFO PayPal.Manager.ConnectionManager [(null)] 从服务器 2013-08-29 09:41:49,507 获得 InternalServerError 状态代码[33] 错误 PayPal.Exception.PayPalException [(null)] HttpConnection Execute 中的异常:Stream 不可读。PayPal.Exception.PayPalException:HttpConnection Execute 中的异常:Stream 不可读。---> System.ArgumentException:Stream 是不可读。在 System.IO.StreamReader..ctor(Stream stream) 在 PayPal.HttpConnection.Execute(String payLoad) , HttpWebRequest httpRequest) --- 内部异常堆栈跟踪结束 ---

这是第二个 2013-08-29 09:44:27,685 [16] DEBUG PayPal.PayPalResource [(null)] User-Agent:PayPalSDK/rest-sdk-dotnet 0.7.3 ;lang=DOTNET;v=4.0.30319.18052 ;bit=64;os=Windows 7 6.1.7601.65536; 2013-08-29 09:44:27,686 [16] 调试 PayPal.PayPalResource [(null)] PayPal-Request-Id:1d5c68e5-4b4b-4876-8bf4-3b9f64d0afb6 2013-08-29 09:44:27,753 [16]调试 PayPal.Manager.ConnectionManager [(null)] {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card":{"number":"4234567890123456 ","type":"visa","expire_month":5,"expire_year":2015,"cvv2":"123","first_name":"MIckey","last_name":"Keenan","billing_address": {"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR ","debug_id":"465701e606a56"} 2013-08-29 09:44:28,848 [16] 信息 PayPal.Manager.ConnectionManager [ (空)]从服务器 2013-08-29 09:44:28,850 [16] 错误 PayPal.Exception.PayPalException [(null)] HttpConnection 执行中的异常 PayPal.Exception.PayPalException:HttpConnection 执行中的异常

4

3 回答 3

0

问题已在核心 SDK 中得到修复。修复在分支https://github.com/paypal/sdk-core-dotnet/tree/fix-log4net-stream中可用。请参阅https://github.com/paypal/rest-api-sdk-dotnet/issues/10了解更多详情。

于 2013-09-06T12:10:58.427 回答
0

我们有时会在沙盒中看到测试卡 4111xxx 存在问题,并且正在研究解决该问题的方法。因此,使用沙盒中的另一张测试卡进行测试。

注册流读取错误,将测试提供的代码并更新回来。

于 2013-08-20T04:01:55.293 回答
0

在与 PayPal 支持人员讨论过同样的问题后:显然即使在沙盒中,如果信用卡使用次数过多,它将被阻止。他们建议尝试其他假卡号,并推荐我到这个网站来生成它们:

http://www.fakenamegenerator.com/

使用那里生成的卡片一直对我有用。

于 2015-02-15T02:38:24.093 回答