2013-08-19 24 views
1

這發生在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執行

+0

我遇到同樣的問題。我嘗試的每個測試信用卡都會給我一個INTERNAL_SERVICE_ERROR響應。我聯繫了貝寶支持,他們把我推薦到這個帖子上:) – Cully

回答

0

我們有時會看到沙盒中的測試卡4111xxx的問題,並且正在研究相同的修復方法,因此請使用沙箱中的其他測試卡進行測試G。

註冊流讀取錯誤,將測試提供的代碼並更新回來。

+0

對此有何更新?我期望4111-1111-1111-1111或4234-5678-9012-3456在任一環境中工作。但我有客戶輸入一個CC號碼,大概是他們的卡上得到相同的流是不可讀的...可能是他的卡失敗了一些驗證(地址,郵政編碼,CVV代碼等...)但那些似乎返回有效的錯誤 –

+0

你仍然面臨這個問題?對於無效的測試卡,我收到了正確的無效信用卡回覆。如果您仍然面臨問題,請使用實際的JSON請求負載更新註釋,而不需要您的憑據等。 –

+0

是的,我仍然得到這個。我使用從GIT下載的SDK運行了一些測試,並且能夠獲得更多信息......當我第一次發出請求時,它返回一個Java Read Timeout錯誤...然後它嘗試重試並獲取Stream是不可讀的錯誤...真正的問題可能是超時,但重試不起作用在這種情況下...我從日誌消息中添加JSON調用...讓我知道如果這有幫助... –

0

在與PayPal支持部門談到此問題之後:顯然即使在沙盒中,如果信用卡使用太多,它也會被阻止。他們建議嘗試其他的假身份證號碼,並叫我去這個網站生成它們:

http://www.fakenamegenerator.com/

使用卡產生已經爲我工作。

相關問題