• Getting Started
    • Mobile Integration (Android/IOS)
      Enterprise Solutions
      Accept Payments
      Process Payments
      Disbursals
      API References
      Webhooks
      Testing
      Refunds
      Guides
      Other Processes
      Mini Program Platform
        Website Integration

      JAVA SDK Integration

      It is a client java library that provides an easy way to interact with the Paytm miniapp ecosystem.

      Installation Guide


      Requirements

      Java 1.7 or later.

      Installing Mini Program SDK with maven

      1. Add below maven repository to your project's POM

        <repository>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
            <id>snapshots</id>
            <name>libs-snapshot</name>
            <url>https://artifactorypg.paytm.in/artifactory/libs-snapshot</url>
        </repository>
      2. Add below maven dependency to your project's POM

        <dependency>
            <groupId>com.paytm</groupId>
            <artifactId>miniapp-sdk-client</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
      3. Build and install locally by executing below command

        $ mvn install

      SDK code


      Auth Client

      // Configuring Auth client
      /*To create HttpClientProperties, 4 parameters are required
              *  1. socketTimeout - Integer
              *  2. connectionTimeout - Integer
              *  3. connectionRequestTimeout - Integer
              *  4. hostUri - String
              * */
              HttpClientProperties httpClientProperties = new HttpClientProperties
                  .Builder()
                  .setSocketTimeout(5000)
                  .setConnectionTimeout(5000)
                  .setConnectionRequestTimeout(5000)
                  .setHostUri("https://accounts.paytm.com")
                  .build();
      
          OAuthClient oAuthClient = OAuthClient.getInstance(httpClientProperties,
                                    "<Auth Client ID received on onboarding>", "<Auth Client Secret received on onboarding>");
      
      // Fetch Access Token
      // Create oauth token request
          OauthTokenRequest oauthTokenRequest = new OauthTokenRequest
                                                      .Builder()
                                                      .setCode("<Auth code received from trust login>")
                                                      .build();
      
      
          try {
                HTTPServiceResponse<OauthTokenResponse> response = oauthClient.oauthToken(oauthTokenRequest, null);
              } catch (MiniAppClientException ex) {
                ErrorResponse errorResponse = ex.getError();
                Integer errorCode = ex.getErrorCode();
              }
      // User Profile
      // Create fetch user profile request
          UserProfileRequest userProfileRequest = new UserProfileRequest
                                                      .Builder()
                                                      .setScopeCode("<received from fetch access token api response: access_token>")
                                                      .build();
      
          try {
               HTTPServiceResponse<OAuthUserProfile> response = oAuthClient.v2UserProfile(userProfileRequest);
          } catch (MiniAppClientException ex) {
              ErrorResponse errorResponse = ex.getError();
              Integer errorCode = ex.getErrorCode();
          }

      Exceptions

      Error TypeError CodeDescription
      UNKNOWN_EXCEPTION1000General error code when cause of exception is not known
      HTTP_IO_EXCEPTION1001Error code when there is an error in HTTP rest call
      JSON_PROCESSING_EXCEPTION1002Error while json serialization or deserialization
      IO_EXCEPTION1003Error in json serialization or deserialization
      ERROR_RESPONSE_FROM_API1004API did not give success response
      MANDATORY_HEADER_MISSING1005Validation error of missing header
      INVALID_REQUEST1006Validation error of not valid request
      INVALID_CLIENT_ATTRIBUTES1007Invalid attributes provided while client creation