我正在尝试使用paypal rest sdk执行交易。
我正在尝试这种方式与sdk文档相同:。
OAuthTokenCredential tokenCredential = 新的OAuthTokenCredential(“”,“”);
String accessToken = tokenCredential.getAccessToken();
Address billingAddress = new Address();
billingAddress.setLine1("52 N Main ST");
billingAddress.setCity("Johnstown");
billingAddress.setCountryCode("US");
billingAddress.setPostalCode("43210");
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 :(得分:1)
我发现PayPal沙箱不太可靠。您在此列表中找到的任何信用卡:http://www.paypalobjects.com/en_US/vhelp/paypalmanager_help/credit_card_numbers.htm 可以并且最终将从PayPal返回错误500。
不断更改测试信用卡号码以避免此问题。
您也可以使用自己的信用卡号码,因为沙盒环境无论如何都不会向您的帐户收取任何费用。
我希望我有更好的答案,因为我也遇到了这个问题。
答案 1 :(得分:1)
我也发现了这个问题。我试图找出这个问题.1小时后我发现问题是由于我们多次使用同一张信用卡而发生的。然后我用不同的卡注册,我在沙盒模式下获得了一个新的令牌。然后我付了我的成功消息