src/test/java/com/squareup/connect/api/CheckoutApiTest.java
@Test
    public void createCheckoutTest() throws ApiException {
        CreateCheckoutRequest body = new CreateCheckoutRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .order(new CreateOrderRequest()
                .referenceId("reference_id")
                .lineItems(Arrays.asList(
                    new CreateOrderRequestLineItem()
                        .name("Printed T Shirt")
                        .quantity("2")
                        .basePriceMoney(new Money()
                            .amount(1500L)
                            .currency("USD"))
                        .addDiscountsItem(
                            new CreateOrderRequestDiscount()
                                .name("7% off previous season item")
                                .percentage("7")
                        )
                        .addDiscountsItem(
                            new CreateOrderRequestDiscount()
                                .name("$3 off Customer Discount")
                                .amountMoney(new Money()
                                    .amount(300L)
                                    .currency("USD"))
                        ),
                    new CreateOrderRequestLineItem()
                        .name("Slim Jeans")
                        .quantity("1")
                        .basePriceMoney(new Money()
                            .amount(2500L)
                            .currency("USD")),
                    new CreateOrderRequestLineItem()
                        .name("Woven Sweate")
                        .quantity("3")
                        .basePriceMoney(new Money()
                            .amount(3500L)
                            .currency("USD"))
                        .addDiscountsItem(new CreateOrderRequestDiscount()
                            .name("$11 off Customer Discount")
                            .amountMoney(new Money()
                                .amount(1100L)
                                .currency("USD")))
                        .addTaxesItem(new CreateOrderRequestTax()
                            .name("Fair Trade Tax")
                            .percentage("5")
                        )

                ))
                .discounts(Arrays.asList(
                    new CreateOrderRequestDiscount()
                        .name("Father's day 12% OFF")
                        .percentage("12"),
                    new CreateOrderRequestDiscount()
                        .name("Global Sales $55 OFF")
                        .amountMoney(new Money()
                            .amount(5500L)
                            .currency("USD"))
                ))
                .addTaxesItem(new CreateOrderRequestTax()
                    .name("Sales Tax")
                    .type("ADDITIVE")
                    .percentage("8.5")
                )
            )
            .askForShippingAddress(true)
            .merchantSupportEmail("merchant+support@website.com")
            .prePopulateBuyerEmail("example@email.com")
            .prePopulateShippingAddress(new Address()
                .addressLine1("1455 Market St.")
                .addressLine2("Suite 600")
                .locality("San Francisco")
                .administrativeDistrictLevel1("CA")
                .postalCode("94103")
                .country("US")
                .firstName("Jane")
                .lastName("Doe")
            )
            .redirectUrl("https://docs.connect.squareup.com/order-confirm");

        CreateCheckoutResponse response = api.createCheckout(locationId, body);

        assertTrue(response.getErrors().isEmpty());
        assertTrue(response.getCheckout().getCheckoutPageUrl().startsWith("https://connect."));
    }
/**
     * CreateCheckout
     *
     * Creates a [Checkout](#type-checkout) response that links a &#x60;checkoutId&#x60; and
     * &#x60;checkout_page_url&#x60; that customers can be directed to in order to provide their
     * payment information using a payment processing workflow hosted on connect.squareup.com.
     *
     * @throws ApiException if the Api call fails
     */
CreateCheckout
Creates a [Checkout](#type-checkout) response that links a `checkoutId` and
`checkout_page_url` that customers can be directed to in order to provide their
payment information using a payment processing workflow hosted on connect.squareup.com.

@throws ApiException if the Api call fails
CreateCheckout Creates a [ Checkout ] ( #type - checkout ) response that links a ` checkoutId ` and ` checkout_page_url ` that customers can be directed to in order to provide their payment information using a payment processing workflow hosted on connect . squareup . com . @throws ApiException if the Api call fails
@Test
    public void createCheckoutTest() throws ApiException {
        CreateCheckoutRequest body = new CreateCheckoutRequest()
            .idempotencyKey(UUID.randomUUID().toString())
            .order(new CreateOrderRequest()
                .referenceId("reference_id")
                .lineItems(Arrays.asList(
                    new CreateOrderRequestLineItem()
                        .name("Printed T Shirt")
                        .quantity("2")
                        .basePriceMoney(new Money()
                            .amount(1500L)
                            .currency("USD"))
                        .addDiscountsItem(
                            new CreateOrderRequestDiscount()
                                .name("7% off previous season item")
                                .percentage("7")
                        )
                        .addDiscountsItem(
                            new CreateOrderRequestDiscount()
                                .name("$3 off Customer Discount")
                                .amountMoney(new Money()
                                    .amount(300L)
                                    .currency("USD"))
                        ),
                    new CreateOrderRequestLineItem()
                        .name("Slim Jeans")
                        .quantity("1")
                        .basePriceMoney(new Money()
                            .amount(2500L)
                            .currency("USD")),
                    new CreateOrderRequestLineItem()
                        .name("Woven Sweate")
                        .quantity("3")
                        .basePriceMoney(new Money()
                            .amount(3500L)
                            .currency("USD"))
                        .addDiscountsItem(new CreateOrderRequestDiscount()
                            .name("$11 off Customer Discount")
                            .amountMoney(new Money()
                                .amount(1100L)
                                .currency("USD")))
                        .addTaxesItem(new CreateOrderRequestTax()
                            .name("Fair Trade Tax")
                            .percentage("5")
                        )
                ))
                .discounts(Arrays.asList(
                    new CreateOrderRequestDiscount()
                        .name("Father's day 12% OFF")
                        .percentage("12"),
                    new CreateOrderRequestDiscount()
                        .name("Global Sales $55 OFF")
                        .amountMoney(new Money()
                            .amount(5500L)
                            .currency("USD"))
                ))
                .addTaxesItem(new CreateOrderRequestTax()
                    .name("Sales Tax")
                    .type("ADDITIVE")
                    .percentage("8.5")
                )
            )
            .askForShippingAddress(true)
            .merchantSupportEmail("merchant+support@website.com")
            .prePopulateBuyerEmail("example@email.com")
            .prePopulateShippingAddress(new Address()
                .addressLine1("1455 Market St.")
                .addressLine2("Suite 600")
                .locality("San Francisco")
                .administrativeDistrictLevel1("CA")
                .postalCode("94103")
                .country("US")
                .firstName("Jane")
                .lastName("Doe")
            )
            .redirectUrl("https://docs.connect.squareup.com/order-confirm");
        CreateCheckoutResponse response = api.createCheckout(locationId, body);
        assertTrue(response.getErrors().isEmpty());
        assertTrue(response.getCheckout().getCheckoutPageUrl().startsWith("https://connect."));
    }
@ Test public void createCheckoutTest ( ) throws ApiException { CreateCheckoutRequest body = new CreateCheckoutRequest ( ) . idempotencyKey ( UUID . randomUUID ( ) . toString ( ) ) . order ( new CreateOrderRequest ( ) . referenceId ( "reference_id" ) . lineItems ( Arrays . asList ( new CreateOrderRequestLineItem ( ) . name ( "Printed T Shirt" ) . quantity ( "2" ) . basePriceMoney ( new Money ( ) . amount ( 1500L ) . currency ( "USD" ) ) . addDiscountsItem ( new CreateOrderRequestDiscount ( ) . name ( "7% off previous season item" ) . percentage ( "7" ) ) . addDiscountsItem ( new CreateOrderRequestDiscount ( ) . name ( "$3 off Customer Discount" ) . amountMoney ( new Money ( ) . amount ( 300L ) . currency ( "USD" ) ) ) , new CreateOrderRequestLineItem ( ) . name ( "Slim Jeans" ) . quantity ( "1" ) . basePriceMoney ( new Money ( ) . amount ( 2500L ) . currency ( "USD" ) ) , new CreateOrderRequestLineItem ( ) . name ( "Woven Sweate" ) . quantity ( "3" ) . basePriceMoney ( new Money ( ) . amount ( 3500L ) . currency ( "USD" ) ) . addDiscountsItem ( new CreateOrderRequestDiscount ( ) . name ( "$11 off Customer Discount" ) . amountMoney ( new Money ( ) . amount ( 1100L ) . currency ( "USD" ) ) ) . addTaxesItem ( new CreateOrderRequestTax ( ) . name ( "Fair Trade Tax" ) . percentage ( "5" ) ) ) ) . discounts ( Arrays . asList ( new CreateOrderRequestDiscount ( ) . name ( "Father's day 12% OFF" ) . percentage ( "12" ) , new CreateOrderRequestDiscount ( ) . name ( "Global Sales $55 OFF" ) . amountMoney ( new Money ( ) . amount ( 5500L ) . currency ( "USD" ) ) ) ) . addTaxesItem ( new CreateOrderRequestTax ( ) . name ( "Sales Tax" ) . type ( "ADDITIVE" ) . percentage ( "8.5" ) ) ) . askForShippingAddress ( true ) . merchantSupportEmail ( "merchant+support@website.com" ) . prePopulateBuyerEmail ( "example@email.com" ) . prePopulateShippingAddress ( new Address ( ) . addressLine1 ( "1455 Market St." ) . addressLine2 ( "Suite 600" ) . locality ( "San Francisco" ) . administrativeDistrictLevel1 ( "CA" ) . postalCode ( "94103" ) . country ( "US" ) . firstName ( "Jane" ) . lastName ( "Doe" ) ) . redirectUrl ( "https://docs.connect.squareup.com/order-confirm" ) ; CreateCheckoutResponse response = api . createCheckout ( locationId , body ) ; assertTrue ( response . getErrors ( ) . isEmpty ( ) ) ; assertTrue ( response . getCheckout ( ) . getCheckoutPageUrl ( ) . startsWith ( "https://connect." ) ) ; }
CreateCheckout
 Creates a [Checkout](#type-checkout) response that links a &#x60;checkoutId&#x60; and
 &#x60;checkout_page_url&#x60; that customers can be directed to in order to provide their
 payment information using a payment processing workflow hosted on connect.squareup.com.
CreateCheckout Creates a [ Checkout ] ( #type - checkout ) response that links a &#x60 ; checkoutId&#x60 ; and &#x60 ; checkout_page_url&#x60 ; that customers can be directed to in order to provide their payment information using a payment processing workflow hosted on connect . squareup . com .