---
page_source: https://juspay.io/in/docs/hyper-checkout/android/base-sdk-integration/open-hypercheckout-screen
page_title: 3. Open Hypercheckout Screen
---


# 3. Open Hypercheckout Screen



Once the Hypercheckout screen is opened, your users can proceed with the transactions. Opening Hypercheckout requires a Server-to-Server request from Merchant to Juspay. The response of this should be forwarded to the Hypercheckout SDK in order to open the payment screen.

> **Warning**
> **This step should be done only once the final payable amount is available** 




### Step 3.1. Fetch Process Payload


The `process` function takes a JSONObject as argument. This argument is also known as process payload.

In order to fetch process payload following steps should be followed: Make a request from Client to your Server with necessary order parameters Your server should call [Juspay's Session API](/hyper-checkout/android/base-sdk-integration/session)(Server-to-Server call) Session API will respond with a JSON object which contains process payload inside `sdk_payload` key Send the `sdk_payload` from your server to client



#### Code Snippets: -

#### Java Code Snippet:

```java
// Note: Session API should only be called from merchant's server. Don't call it from client app
    // -----------------------------------------------------------------
    private void run() throws IOException {
        JSONObject payload = new JSONObject();
        // API Key Should never be used from client side, it should always be stored securely on server.
        // And all the API calls requiring API key should always be done from server
        String apiKey = "<YOUR_API_KEY>";  //Put your API Key Here
        String clientId = "<CLIENT_ID>";  // Put your clientID here
        String merchantId = "<MERCHANT_ID>";   // Put your merchant ID here

        long randomOrderId = (long) (Math.random()*Math.pow(10,12)); 
        String order_id = "test-" + Long.toString(randomOrderId);    // Put you own order id here
        try{
            // You can put your payload details here
            payload.put("order_id", order_id);    // OrderID should be unique
            payload.put("amount", amountString);    // Amount should be in strings e.g. "100.00"
            payload.put("customer_id", "9876543201");    // Customer ID should be unique for each user and should be a string
            payload.put("customer_email", "test@mail.com");
            payload.put("customer_phone", "9876543201");
            payload.put("payment_page_client_id", clientId);
            payload.put("action", "paymentPage");
            payload.put("first_name", "john");
            payload.put("last_name", "wick");
            payload.put("description", "Order Description");
            // For other payload params you can refer to the integration doc shared with you
        } catch (Exception e){

        }


        OkHttpClient client = new OkHttpClient();

        MediaType mediaType = MediaType.parse("application/json");
        RequestBody requestBody = RequestBody.create(mediaType, payload.toString());
        String authorization = "Basic " + Base64.getEncoder().encodeToString(apiKey.getBytes());
        Request request =
                new Request.Builder()
                        .url("https://api.juspay.in/session")
                        .method("POST", requestBody)
                        .addHeader("x-merchantid", merchantId)
                        .addHeader("Authorization", authorization)
                        .addHeader("Content-Type", "application/json")
                        .build();

        // Note: Session API should only be called from merchant's server. Don't call it from client app
        client.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                call.cancel();
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                try{
                    String processResponse = response.body().string();

                    JSONObject jsonObj = new JSONObject(processResponse);
                    JSONObject sdkPayload = jsonObj.getJSONObject("sdk_payload");

                    CheckoutActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            startPayments(sdkPayload);
                        }
                    });
                } catch (Exception e){

                }
            }
        });
    }
    // -----------------------------------------------------------------
```

#### Kotlin Code Snippet:

```kotlin
// Note: Session API should only be called from merchant's server. Don't call it from client app
    // -----------------------------------------------------------------
    @Throws(IOException::class)
    fun run() {
        val payload = JSONObject()
        
        // API Key Should never be used from client side, it should always be stored securely on server.
        // And all the API calls requiring API key should always be done from server
        val apiKey = "<API_KEY>"     //Put your API Key Here
        val clientId = "<CLIENT_ID>"    //Put your Client ID here
        val merchantId = "<MERCHANT_ID>"     // Put your Merchant ID here
        val randomOrderId = (Math.random() * Math.pow(10.0, 12.0)).toLong()
        val order_id = "test-" + java.lang.Long.toString(randomOrderId)
        try {
            payload.put("order_id", order_id)
            payload.put("amount", amountString)          // Amount must be in string
            payload.put("customer_id", "9876543201")        //Customer id should be in string
            payload.put("customer_email", "test@mail.com")
            payload.put("customer_phone", "9876543201")     //Mobile number should be in string
            payload.put("payment_page_client_id", clientId)
            payload.put("action", "paymentPage")
            payload.put("offer_code", "testingCode")
            payload.put("first_name", "john")
            payload.put("last_name", "wick")
            payload.put("description", "Order Description")
        } catch (e: Exception) {
        }
        val client = OkHttpClient()
        val mediaType: MediaType? = "application/json".toMediaTypeOrNull()
        val requestBody: RequestBody = RequestBody.create(mediaType, payload.toString())
        val authorization = "Basic " + Base64.getEncoder().encodeToString(apiKey.toByteArray())
        val request: Request = Request.Builder()
            .url("https://api.juspay.in/session")
            .method("POST", requestBody)
            .addHeader("x-merchantid", merchantId)
            .addHeader("Authorization", authorization)
            .addHeader("Content-Type", "application/json")
            .build()
        // NOTE: DON'T COPY THIS CODE IN YOUR CLIENT APP
        // Juspay API should be called from your server, client app should only fetch the sdk_payload from your server
        client.newCall(request).enqueue(object : Callback {


            override fun onFailure(call: Call, e: IOException) {
                call.cancel()
            }
            @Throws(IOException::class)
            override fun onResponse(call: Call, response: Response) {
                try {
                    val processResponse: String = response.body?.string() ?: ""
                    val jsonObj = JSONObject(processResponse)
                    val sdkPayload = jsonObj.getJSONObject("sdk_payload")
                    runOnUiThread { startPayments(sdkPayload) }
                } catch (e: Exception) {
                }
            }
        })
    }
    // -----------------------------------------------------------------
```



### Step 3.3. Call Process Function


Pass the JSON inside `sdk_payload` obtained in `Step 3.1`, to `process`SDK``function`.`

The process function is to be called using an instance of `HyperServiceHolder`



#### Code Snippets: -

#### Java Code Snippet:

```java
private void startPayments(JSONObject sdk_payload) {
        // Make sure to use the same hyperServices instance which was created in
        // ProductsActivity.java

        Helper helper = new Helper();
        helper.showSnackbar("Process Called!", coordinatorLayout);
        hyperServicesHolder.process(sdk_payload);

    }
```

#### Kotlin Code Snippet:

```kotlin
fun startPayments(sdk_payload: JSONObject?) {
        // Make sure to use the same hyperServices instance which was created in
        // ProductsActivity.java
        showSnackbar("Process Called!")
        hyperServicesHolder?.process(sdk_payload)
    }
```


> **Warning**
> As soon as you sign up with Juspay, we set you up with a Dummy PG automatically. Using this Dummy PG, you can run test transactions with a pre-configured set of cards. You may also configure the test credentials of the gateway and use the respective test cards for completing the transaction journey. Please refer to the [Test Resources](/hyper-checkout/android/resources/test-resources)page for more details.

