Giter VIP home page Giter VIP logo

pagarme-java-sdk's Introduction

Getting Started with PagarmeApiSDK

Introduction

Pagarme API

Building

Supported Java version is 8+.

The generated code uses a few Maven dependencies e.g., Jackson, OkHttp, and Apache HttpClient. The reference to these dependencies is already added in the pom.xml file will be installed automatically. Therefore, you will need internet access for a successful build.

  • In order to open the client library in Eclipse click on File -> Import.

Importing SDK into Eclipse - Step 1

  • In the import dialog, select Existing Java Project and click Next.

Importing SDK into Eclipse - Step 2

  • Browse to locate the folder containing the source code. Select the detected location of the project and click Finish.

Importing SDK into Eclipse - Step 3

  • Upon successful import, the project will be automatically built by Eclipse after automatically resolving the dependencies.

Importing SDK into Eclipse - Step 4

Installation

The following section explains how to use the PagarmeApiSDKLib library in a new project.

1. Starting a new project

For starting a new project, click the menu command File > New > Project.

Add a new project in Eclipse

Next, choose Maven > Maven Project and click Next.

Create a new Maven Project - Step 1

Here, make sure to use the current workspace by choosing Use default Workspace location, as shown in the picture below and click Next.

Create a new Maven Project - Step 2

Following this, select the quick start project type to create a simple project with an existing class and a main method. To do this, choose maven-archetype-quickstart item from the list and click Next.

Create a new Maven Project - Step 3

In the last step, provide a Group Id and Artifact Id as shown in the picture below and click Finish.

Create a new Maven Project - Step 4

2. Add reference of the library project

The created Maven project manages its dependencies using its pom.xml file. In order to add a dependency on the PagarmeApiSDKLib client library, double click on the pom.xml file in the Package Explorer. Opening the pom.xml file will render a graphical view on the canvas. Here, switch to the Dependencies tab and click the Add button as shown in the picture below.

Adding dependency to the client library - Step 1

Clicking the Add button will open a dialog where you need to specify PagarmeApiSDKLib in Group Id, pagarme-api-sdklib in Artifact Id and 6.8.1 in the Version fields. Once added click OK. Save the pom.xml file.

Adding dependency to the client library - Step 2

Adding sample code

3. Write sample code

Once the SimpleConsoleApp is created, a file named App.java will be visible in the Package Explorer with a main method. This is the entry point for the execution of the created project. Here, you can add code to initialize the client library and instantiate a Controller class. Sample code to initialize the client library and using controller methods is given in the subsequent sections.

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
serviceRefererName String
httpClientConfig ReadonlyHttpClientConfiguration Http Client Configuration instance.
basicAuthUserName String The username to use with basic authentication
basicAuthPassword String The password to use with basic authentication

The API client can be initialized as follows:

PagarmeApiSDKClient client = new PagarmeApiSDKClient.Builder()
    .httpClientConfig(configBuilder -> configBuilder
            .timeout(0))
    .serviceRefererName("ServiceRefererName")
    .basicAuthCredentials("BasicAuthUserName", "BasicAuthPassword")
    .build();

Authorization

This API uses Basic Authentication.

API Errors

Here is the list of errors that the API might throw.

HTTP Status Code Error Description Exception Class
400 Invalid request ErrorException
401 Invalid API key ErrorException
404 An informed resource was not found ErrorException
412 Business validation error ErrorException
422 Contract validation error ErrorException
500 Internal server error ErrorException

List of APIs

Classes Documentation

pagarme-java-sdk's People

Contributors

magnomoreira avatar jefersoncaugusto avatar robsonjunior1994 avatar grazielcosta avatar gusbedasi avatar andreals 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.