Pagarme API
The SDK requires Go version 1.18 or above.
Resolve all the SDK dependencies, using the go get
command.
The following section explains how to use the pagarmeapisdk library in a new project.
- Add the following lines to your application's
go.mod
file:
replace pagarmeapisdk => ".\\PagarmeApiSDK" // local path to the SDK
require pagarmeapisdk v0.0.0
- Resolve the dependencies in the updated
go.mod
file, using thego get
command.
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
Parameter | Type | Description |
---|---|---|
serviceRefererName |
string |
|
httpConfiguration |
HttpConfiguration |
Configurable http client options like timeout and retries. |
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:
config := pagarmeapisdk.CreateConfiguration(
pagarmeapisdk.WithServiceRefererName("ServiceRefererName"),
pagarmeapisdk.WithHttpConfiguration(
pagarmeapisdk.CreateHttpConfiguration(
pagarmeapisdk.WithTimeout(0),
pagarmeapisdk.WithTransport(http.DefaultTransport),
pagarmeapisdk.WithRetryConfiguration(
pagarmeapisdk.CreateRetryConfiguration(
pagarmeapisdk.WithMaxRetryAttempts(0),
pagarmeapisdk.WithRetryOnTimeout(true),
pagarmeapisdk.WithRetryInterval(1),
pagarmeapisdk.WithMaximumRetryWaitTime(0),
pagarmeapisdk.WithBackoffFactor(2),
pagarmeapisdk.WithHttpStatusCodesToRetry([]int64{408, 413, 429, 500, 502, 503, 504, 521, 522, 524}),
pagarmeapisdk.WithHttpMethodsToRetry([]string{"GET", "PUT"}),
),
),
),
),
pagarmeapisdk.WithBasicAuthUserName("BasicAuthUserName"),
pagarmeapisdk.WithBasicAuthPassword("BasicAuthPassword"),
)
client := pagarmeapisdk.NewClient(config)
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 |