[英]PayPal integration in spring boot rest api only
I am trying to integrate PayPal in spring boot app using this link, https://developer.paypal.com/docs/api/quickstart/payments/#define-payment but getting exception like bellow: I am trying to integrate PayPal in spring boot app using this link, https://developer.paypal.com/docs/api/quickstart/payments/#define-payment but getting exception like bellow:
2021-03-17 18:37:43.283 INFO 2932 --- [nio-9001-exec-1] d.b.o.controller.PaypalEndpoint : EXception occred
response-code: 400 details: name: INTERNAL_SERVICE_ERROR message: An internal service error has occurred details: [] debug-id: cb8b4f5808cef information-link: https://developer.paypal.com/docs/api/payments/#errors
at com.paypal.base.rest.PayPalRESTException.createFromHttpErrorException(PayPalRESTException.java:72)
at com.paypal.base.rest.PayPalResource.execute(PayPalResource.java:431)
at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:295)
at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228)
at com.paypal.api.payments.Payment.create(Payment.java:149)
public Payment createPayment(
Double total,
String currency,
String method,
String intent,
String description,
String cancelUrl,
String successUrl) throws PayPalRESTException{
Details details = new Details();
details.setShipping("1");
details.setSubtotal("1");
details.setTax("1");
Amount amount = new Amount();
amount.setCurrency(currency);
total = new BigDecimal(total).setScale(2, RoundingMode.HALF_UP).doubleValue();
amount.setTotal(String.format("%.2f", total));
amount.setDetails(details);
Transaction transaction = new Transaction();
transaction.setDescription(description);
transaction.setAmount(amount);
List<Transaction> transactions = new ArrayList<>();
transactions.add(transaction);
Payer payer = new Payer();
payer.setPaymentMethod(method);
Payment payment = new Payment();
payment.setIntent(intent);
payment.setPayer(payer);
payment.setTransactions(transactions);
RedirectUrls redirectUrls = new RedirectUrls();
redirectUrls.setCancelUrl(cancelUrl);
redirectUrls.setReturnUrl(successUrl);
payment.setRedirectUrls(redirectUrls);
return payment.create(apiContext);
}
I think exception is occurred in我认为异常发生在
return payment.create(apiContext);
apiContext have value. apiContext 有价值。 Can any body tell me what is the issue?任何机构都可以告诉我是什么问题吗?
You are attempting to use a deprecated API that should not be used for any new integration.您正在尝试使用不应用于任何新集成的已弃用 API。
Integrate with the REST v2/checkout/orders instead.改为与 REST v2/checkout/orders 集成。 See 'Create Order' and 'Capture Order' at https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls请参阅https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-side-api-calls上的“创建订单”和“获取订单”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.