GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Oceanwings/rest-api-sdk-java: PayPalSDK

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

57 Commits
57 Commits

Folders and files

NameName
Last commit message
Last commit date
rest-api-sample
rest-api-sample
 
 
rest-api-sdk
rest-api-sdk
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

PayPal REST API Java SDK Build Status

This repository contains Java SDK and samples for REST API.

Prerequisites:

  • Java JDK-1.5 or higher
  • Apache Maven 3 or higher
  • Please refer http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html for any help in Maven.

SDK Core Dependency:

  • Source code for core files are present at https://github.com/paypal/sdk-core-java.

To build sdk and samples:

  • Run mvn install to build sdk jar and sample war files.

SDK Integration:

  • Create a new maven application.

  • Add dependency to sdk in your application's pom.xml as below.

    <dependency>
    	<groupId>com.paypal.sdk</groupId>
    	<artifactId>rest-api-sdk</artifactId>
    	<version>0.7.1</version>
    </dependency>
    

To make an API call:

  • Import stub classes into your code. For example,

    import com.paypal.api.payments.*
  • Copy the configuration file sdk_config.properties in rest-api-sample/src/test/resources folder to your application src/main/resources. And load it as a classloader resource,

    InputStream is = PaymentWithCreditCardServlet.class.getResourceAsStream("/sdk_config.properties");
  • Or load config file from any custom location using absolute path with the below method calls as required,

    Payment.initConfig(new File("../sdk_config.properties"));
    					Or
    Payment.initConfig(new InputStream(new File("../sdk_config.properties")));
    					Or
    Payment.initConfig(new Properties().load(new InputStream(new File("../sdk_config.properties"))));
  • Create accesstoken from clientID and clientSecret using OAuthTokenCredential

    String accessToken = new OAuthTokenCredential(clientID, clientSecret).getAccessToken();
  • Depending on the context of API calls, calling method may be static or non-static (For example, most GET http methods are created as static methods within the resource). In all API calls, we need to pass accessToken created above as argument as shown below,

    • If it is static, invoke it as a class method as like

      Payment.get(accessToken, paymentID);
    • If it is non-static, invoke it using resource object as like below. The API call takes a APIContext object in the place of AccessToken, APIContext object encapsulates Access Token and Request ID (used for idempotency).

      APIContext apiContext = new APIContext(accessToken);
      		     (OR)
      APIContext apiContext = new APIContext(accessToken, requestId);
      Payment payment = new Payment();
      payment.setIntent("sale");
      ...		
      payment.create(apiContext);

SDK Configuration:

The SDK uses Java properties format configuration file. Sample of this file is at

rest-api-sample/src/test/resources/. You can use the sdk_config.properties configuration file to configure

  • HTTP connection parameters.

  • Service configuration.

  • Credentials

Bitdeli Badge

About

PayPalSDK

Resources

Readme
License
Activity

Stars

1 star

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.