# Connect using the SDK
source: https://developer.mastercard.com/straight-through-processing/documentation/tutorials-and-guides/connect-using-the-sdk-tutorial/index.md

## Overview {#overview}

This tutorial explains how to use the supplied Java SDK to integrate with the STP service.

### You will learn how to {#you-will-learn-how-to}

* Use the Java SDK to make requests.

## Prerequisites {#prerequisites}

Before starting this tutorial, ensure that you have already completed the following tasks:

1. Supply the STP implementation team with the suppliers you want to use STP with.
2. Create your project and retrieve the required credentials by following [Create a Sandbox project](https://developer.mastercard.com/straight-through-processing/documentation/tutorials-and-guides/create-sandbox-project-tutorial/index.md) tutorial.
3. Share your consumer key with the STP implementation team and receive confirmation that you have been onboarded to Sandbox.
4. Download the Java [Jar](https://developer.mastercard.com/straight-through-processing/documentation/sdk/index.md) file and add it as a dependency to your project.

## Initiate the API Client {#initiate-the-api-client}

```java

// Import classes:
//import com.mastercard.stp.ApiException;
//import com.mastercard.stp.client.ProvidersApi;

try {
    ApiClient apiClient = new ApiClient().initiate("<Place your consumer key here>",
            "<Place your path to your p12 file here>",
            "keyalias", "keystorepassword");
} catch (ApiException e) {
        // Auto-generated catch block
        e.printStackTrace();
}
```

## Link Suppliers {#link-suppliers}

```java

// Import classes:
//import com.mastercard.stp.ApiException;
//import com.mastercard.stp.client.SuppliersApi;
//import com.mastercard.stp.models.Supplier;

SuppliersApi apiInstance = new SuppliersApi();
apiInstance.setApiClient(apiClient); //Important to set the client we created previously
Supplier body = new Supplier(); // Supplier | Supplier data.
//Build the supplier object from the Providers result (You should use something like GSON to make this easy)
body.setName("Delta-3");
//...
try {
    Supplier result = apiInstance.suppliersPost(body);
    System.out.println(result); //Result will be printed
} catch (ApiException e) {
    System.err.println("Exception when calling SuppliersApi#suppliersPost");
    e.printStackTrace();
}
```

## Make a payment {#make-a-payment}

```java

// Import classes:
//import com.mastercard.stp.ApiException;
//import com.mastercard.stp.client.PaymentsApi;
//import com.mastercard.stp.models.Payment;

PaymentsApi apiInstance = new PaymentsApi();
apiInstance.setApiClient(apiClient); //Important to set the client we created previously
Payment body = new Payment(); // Payment | Payment data.
//Build the payment object with the required parameters; cardNumber, expiryMonth, expiryYear, amount, currencyAplhaCode
body.cardNumber("5555555....");
//...
try {
    Payment result = apiInstance.paymentsPost(body);
    System.out.println(result); //Result will be printed
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentsApi#paymentsPost");
    e.printStackTrace();
}
```

## Check the status of the payment {#check-the-status-of-the-payment}

```java

// Import classes:
//import com.mastercard.stp.ApiException;
//import com.mastercard.stp.client.PaymentApi;

PaymentApi apiInstance = new PaymentApi();
BigDecimal id = new BigDecimal(); // BigDecimal | ID of the payment request. Integer. Must be a positive value.
try {
    Payment result = apiInstance.paymentsIdGet(id);
    System.out.println(result); //Result will be printed
} catch (ApiException e) {
    System.err.println("Exception when calling PaymentApi#paymentsIdGet");
    e.printStackTrace();
}
```

