paypal - PayPalRest API无法读取流

标签 paypal

这发生在沙盒或生产中。在沙箱中,如果我输入带代码的Visa签证4111111111111111,并输入到期日...当我点击payment.Creat(token)行时,引发异常,“流不可读”。如果我输入了其他CC号码,例如4234567890123456,付款就可以了。在生产中,如果我使用4234 ...,我会得到流不可读的错误。我了解测试卡并非总能正常工作,但我希望您能收到信用卡无效的回复。我的问题是我的一些客户遇到了流错误。...如果我在生产中放入了真正的抄送,则可以正常工作..但是如果我更改1个数字,则会得到无效的卡错误。因此,有时它会正确地将其发送回,而有时是Stream错误...我最近使用Nuget将程序包更新为最新,最出色的API,但是其他人有何建议?

这是我的相关代码
                尝试
            {
                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;


这是日志条目,第一个是如果Retry设置为> 0,第二个是不重试
2013-08-29 09:41:45,852 [33]调试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)] {“意图”:“销售”,“付款人”:{“ payment_method”:“信用卡”,“ funding_instruments”: [{{credit_card“:{” number“:” 4234567890123456“,” type“:” visa“,” expire_month“:5,” expire_year“:2015,” cvv2“:” 123“,” first_name“:” MIckey“ ,“ last_name”:“ Keenan”,“ billing_address”:{“ line1”:“ 123 Main St”,“ city”:“ Denver”,“ country_code”:“ US”,“ postal_code”:“ 80210”,“ state “:” CO“},” payer_id“:” 205“}}]},”交易“:[{”金额“:{”货币“:” USD“,”总计“:” 4.75“},”描述“ :“ WFS午餐订单”,“ item_list”:{“商品”:[{“数量”:“ 1”,“名称”:“ WFS午餐订单”,“价格”:“ 4.75”,“货币”:“美元“}]}}]}
2013-08-29 09:41:49,505 [33]错误PayPal.Manager.ConnectionManager [(null)]错误响应:{“名称”:“ INTERNAL_SERVICE_ERROR”,“消息”:“发生内部服务错误”,“ information_link“:” https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR“,” debug_id“:” 2520071cde1ca“}
2013-08-29 09:41:49,506 [33]信息PayPal.Manager.ConnectionManager [[null)]从服务器获取了InternalServerError状态代码
2013-08-29 09:41:49,507 [33]错误PayPal.Exception.PayPalException [[null)] HttpConnection执行中的异常:无法读取流。
PayPal.Exception.PayPalException:HttpConnection中的异常执行:流不可读。 ---> System.ArgumentException:流不可读。
   在System.IO.StreamReader..ctor处(流流,编码编码,布尔型detectEncodingFromByteOrderMarks,Int32 bufferSize,布尔型leaveOpen)
   在System.IO.StreamReader..ctor(Stream stream)
   在PayPal.HttpConnection.Execute(字符串payLoad,HttpWebRequest httpRequest)
   ---内部异常堆栈跟踪的结尾---

这是第二个
   2013-08-29 09:44:27,685 [16]调试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)] {“意图”:“销售”,“付款人”:{“付款方式”:“信用卡”,“资金工具”: [{{credit_card“:{” number“:” 4234567890123456“,” type“:” visa“,” expire_month“:5,” expire_year“:2015,” cvv2“:” 123“,” first_name“:” MIckey“ ,“ last_name”:“ Keenan”,“ billing_address”:{“ line1”:“ 123 Main St”,“ city”:“ Denver”,“ country_code”:“ US”,“ postal_code”:“ 80210”,“ state “:” CO“},” payer_id“:” 205“}}]},”交易“:[{”金额“:{”货币“:” USD“,”总计“:” 4.75“},”描述“ :“ WFS午餐订单”,“ item_list”:{“商品”:[{“数量”:“ 1”,“名称”:“ WFS午餐订单”,“价格”:“ 4.75”,“货币”:“美元“}]}}]}
2013-08-29 09:44:28,847 [16]错误PayPal.Manager.ConnectionManager [(null)]错误响应:{“名称”:“ INTERNAL_SERVICE_ERROR”,“消息”:“发生内部服务错误”,“ information_link“:” 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 [[null)]从服务器获取了InternalServerError状态代码
2013-08-29 09:44:28,850 [16]错误HttpConnection执行中的PayPal.Exception.PayPalException [(null)]异常
PayPal.Exception.PayPalException:HttpConnection执行中的异常

最佳答案

有时我们会在沙箱中看到测试卡4111xxx的问题,并正在调查修复问题。因此,请使用沙盒中的其他测试卡进行测试。

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

关于paypal - PayPalRest API无法读取流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18320132/

相关文章:

php - 网站使用什么支付系统?

.NET API : Stream was not readable 的 PayPal 异常

paypal - 将我的 PayPal 应用程序从沙盒转移到上线

php - PayPal REST API [Sandbox] - INTERNAL_SERVICE_ERROR 付款销售执行

php - Paypal 订阅 "custom"变量问题(沙盒)

python - Paypal 交易 : How to receive and send funds with PayPal API and Django?

wordpress - 使用 woocommerce 在 Wordpress 中进行基于订阅的访问

paypal - 授权收取 1.00 美元费用而不收取

laravel - 自定义计费周期的 Paypal 定期付款

php - 获取 CreateRecurringPaymentsProfile 的 "Invalid Token"错误