Giter Club home page Giter Club logo

java-sdk's Introduction

Build Status Coverage Status Maven Central

Hyperwallet REST SDK v2.4.3

A library to manage users, transfer methods and payments through the Hyperwallet v4 API.

For Hyperwallet v3 API calls, please use the latest SDK version 1.x.x. See here to learn about the differences between versions and the update process required to use REST API v4.

Prerequisites

Hyperwallet's Java server SDK requires at minimum JDK (Java Development Kit) version 1.7 and above.

Installation

Maven

<dependency>
    <groupId>com.hyperwallet</groupId>
    <artifactId>sdk</artifactId>
    <version>2.4.3</version>
</dependency>

Gradle

compile 'com.hyperwallet:sdk:2.4.3'

Documentation

Documentation is available at http://hyperwallet.github.io/java-sdk.

API Overview

To write an app using the SDK

  • Register for a sandbox account and get your username, password and program token at the Hyperwallet Program Portal.

  • Add dependency com.hyperwallet:sdk:2.4.3 to your pom.xml (or build.gradle).

  • Create a instance of the Hyperwallet Client (with username, password and program token)

    Hyperwallet client = new Hyperwallet("restapiuser@4917301618", "mySecurePassword!", "prg-645fc30d-83ed-476c-a412-32c82738a20e");
  • Start making API calls (e.g. create a user)

    HyperwalletUser user = new HyperwalletUser();
    user
      .clientUserId("test-client-id-1")
      .profileType(HyperwalletUser.UserProfileType.INDIVIDUAL)
      .firstName("Daffyd")
      .lastName("y Goliath")
      .email("[email protected]")
      .addressLine1("123 Main Street")
      .city("Austin")
      .stateProvince("TX")
      .country("US")
      .postalCode("78701");
    
    try {
        HyperwalletUser createdUser = client.createUser(user);
    } catch (HyperwalletException e) {
        // Add error handling here
    }

Payload Encryption

Hyperwallet’s Payload Encryption is an implementation of Javascript Object Signing and Encryption (JOSE) and JSON Web Tokens (JWT), and provides an alternative to IP allowlisting as the second factor of authentication. Please see https://docs.hyperwallet.com/content/api/v4/overview/payload-encryption for more details.

To enable payload encryption, we need the following two keysets available:

Create a HyperwalletEncryption object providing the two keyset locations, the JWS/JWE algorithms you want to use, and the encryption method.

HyperwalletEncryption hyperwalletEncryption = new HyperwalletEncryptionBuilder()
    .encryptionAlgorithm(JWEAlgorithm.ECDH_ES)
    .encryptionMethod(EncryptionMethod.A256CBC_HS512)
    .signAlgorithm(JWSAlgorithm.ES256)
    .hyperwalletKeySetLocation("src/main/resources/hw-uat.json")
    .clientPrivateKeySetLocation("src/main/resources/client-private-keyset.json")
    .build();

Initialize the Hyperwallet Client with the created HyperwalletEncryption object

Hyperwallet client = new Hyperwallet("restapiuser@4917301618", "mySecurePassword!", "prg-645fc30d-83ed-476c-a412-32c82738a20e", hyperwalletEncryption);  

API requests will now be signed using the private key matching the selected JWS algorithm, and encrypted using Hyperwallet's public key matching the selected JWE algorithm.

Proxy Support

Hyperwallet's API client supports a connection through a proxy. To enable, an appropriate proxy configuration must be provided. It can either be provided as a Proxy object or as a String and Integer representing the URL and Port of the proxy.

A proxy can be configured after creating an instance of the Hyperwallet Client.

client.setHyperwalletProxy("proxyURL", 9090);

To enable Proxy Authorization, proper credentials and System configurations must be provided. In order to connect using Basic Auth, Basic must be an allowed tunneling method within your Java System Properties. By default, it is listed as a disabled tunneling scheme for Java 8. To enable it, follow any of the options provided below:

  • Manually remove Basic from the jdk.http.auth.tunneling.disabledSchemes property inside of JAVA_HOME/jre/lib/net.properties

  • Override System properties with JVM options by providing the below option

    -Djdk.http.auth.tunneling.disabledSchemes=""
  • Set the System property within your code before initializing the Hyperwallet API client

    System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
    Hyperwallet client = new Hyperwallet("restapiuser@4917301618", "mySecurePassword!", "prg-645fc30d-83ed-476c-a412-32c82738a20e");

An example of a fully configured Proxy is provided below:

System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
Hyperwallet client = new Hyperwallet("restapiuser@4917301618", "mySecurePassword!", "prg-645fc30d-83ed-476c-a412-32c82738a20e");
client.setHyperwalletProxy("proxyURL", 3128);
client.setHyperwalletProxyUsername("proxyUsername");
client.setHyperwalletProxyPassword("proxyPassword");

To enable Proxy Support when loading JWS keys for encryption, similar proxy configurations need to be set for the HyperwalletEncryption object.

HyperwalletEncryption hyperwalletEncryption;
      ...
      hyperwalletEncryption.setProxy("proxyURL", 9090);
      hyperwalletEncryption.setProxyUsername("proxyUsername");
      hyperwalletEncryption.setProxyPassword("proxyPassword");

Once this object has been properly configured, it can then be utilized within the Hyperwallet's API client constructor.

Timeout Support

Hyperwallet's API client supports timeout value, in milliseconds, for reading and establishing communications link to Hyperwallet API resources.

   //300 milliseconds
   int connectionTimeout = 300;
   // 2 seconds  
   int readTimout = 2000;
   Hyperwallet client=new Hyperwallet("restapiuser@4917301618","mySecurePassword!","prg-645fc30d-83ed-476c-a412-32c82738a20e",connectionTimeout,readTimout);

Development

Run the tests using maven:

$ mvn test

Reference

REST API Reference

License

MIT

java-sdk's People

Contributors

arao6 avatar ramahalingam avatar fkrauthan-hyperwallet avatar hlahlou-pp-dev avatar saikgupta avatar wmews-hw avatar jkurra-hw avatar rrathinasabapath avatar akalichety-hw avatar gmeyer-hw avatar skoong avatar aseveryn-hw avatar dyurchenko-epam avatar simrandsingh avatar akreisman-epam avatar ssangaran avatar rasyed-hw-dev avatar sgupta-hw-dev avatar yherasym-hw avatar ravikumarmahalingam avatar kprathaban-hw avatar rbao2016 avatar vadimk87 avatar jchanghw avatar grmeyer-hw-dev avatar rjstanford avatar adwivedi-hw avatar kverma-hw avatar bolynykhw avatar igusar-epam avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.