这发生在Sandbox或生产中。在沙箱中,如果我输入带有代码的Visa 4111111111111111和exp日期......当我点击payment.Creat(令牌)行时,会抛出异常,“Stream无法读取”。如果我输入其他一些CC号码,如4234567890123456,付款工作正常。在生产中,如果我使用4234 ...我得到的流不可读错误。我知道测试卡并不总是有效,但我希望能回复一张信用卡无效的回复。我遇到的问题是我的一些客户正在收到流错误....如果我在生产中放入一个真正的CC,它工作正常..但如果我更改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;
以下是日志条目,第一个是重试是否设置为&gt; 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] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:a781e6bb-c0b0-4f06-abf8-1202dbc17a59 2013-08-29 09:41:45,920 [33] DEBUG PayPal.Manager.ConnectionManager [(null)] {“intent”:“sale”,“payer”:{“payment_method”:“credit_card”,“funding_instruments”: [{ “CREDIT_CARD”:{ “号”: “4234567890123456”, “类型”: “签证”, “expire_month”:5 “EXPIRE_YEAR”:2015, “CVV2”: “123”, “如first_name”: “米奇” ,“last_name”:“Keenan”,“billing_address”:{“line1”:“123 Main St”,“city”:“Denver”,“country_code”:“US”,“postal_code”:“80210”,“州” “:” CO “},” payer_id “:” 205 “}}]},” 交易 “:[{” 量 “:{” 货币 “:” USD”, “总”: “4.75”}, “说明” :“WFS午餐订单”,“item_list”:{“items”:[{“quantity”:“1”,“name”:“WFS午餐订单”,“价格”:“4.75”,“货币”:“USD “}]}}]} 2013-08-29 09:41:49,505 [33]错误PayPal.Manager.ConnectionManager [(null)]错误响应:{“name”:“INTERNAL_SERVICE_ERROR”,“message”:“发生内部服务错误”,“ information_link “:”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)]从服务器获取InternalServerError状态码 2013-08-29 09:41:49,507 [33]错误PayPal.Exception.PayPalException [(null)] HttpConnection中的异常执行:Stream无法读取。 PayPal.Exception.PayPalException:HttpConnection中的异常执行:Stream无法读取。 ---&GT; System.ArgumentException:Stream无法读取。 在System.IO.StreamReader..ctor(Stream stream,Encoding encoding,Boolean detectEncodingFromByteOrderMarks,Int32 bufferSize,Boolean leaveOpen) 在System.IO.StreamReader..ctor(流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] DEBUG PayPal.PayPalResource [(null)] PayPal-Request-Id:1d5c68e5-4b4b-4876-8bf4-3b9f64d0afb6 2013-08-29 09:44:27,753 [16] DEBUG PayPal.Manager.ConnectionManager [(null)] {“intent”:“sale”,“payer”:{“payment_method”:“credit_card”,“funding_instruments”: [{ “CREDIT_CARD”:{ “号”: “4234567890123456”, “类型”: “签证”, “expire_month”:5 “EXPIRE_YEAR”:2015, “CVV2”: “123”, “如first_name”: “米奇” ,“last_name”:“Keenan”,“billing_address”:{“line1”:“123 Main St”,“city”:“Denver”,“country_code”:“US”,“postal_code”:“80210”,“州” “:” CO “},” payer_id “:” 205 “}}]},” 交易 “:[{” 量 “:{” 货币 “:” USD”, “总”: “4.75”}, “说明” :“WFS午餐订单”,“item_list”:{“items”:[{“quantity”:“1”,“name”:“WFS午餐订单”,“价格”:“4.75”,“货币”:“USD “}]}}]} 2013-08-29 09:44:28,847 [16]错误PayPal.Manager.ConnectionManager [(null)]错误响应:{“name”:“INTERNAL_SERVICE_ERROR”,“message”:“发生内部服务错误”,“ information_link “:”https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR”, “debug_id”: “465701e606a56”} 2013-08-29 09:44:28,848 [16] INFO PayPal.Manager.ConnectionManager [(null)]从服务器获取InternalServerError状态代码 2013-08-29 09:44:28,850 [16]错误PayPal.Exception.PayPalException [(null)] HttpConnection中的异常执行 PayPal.Exception.PayPalException:HttpConnection中的异常执行
答案 0 :(得分:0)
我们有时会在沙箱中看到测试卡4111xxx的问题,并正在调查相同的修复程序。因此,请使用沙箱中的其他测试卡进行测试。
注册流读取错误,将测试提供的代码并更新回来。
答案 1 :(得分:0)
问题已在核心SDK中修复。分支https://github.com/paypal/sdk-core-dotnet/tree/fix-log4net-stream中提供了修复。有关详细信息,请参阅https://github.com/paypal/rest-api-sdk-dotnet/issues/10。
答案 2 :(得分:0)
在与PayPal支持人员讨论同一问题之后:显然即使在沙盒中,如果信用卡使用次数太多,也会被阻止。他们建议尝试其他假卡号,并将我引荐到这个网站进行生成:
http://www.fakenamegenerator.com/
使用生成的卡片一直在为我工作。