Giter Site home page Giter Site logo

sdk-core-java's Introduction

This repository contains core files for all Java sdks.

Prerequisites:

  • Java JDK-1.5 or higher
  • Apache Maven 3 or higher

To build this application:

  • Run 'mvn install' to build jar file.

Core Testing:

  • Run 'mvn test' to run the test cases for all the core classes.
  • Test reports are generated in testReport folder.

Core Logging:

  • For logging - java.util.logging has been used. To change the default configuration, edit the logging.properties file in 'jre/lib' folder under your JDK root.

Core Configuration:

The core uses .properties format configuration file. Sample of this file is at 'src/test/resources/'. You can use the 'sdk_config.properties' configuration file to configure

  • Mode is specified using the parameter name 'mode' with values 'sandbox' or 'live', if specified 'service.EndPoint' parameter is not required and the SDK choses the sandbox or live endpoints automatically.

  • (Multiple) API account credentials, by appending a '.' (dot) character and the service name to 'service.EndPoint' parameter.

  • HTTP connection parameters, if certain connection parameters are not specified, the SDK will assume defaults for them.

  • Service configuration.

OpenID Connect Integration

  • Redirect your buyer to Authorization.getRedirectUrl(redirectURI, scope, configurationMap); to obtain authorization.
  • Capture the authorization code that is available as a query parameter (code) in the redirect url
  • Exchange the authorization code for a access token, refresh token, id token combo
    Map<String, String> configurationMap = new HashMap<String, String>();
    configurationMap.put("clientId", "...");
    configurationMap.put("clientSecret", "...");
    configurationMap.put("service.EndPoint", "https://api.paypal.com/");
    APIContext apiContext = new APIContext();
    apiContext.setConfigurationMap(configurationMap);
    ...
    CreateFromAuthorizationCodeParameters param = new CreateFromAuthorizationCodeParameters();
    param.setCode(code);
    Tokeninfo info = Tokeninfo.createFromAuthorizationCode(apiContext, param);
    String accessToken = info.getAccessToken();
  • The access token is valid for a predefined duration and can be used for seamless XO or for retrieving user information
    Map<String, String> configurationMap = new HashMap<String, String>();
    configurationMap.put("clientId", "...");
    configurationMap.put("clientSecret", "...");
    configurationMap.put("service.EndPoint", "https://api.paypal.com/");
    APIContext apiContext = new APIContext();
    apiContext.setConfigurationMap(configurationMap);
    ...
    Tokeninfo info = new Tokeninfo();
    info.setRefreshToken("refreshToken");
    UserinfoParameters param = new UserinfoParameters();
    param.setAccessToken(info.getAccessToken());
    Userinfo userInfo = Userinfo.userinfo(apiContext, param);
  • If the access token has expired, you can obtain a new access token using the refresh token from the 3'rd step.
    Map<String, String> configurationMap = new HashMap<String, String>();
    configurationMap.put("clientId", "...");
    configurationMap.put("clientSecret", "...");
    configurationMap.put("service.EndPoint", "https://api.paypal.com/");
    APIContext apiContext = new APIContext();
    apiContext.setConfigurationMap(configurationMap);
    ...
    CreateFromRefreshTokenParameters param = new CreateFromRefreshTokenParameters();
    param.setScope("openid"); // Optional
    Tokeninfo info = new Tokeninfo // Create Token info object; setting the refresh token
    info.setRefreshToken("refreshToken");

    info.createFromRefreshToken(apiContext, param);

sdk-core-java's People

Contributors

kumaravel-jayakumar avatar lathavairamani avatar prannamalai avatar tkanta avatar lvairamani avatar aydiv avatar ganeshx avatar markdevries avatar

Watchers

Phuc Huynh 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.