Skip to content

a-ibarra/checkout-sdk-java

 
 

Repository files navigation

Checkout.com Java SDK

Build Status GitHub license GitHub release

Getting started

Binaries, Javadoc, and sources are all available from Maven Central.

Gradle

dependencies {
    implementation 'com.checkout:checkout-sdk-java:<version>'
}

Maven

<dependency>
    <groupId>com.checkout</groupId>
    <artifactId>checkout-sdk-java</artifactId>
    <version>version</version>
</dependency>

Please check in GitHub releases for all the versions available.

How to use the SDK

This SDK can be used with two different pair of API keys provided by Checkout. However, using different API keys imply using specific API features. Please find in the table below the types of keys that can be used within this SDK.

Account System Public Key (example) Secret Key (example)
Classic pk_test_fe70ff27-7c42-4ce1-ae90-5691a188ee7b sk_test_fde517a8-3z01-41ef-b4bd-4282384b0a64
Four pk_sbox_pkhpdtvmkgf7hdgpwnbhw7r2uic sk_sbox_m73dzypy7cf3gfd46xr4yj5xo4e

If you don't have your own API keys, you can sign up for a test account here.

This SDK does not support oAuth (yet).

Classic

If your pair of keys matches the Classic type, this is how the SDK should be used:

public static void main(String[] args) {

    boolean useSandbox = true;

    CheckoutApi checkoutApi = CheckoutApiImpl.create("secret_key", useSandbox, "public_key");

    PaymentsClient paymentsClient = checkoutApi.paymentsClient();
    CompletableFuture<RefundResponse> refundResponse = paymentsClient.refundAsync("payment_id");
    
}

Four (BETA)

If your pair of keys matches the Four type, this is how the SDK should be used:

public static void main(String[] args) {

    CheckoutApi checkoutApi = Checkout.staticKeys()
                .environment(Environment.SANDBOX)
                .build();

    PaymentsClient paymentsClient = checkoutApi.paymentsClient();
    CompletableFuture<RefundResponse> refundResponse = paymentsClient.refundPayment("payment_id");
}

Please note that at the moment, support for Four API keys is quite limited. Future releases will provide a bigger feature set for this credential type.

More examples can be found in the following places:

  • Samples available under samples
  • Integration tests in this repo, located under src/test

Building from source

Once you checkout the code from GitHub, the project can be built using Gradle:

gradlew build

# skip tests
gradlew build -x test

Integration tests execution requires two pairs of keys, and the following environment variables set in your system:

  • For Classic account systems: CHECKOUT_PUBLIC_KEY & CHECKOUT_SECRET_KEY
  • For Four account systems: CHECKOUT_FOUR_PUBLIC_KEY & CHECKOUT_FOUR_SECRET_KEY

Code of Conduct

Please refer to Code of Conduct

Licensing

MIT