paypal仅在spring boot rest api中集成

cfh9epnr  于 2021-07-16  发布在  Java
关注(0)|答案(1)|浏览(425)

我正在尝试使用这个链接将paypal集成到SpringBoot应用程序中,https://developer.paypal.com/docs/api/quickstart/payments/#define-付款但有以下例外情况:

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);
    }

我想这是个例外

return payment.create(apiContext);

apicontext有价值。有人能告诉我问题出在哪里吗?

zengzsys

zengzsys1#

您正在尝试使用不推荐使用的api,该api不应用于任何新的集成。
与其他v2/checkout/orders集成。请参见“创建订单”和“捕获订单”https://developer.paypal.com/docs/business/checkout/server-side-api-calls/#server-侧api调用

相关问题