Pagarme API
The generated code uses the Newtonsoft Json.NET NuGet Package. If the automatic NuGet package restore is enabled, these dependencies will be installed automatically. Therefore, you will need internet access for build.
- Open the solution (PagarmeApiSDK.sln) file.
Invoke the build process using Ctrl + Shift + B shortcut key or using the Build menu as shown below.
The build process generates a portable class library, which can be used like a normal class library. The generated library is compatible with Windows Forms, Windows RT, Windows Phone 8, Silverlight 5, Xamarin iOS, Xamarin Android and Mono. More information on how to use can be found at the MSDN Portable Class Libraries documentation.
The following section explains how to use the PagarmeApiSDK.Standard library in a new project.
For starting a new project, right click on the current solution from the solution explorer and choose Add -> New Project
.
Next, choose Console Application
, provide TestConsoleProject
as the project name and click OK.
The new console project is the entry point for the eventual execution. This requires us to set the TestConsoleProject
as the start-up project. To do this, right-click on the TestConsoleProject
and choose Set as StartUp Project
form the context menu.
In order to use the Tester library in the new project, first we must add a project reference to the TestConsoleProject
. First, right click on the References
node in the solution explorer and click Add Reference...
Next, a window will be displayed where we must set the checkbox
on Tester.Tests
and click OK
. By doing this, we have added a reference of the Tester.Tests
project into the new TestConsoleProject
.
Once the TestConsoleProject
is created, a file named Program.cs
will be visible in the solution explorer with an empty Main
method. This is the entry point for the execution of the entire solution. Here, you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using Controller methods is given in the subsequent sections.
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
Parameter | Type | Description |
---|---|---|
Timeout |
TimeSpan |
Http client timeout. Default: TimeSpan.FromSeconds(100) |
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:
PagarmeApiSDK.Standard.PagarmeApiSDKClient client = new PagarmeApiSDK.Standard.PagarmeApiSDKClient.Builder().Build();
This API uses Basic Authentication
.
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 |