Skip to main content

Hello World sample code

Learn how to test connectivity using the Hello world sample code

Overview

The Hello World API is a simple endpoint that verifies connectivity between your application and the Visa Developer gateway, ensuring that your credentials, certificates, and environment are set up correctly.

In this guide, you will learn how to:

  • Edit the Hello World sample code
  • Send a Hello World API request

Before you begin

Before running Hello World sample code, confirm that:

  • You have a Visa Developer account and a project, as described in the quick start
  • You have obtained your Two-Way SSL or X-Pay Token credentials
  • You have downloaded the Hello World sample code from Onboarding Dashboard > Assets > General Assets > Sample Code

Step 1: Edit the Hello World sample

  1. Open the Hello World sample code file for your programming language.
  2. Replace the values in brackets (<>) with your specific credentials. For example, in Java:
    • String keystorePath = "<YOUR JAVA KEYSTORE PATH>";
    • String keystorePassword = "<YOUR KEYSTORE PASSWORD>"; 
    • String userId = "<YOUR USER ID>";
    • String password = "<YOUR PASSWORD>";
  3. The sample code sets the helloworld URL to Sandbox. To test in Certification or Production, change the URL accordingly:
    • Sandbox: https://sandbox.api.visa.com/vdp/helloworld
    • Certification: https://cert.api.visa.com/vdp/helloworld
    • Production: https://api.visa.com/vdp/helloworld

Sample code (Java):


/*
 * (c) Copyright 2018 - 2020 Visa. All Rights Reserved.**
 *
 * NOTICE: The software and accompanying information and documentation (together, the “Software”) remain the property of and are proprietary to Visa and its suppliers and affiliates. The Software remains protected by intellectual property rights and may be covered by U.S. and foreign patents or patent applications. The Software is licensed and not sold.*
 *
 * By accessing the Software you are agreeing to Visa's terms of use (developer.visa.com/terms) and privacy policy (developer.visa.com/privacy).In addition, all permissible uses of the Software must be in support of Visa products, programs and services provided through the Visa Developer Program (VDP) platform only (developer.visa.com). **THE SOFTWARE AND ANY ASSOCIATED INFORMATION OR DOCUMENTATION IS PROVIDED ON AN “AS IS,” “AS AVAILABLE,” “WITH ALL FAULTS” BASIS WITHOUT WARRANTY OR CONDITION OF ANY KIND. YOUR USE IS AT YOUR OWN RISK.** All brand names are the property of their respective owners, used for identification purposes only, and do not imply product endorsement or affiliation with Visa. Any links to third party sites are for your information only and equally do not constitute a Visa endorsement. Visa has no insight into and control over third party content and code and disclaims all liability for any such components, including continued availability and functionality. Benefits depend on implementation details and business factors and coding steps shown are exemplary only and do not reflect all necessary elements for the described capabilities. Capabilities and features are subject to Visa’s terms and conditions and may require development,implementation and resources by you based on your business and operational details. Please refer to the specific API documentation for details on the requirements, eligibility and geographic availability.*
 *
 * This Software includes programs, concepts and details under continuing development by Visa. Any Visa features,functionality, implementation, branding, and schedules may be amended, updated or canceled at Visa’s discretion.The timing of widespread availability of programs and functionality is also subject to a number of factors outside Visa’s control,including but not limited to deployment of necessary infrastructure by issuers, acquirers, merchants and mobile device manufacturers.*
 *
 */

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.KeyStore;
import java.util.Base64;

public class Helloworld {

 public static void main(String[] args) throws Exception {

 System.out.println("START Sample Code for Two-Way (Mutual) SSL");
 URL url = new URL("https://sandbox.api.visa.com/vdp/helloworld");

 HttpURLConnection con = (HttpURLConnection) url.openConnection();

 // THIS IS EXAMPLE ONLY how will cert and key look like
 // keystorePath = "visa.jks"
 // keystorePassword = "password"

 String keystorePath = "<YOUR JAVA KEYSTORE PATH>";
 String keystorePassword = "<YOUR KEYSTORE PASSWORD>";
 // Make a KeyStore from the PKCS-12 file
 KeyStore ks = KeyStore.getInstance("PKCS12");
 try (FileInputStream fis = new FileInputStream(keystorePath)) {
 ks.load(fis, keystorePassword.toCharArray());
 }

 // Make a KeyManagerFactory from the KeyStore
 KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
 kmf.init(ks, keystorePassword.toCharArray());

 // Now make an SSL Context with our Key Manager and the default Trust Manager
 SSLContext sslContext = SSLContext.getInstance("TLS");
 sslContext.init(kmf.getKeyManagers(), null, null);
 if (con instanceof HttpsURLConnection) {
 ((HttpsURLConnection) con).setSSLSocketFactory(sslContext.getSocketFactory());
 }

 con.setRequestMethod("GET");
 con.setRequestProperty("Content-Type", "application/json");
 con.setRequestProperty("Accept", "application/json");

 // THIS IS EXAMPLE ONLY how will user_id and password look like
 // userId = "1WM2TT4IHPXC8DQ5I3CH21n1rEBGK-Eyv_oLdzE2VZpDqRn_U";
 // password = "19JRVdej9";
 String userId = "<YOUR USER ID>";
 String password = "<YOUR PASSWORD>";

 String auth = userId + ":" + password;
 byte[] encodedAuth = Base64.getEncoder().encode(auth.getBytes(StandardCharsets.UTF_8));
 String authHeaderValue = "Basic " + new String(encodedAuth);
 con.setRequestProperty("Authorization", authHeaderValue);

 int status = con.getResponseCode();
 System.out.println("Http Status: " + status);

 BufferedReader in;
 if (status == 200) {
 in = new BufferedReader(new InputStreamReader(con.getInputStream()));
 } else {
 in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
 System.out.println("Two-Way (Mutual) SSL test failed");
 }
 String response;
 StringBuffer content = new StringBuffer();
 while ((response = in.readLine()) != null) {
 content.append(response);
 }
 in.close();
 con.disconnect();

 System.out.println(content.toString());
 System.out.println("END Sample Code for Two-Way (Mutual) SSL");
 }
}
Copied!

Step 2: Send a Hello World API request

Build and run the sample code according to your development environment in order to send a Hello World API request.

If the request is successful, you will receive an HTTP 200 OK response with a response body, like the one below.

{
    "timestamp": "2026-05-28T22:14:23",
    "message": "helloworld"
}
Copied!

If the request is not successful, ensure you are using the correct credentials for your environment.

Need help?

Find answers in our FAQs or get support from a Visa Developer expert.