這發生在Sandbox或生產中。如果我在代碼爲4111111111111111的沙箱中輸入代碼和exp date ...當我點擊payment.Creat(token)行時,會拋出異常,「Stream was not readable」。如果我輸入其他一些CC號碼(如423456789),付款工作正常。在生產中,如果我使用那個4234 ...我得到的流是不可讀的錯誤。我知道測試卡並不總是有效,但我希望得到一張信用卡無效回覆。我遇到的問題是,我的一些客戶得到流錯誤....如果我在生產中放入真正的CC,它工作正常..但如果我更改1號碼,我得到無效卡錯誤....所以有時它會正確地發回它,其他時間是Stream錯誤......我最近使用Nuget將包更新到最新和最好的API,但其他人是否有任何建議?Stream對於PayPalRest 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;
這裏是日誌條目中,第一是,如果重試設置爲> 0,第二個是沒有重試 2013年8月29日09:41:45852 [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」:{「number」 「423456789」, 「類型」: 「簽證」, 「expire_month」:5 「EXPIRE_YEAR」:2015, 「CVV2」: 「123」, 「如first_name」: 「米奇」, 「姓氏」: 「基南」,「billing_address 「:{」line1「:」123 Main St「,」city「:」Denver「,」country_code「:」US「,」postal_code「:」80210「,」state「:」CO「},」payer_id「 「205」}}]},「transactions」:[{「amount」:{「currency」:「USD」,「total」:「4.75」},「description」:「WFS Lunch Order」,「item_list」 {「items」:[{「quantity」:「1」,「name」:「WFS Lunch Order」,「price」:「4.75」,「currency」:「USD」}]}}]} 2013-08 -29 09:41:49,505 [33] ERROR 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「}信息PayPal.Manager.ConnectionManager [(null)]得到InternalServerError狀態代碼從服務器 2013-08-29 09:41:49,507 [33] ERROR PayPal.Exception.PayPalException [(null)] HttpConnection中的異常執行:流不可讀。 PayPal.Exception.PayPalException:HttpConnection中的異常執行:Stream不可讀。 ---> System.ArgumentException:流不可讀。 (Stream stream,Encoding encoding,Boolean detectEncodingFromByteOrderMarks,Int32 bufferSize,Boolean leaveOpen) at System.IO.StreamReader..ctor(Stream stream) at PayPal.HttpConnection.Execute(String payLoad ,HttpWebRequest的HttpRequest的) ---內部異常堆棧跟蹤的結尾---
這裏是第二 2013年8月29日09:44:27685 [16] DEBUG PayPal.PayPalResource [(空)]用戶 - 代理: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 [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」:{「number」 「423456789」, 「類型」: 「簽證」, 「expire_month」:5 「EXPIRE_YEAR」:2015, 「CVV2」: 「123」, 「如first_name」: 「米奇」, 「姓氏」: 「基南」,「billing_address 「:{」line1「:」123 Main St「,」city「:」Denver「,」country_code「:」US「,」postal_code「:」80210「,」state「:」CO「},」payer_id「 「205」}}]},「transactions」:[{「amount」:{「currency」:「USD」,「total」:「4.75」},「description」:「WFS Lunch Order」,「item_list」 {「items」:[{「quantity」:「1」,「name」:「WFS Lunch Order」,「price」:「4。75「,」currency「:」USD「}]}}]} 2013-08-29 09:44:28,847 [16] ERROR 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信息PayPal.Manager .ConnectionManager [(null)]從服務器得到InternalServerError狀態代碼 2013-08-29 09:44:28,850 [16] ERROR PayPal.Exception.PayPalException [(null)] HttpConnection中的異常執行 PayPal.Exception.PayPalException:Exception在HttpConnection執行
我遇到同樣的問題。我嘗試的每個測試信用卡都會給我一個INTERNAL_SERVICE_ERROR響應。我聯繫了貝寶支持,他們把我推薦到這個帖子上:) – Cully