Documentation
¶
Overview ¶
Package sumup is a production-grade, fully-typed Go client for the SumUp API (https://developer.sumup.com/api).
Structure ¶
The SDK is organized by domain, one bounded context per subpackage: checkouts, customers, paymentinstruments, transactions, payouts, receipts, members, memberships, roles, merchants, and webhooks. This package is the composition root — it owns the shared HTTP engine and wires up one Service per domain package, exposed as a field on Client.
Quick start ¶
client, err := sumup.NewClient(sumup.WithAPIKey(os.Getenv("SUMUP_API_KEY")))
if err != nil {
log.Fatal(err)
}
checkout, err := client.Checkouts.Create(ctx, checkouts.CreateCheckoutParams{
CheckoutReference: "order-1234",
Amount: 10.50,
Currency: "EUR",
MerchantCode: "MC12345",
})
Every resource is exposed as a field on Client (Checkouts, Readers, Customers, ...), typed to its own domain package. Every method takes a context.Context as its first argument and returns a plain Go error — use errors.As to recover a typed *Error for API/transport failures, or a *ValidationError for arguments that failed local validation before any request was sent.
Index ¶
- Constants
- Variables
- type Client
- type Error
- type ErrorSource
- type FloatMoney
- type MinorUnitMoney
- type Option
- func WithAPIKey(key string) Option
- func WithAccessToken(token string) Option
- func WithBaseURL(baseURL string) Option
- func WithHTTPClient(httpClient *http.Client) Option
- func WithHeader(key, value string) Option
- func WithMaxRetries(n int) Option
- func WithReceiveTimeout(d time.Duration) Option
- func WithRetryBaseDelay(d time.Duration) Option
- func WithRetryMaxDelay(d time.Duration) Option
- func WithUserAgent(userAgent string) Option
- type RequestErrorInfo
- type RequestInfo
- type RequestRetryInfo
- type RequestSuccessInfo
- type Trace
- type ValidationError
Constants ¶
const ( ErrorSourceUnknown = apierror.ErrorSourceUnknown ErrorSourceProblem = apierror.ErrorSourceProblem ErrorSourceLegacy = apierror.ErrorSourceLegacy ErrorSourceLegacyList = apierror.ErrorSourceLegacyList ErrorSourceTransport = apierror.ErrorSourceTransport )
ErrorSource values. See the equivalent constants in apierror.
Variables ¶
var ExponentFor = money.ExponentFor
ExponentFor returns the ISO 4217 decimal exponent for a currency code. See money.ExponentFor.
var IsZeroDecimalCurrency = money.IsZeroDecimalCurrency
IsZeroDecimalCurrency reports whether a currency has no minor unit (e.g. JPY, KRW).
var NewMinorUnitMoneyFromDecimal = money.NewMinorUnitMoneyFromDecimal
NewMinorUnitMoneyFromDecimal builds a MinorUnitMoney from a major-unit decimal amount.
var WithTrace = tracing.WithTrace
WithTrace attaches a Trace to ctx; every client method called with the resulting context reports its lifecycle events to trace's callbacks. See tracing.WithTrace.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Checkouts *checkouts.Service
Readers *readers.Service
Customers *customers.Service
PaymentInstruments *paymentinstruments.Service
Transactions *transactions.Service
Payouts *payouts.Service
Receipts *receipts.Service
Members *members.Service
Memberships *memberships.Service
Roles *roles.Service
Merchants *merchants.Service
Webhooks *webhooks.Service
// contains filtered or unexported fields
}
Client is the main entry point for the SumUp SDK. Construct one per credential set with NewClient and reuse it — it is safe for concurrent use by multiple goroutines.
func NewClient ¶
NewClient builds a Client. Requires exactly one of WithAPIKey or WithAccessToken.
type Error ¶
Error is the normalized SumUp API/transport error type. See apierror.Error.
type ErrorSource ¶
type ErrorSource = apierror.ErrorSource
ErrorSource identifies which of SumUp's response shapes an Error was decoded from. See apierror.ErrorSource.
type FloatMoney ¶
type FloatMoney = money.FloatMoney
FloatMoney is SumUp's legacy major-unit money shape. See money.FloatMoney.
type MinorUnitMoney ¶
type MinorUnitMoney = money.MinorUnitMoney
MinorUnitMoney is SumUp's minor-unit money shape, used by Readers. See money.MinorUnitMoney.
type Option ¶
type Option func(*clientConfig) error
Option configures a Client. Pass one or more to NewClient.
func WithAPIKey ¶
WithAPIKey sets the SumUp secret API key (sk_live_... / sk_test_...), or a restricted key. Mutually exclusive with WithAccessToken — if both are given, the one applied last wins.
func WithAccessToken ¶
WithAccessToken sets an OAuth2 access token, as an alternative to WithAPIKey.
func WithBaseURL ¶
WithBaseURL overrides the API base URL. Useful for testing against a mock server.
func WithHTTPClient ¶
WithHTTPClient supplies a custom *http.Client (e.g. one with a custom Transport for proxying, mTLS, or test interception). Its Timeout is left untouched by this package — set WithReceiveTimeout to control the per-request timeout that this package applies via context, or set Timeout on the client yourself.
func WithHeader ¶
WithHeader adds an extra header sent with every request.
func WithMaxRetries ¶
WithMaxRetries sets the max retry attempts for retryable errors (429 and 5xx, and transport failures). Default: 3. Pass 0 to disable retries.
func WithReceiveTimeout ¶
WithReceiveTimeout sets the per-request timeout applied via context. Default: 30s.
func WithRetryBaseDelay ¶
WithRetryBaseDelay sets the base delay for exponential backoff (doubles per attempt, with jitter). Default: 250ms.
func WithRetryMaxDelay ¶
WithRetryMaxDelay sets the maximum backoff delay. Default: 5s.
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header.
type RequestErrorInfo ¶
type RequestErrorInfo = tracing.RequestErrorInfo
RequestErrorInfo is passed to [Trace.OnRequestError]. See tracing.RequestErrorInfo.
type RequestInfo ¶
type RequestInfo = tracing.RequestInfo
RequestInfo carries metadata common to every trace event. See tracing.RequestInfo.
type RequestRetryInfo ¶
type RequestRetryInfo = tracing.RequestRetryInfo
RequestRetryInfo is passed to [Trace.OnRequestRetry]. See tracing.RequestRetryInfo.
type RequestSuccessInfo ¶
type RequestSuccessInfo = tracing.RequestSuccessInfo
RequestSuccessInfo is passed to [Trace.OnRequestSuccess]. See tracing.RequestSuccessInfo.
type ValidationError ¶
type ValidationError = apierror.ValidationError
ValidationError is returned when caller-supplied parameters fail local validation before any request is sent. See apierror.ValidationError.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package apierror holds the normalized error types returned by every resource in the SumUp SDK (Error and ValidationError), plus the decoding logic that builds an Error from an HTTP response or a transport-level failure.
|
Package apierror holds the normalized error types returned by every resource in the SumUp SDK (Error and ValidationError), plus the decoding logic that builds an Error from an HTTP response or a transport-level failure. |
|
Package checkouts handles the Checkouts resource: create a payment intent, then process it with a card, saved token, or an alternative payment method (Boleto, iDEAL, Bancontact, Blik, Google Pay, Apple Pay).
|
Package checkouts handles the Checkouts resource: create a payment intent, then process it with a card, saved token, or an alternative payment method (Boleto, iDEAL, Bancontact, Blik, Google Pay, Apple Pay). |
|
Package customers handles the Customers resource: a lightweight vault for storing payer identity and reusable payment instruments.
|
Package customers handles the Customers resource: a lightweight vault for storing payer identity and reusable payment instruments. |
|
internal
|
|
|
decode
Package decode provides small, panic-free type assertion helpers for pulling typed Go values out of a loosely-typed map[string]any decoded from a JSON response body.
|
Package decode provides small, panic-free type assertion helpers for pulling typed Go values out of a loosely-typed map[string]any decoded from a JSON response body. |
|
transport
Package transport is the low-level HTTP engine behind every domain package's Service: it owns the *http.Client, base URL, auth header, and retry policy, and turns a RequestParams into a RequestResult or a normalized apierror.Error, reporting lifecycle events to any tracing.Trace attached to the request context.
|
Package transport is the low-level HTTP engine behind every domain package's Service: it owns the *http.Client, base URL, auth header, and retry policy, and turns a RequestParams into a RequestResult or a normalized apierror.Error, reporting lifecycle events to any tracing.Trace attached to the request context. |
|
transporttest
Package transporttest provides a small httptest-backed harness for exercising a transport.Client (and, by extension, any domain package's Service) against a fake server, without pulling in the root sumup package.
|
Package transporttest provides a small httptest-backed harness for exercising a transport.Client (and, by extension, any domain package's Service) against a fake server, without pulling in the root sumup package. |
|
validation
Package validation provides small parameter-validation helpers shared by every domain package's Params.validate methods.
|
Package validation provides small parameter-validation helpers shared by every domain package's Params.validate methods. |
|
wire
Package wire provides small helpers for building outgoing request bodies and query strings, used by every domain package's Params.wire and Params.query methods.
|
Package wire provides small helpers for building outgoing request bodies and query strings, used by every domain package's Params.wire and Params.query methods. |
|
Package members handles the Members resource: user accounts under a merchant, including virtual/managed users.
|
Package members handles the Members resource: user accounts under a merchant, including virtual/managed users. |
|
Package memberships handles the Memberships resource: lists the currently authenticated user's memberships across merchants/organizations, optionally filtered by resource type, role, status, or parent.
|
Package memberships handles the Memberships resource: lists the currently authenticated user's memberships across merchants/organizations, optionally filtered by resource type, role, status, or parent. |
|
Package merchants handles the Merchants resource: legal entity and KYC profile data.
|
Package merchants handles the Merchants resource: legal entity and KYC profile data. |
|
Package money holds the two money value objects used across SumUp's API — FloatMoney (legacy major-unit decimal amounts) and MinorUnitMoney (the newer, numerically-safe minor-unit representation) — plus currency-exponent helpers shared by every domain package that decodes or encodes an amount.
|
Package money holds the two money value objects used across SumUp's API — FloatMoney (legacy major-unit decimal amounts) and MinorUnitMoney (the newer, numerically-safe minor-unit representation) — plus currency-exponent helpers shared by every domain package that decodes or encodes an amount. |
|
Package pagination provides the generic, range-over-func pagination primitive (Paginate) that every domain package's ListAll-style method (e.g.
|
Package pagination provides the generic, range-over-func pagination primitive (Paginate) that every domain package's ListAll-style method (e.g. |
|
Package paymentinstruments handles the Payment Instruments resource: tokenized cards saved against a customer, created as a side effect of a checkouts.Service.Process call with Purpose "SETUP_RECURRING_PAYMENT" (or a regular charge that opts to save the method).
|
Package paymentinstruments handles the Payment Instruments resource: tokenized cards saved against a customer, created as a side effect of a checkouts.Service.Process call with Purpose "SETUP_RECURRING_PAYMENT" (or a regular charge that opts to save the method). |
|
Package payouts handles the Payouts resource: a date-ranged report of funds settled to (or deducted from) a merchant's bank account.
|
Package payouts handles the Payouts resource: a date-ranged report of funds settled to (or deducted from) a merchant's bank account. |
|
Package readers handles the Readers resource: pair, manage, and push payments to physical SumUp Solo card readers.
|
Package readers handles the Readers resource: pair, manage, and push payments to physical SumUp Solo card readers. |
|
Package receipts handles the Receipts resource: a detailed, receipt-formatted view of a transaction, keyed by transaction id plus the merchant id (MID).
|
Package receipts handles the Receipts resource: a detailed, receipt-formatted view of a transaction, keyed by transaction id plus the merchant id (MID). |
|
Package roles handles the Roles resource: role definitions (built-in and custom) grouping permissions, assignable to Members.
|
Package roles handles the Roles resource: role definitions (built-in and custom) grouping permissions, assignable to Members. |
|
Package shared holds small value objects that cross bounded-context boundaries — used by more than one domain package — so that neither domain package needs to import the other just to share a struct shape.
|
Package shared holds small value objects that cross bounded-context boundaries — used by more than one domain package — so that neither domain package needs to import the other just to share a struct shape. |
|
Package tracing provides request-lifecycle observability hooks (Trace) that the internal transport layer reports to, attached to a context with WithTrace.
|
Package tracing provides request-lifecycle observability hooks (Trace) that the internal transport layer reports to, attached to a context with WithTrace. |
|
Package transactions handles the Transactions resource: read-heavy history and lookup endpoints (API version v2.1), plus refunds (API version v1.0).
|
Package transactions handles the Transactions resource: read-heavy history and lookup endpoints (API version v2.1), plus refunds (API version v1.0). |
|
Package webhooks handles SumUp's online-payments webhooks.
|
Package webhooks handles SumUp's online-payments webhooks. |