cancel
Showing results for 
Search instead for 
Did you mean: 

Guest checkout using Java SDK

Options
Vanblerk1
Contributor
Posted on

Hi,

 

I want to know if there is a way to use guest checkout, i.e. allowing a user to pay with a credit/debit card without logging into(or signing up for) PayPal, by using the Java Checkout SDK.

I've integrated with PayPal using the Java checkout SDK.

 

Here is my ApplicationContext config:

 

 

 

 

 

 
    public ApplicationContext applicationContext() {
        ApplicationContext applicationContext = new ApplicationContext();
        applicationContext
            .brandName(brandName)
            .landingPage(landingPage)
            .returnUrl(returnUrl)
            .cancelUrl(cancelUrl)
            .userAction(userAction);

        return applicationContext;
    }

 

 

 

 

 

Here is my createOrder logic:

 

 

 

 

 

public Order createOrder(OrderCreate orderCreate) {
        Order order;

        OrderRequest orderRequest = new OrderRequest();
        orderRequest.checkoutPaymentIntent(CAPTURE_PAYMENT_INTENT);

        orderRequest.applicationContext(applicationContext);

        List<PurchaseUnitRequest> purchaseUnitRequests = new ArrayList<>();
        PurchaseUnitRequest purchaseUnitRequest =
                new PurchaseUnitRequest()
                    .referenceId(orderCreate.getReferenceId())
                    .description(orderCreate.getDescription())
                    .customId(orderCreate.getCustomId())
                    .amountWithBreakdown(
                            new AmountWithBreakdown()                      .currencyCode(orderCreate.getAmount().getCurrency())                         .value(orderCreate.getAmount().getValue().toString())
                    );

        purchaseUnitRequests.add(purchaseUnitRequest);

        orderRequest.purchaseUnits(purchaseUnitRequests);
        OrdersCreateRequest request = new OrdersCreateRequest().requestBody(orderRequest);
        request.prefer(REQUEST_PREFERENCE);

        try {
            HttpResponse<Order> response = this.payPalHttpClient.execute(request);
            order = response.result();
            log.info("Order ID: {}", order.id());
        } catch (IOException ex) {
           //erro handling
          
        }
        return order;
    }

 

 

 

 

 

After creating an order and following the "Approve" hateoas link returned after creating an Order, it takes me to the following page:

 

Screenshot from 2021-08-03 10-10-36.png


Which doesn't allow me to make a credit/debit card payment without a PayPal account.

 

I know that by making use of PayPal's smart buttons you can setup a checkout button like this that allows you to make credit/debit card payments:

Screenshot from 2021-08-03 10-20-10.png

 

Is this at all possible using the Java checkout SDK? Is there some extra configuration that I need to set that I'm missing?

Thanks! 

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.