2014-01-27 45 views
0

我想使用貝寶休息sdk執行交易。貝寶休息sdk-內部服務錯誤發生錯誤

我想以這種方式與sdk文檔相同:。

OAuthTokenCredential tokenCredential = new OAuthTokenCredential(「」,「」);

String accessToken = tokenCredential.getAccessToken(); 

Address billingAddress = new Address(); 
billingAddress.setLine1("52 N Main ST"); 
billingAddress.setCity("Johnstown"); 
billingAddress.setCountryCode("US"); 
billingAddress.setPostalCode(""); 
billingAddress.setState("OH"); 

CreditCard creditCard = new CreditCard(); 
creditCard.setNumber("4417119669820331"); 
creditCard.setType("visa"); 
creditCard.setExpireMonth("11"); 
creditCard.setExpireYear("2018"); 
creditCard.setCvv2("874"); 
creditCard.setFirstName("Joe"); 
creditCard.setLastName("Shopper"); 
creditCard.setBillingAddress(billingAddress); 

AmountDetails amountDetails = new AmountDetails(); 
amountDetails.setSubtotal("7.41"); 
amountDetails.setTax("0.03"); 
amountDetails.setShipping("0.03"); 

Amount amount = new Amount(); 
amount.setTotal("7.47"); 
amount.setCurrency("USD"); 
amount.setDetails(amountDetails); 

Transaction transaction = new Transaction(); 
transaction.setAmount(amount); 
transaction.setDescription("This is the payment transaction description."); 

List<Transaction> transactions = new ArrayList<Transaction>(); 
transactions.add(transaction); 

FundingInstrument fundingInstrument = new FundingInstrument(); 
fundingInstrument.setCreditCard(creditCard); 

List<FundingInstrument> fundingInstruments = new ArrayList<FundingInstrument>(); 
fundingInstruments.add(fundingInstrument); 

Payer payer = new Payer(); 
payer.setFundingInstruments(fundingInstruments); 
payer.setPaymentMethod("credit_card"); 

Payment payment = new Payment(); 
payment.setIntent("sale"); 
payment.setPayer(payer); 
payment.setTransactions(transactions); 

Payment createdPayment = payment.create(accessToken); 

Payment executePayment = Payment.get(accessToken, "PAY-34629814WL663112AKEE3AWQ"); 

PaymentExecution paymentExecution = new PaymentExecution(); 
paymentExecution.setPayerId("7E7MGXCWTTKK2"); 

Payment newPayment = executePayment.execute(accessToken, paymentExecution); 

但我得到異常作爲

Caused by: com.paypal.exception.HttpErrorException: Error code : 500 with response : 
{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link": 
"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"7a7f0k30b2719"} 
     at com.paypal.core.HttpConnection.execute(HttpConnection.java:108) 
     at com.paypal.core.rest.PayPalResource.execute(PayPalResource.java:321) 
     ... 214 more 

任何人都可以告訴我爲什麼我收到此錯誤?

謝謝,

+0

我嘗試按https://developer.paypal.com/webapps/中的給定執行事務開發人員/ docs/api/rest sdk錯誤幾次,但得到相同的異常。 – Java

+0

FWIW我認爲這是一個PayPal錯誤...我猜測「沙箱」不夠穩定...我可能是錯的...但是,有時我的代碼工作,有時不...隨機... c# .NET ...'createdInvoice = getInvoiceFromPayPal.Create(apiContext);'「在PayPalCoreSDK.dll中發生類型'PayPal.Exception.PayPalException'的第一個機會異常」 – gerryLowry

回答

1

我發現PayPal沙箱很不幸不是很可靠。您在此列表中找到的任何信用卡:http://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm 最終都可以從PayPal返回錯誤500。

不斷更改您的測試信用卡號碼以避免此問題。

您也可以使用您自己的信用卡號碼,因爲沙箱環境不會向您的帳戶收取任何費用。

我希望我有更好的答案,因爲我也遇到了這個問題。

參見:PayPal Sandbox Internal Service Error

1

我也發現了這個疑難問題試圖弄清楚這個問題。經過1小時我發現,萬阿英,蔣達清發生是由於相同的信用卡,我們使用多的時間。然後我用不同的卡註冊,我在沙箱模式下獲得了一個新的令牌。然後我付了我的成功消息

相關問題