Categorygithub.com/gojuno/go-checkout
modulepackage
1.0.1
Repository: https://github.com/gojuno/go-checkout.git
Documentation: pkg.go.dev

# README

Checkout.com API client GoDoc Build Status Go Report Card

This repo contains Checkout.com API client written in Go.

Checkout.com API documentation: https://docs.checkout.com/v2.0/docs/integration-options

Before using this client you need to register an account.

How to install

Download package:

go get github.com/gojuno/go-checkout

Client uses github.com/pkg/errors, so you may need to download this package as well:

go get github.com/pkg/errors

Go modules are supported as well.

How to use

To init client you will need secret_key which you can get from your Checkout.com account profile.

import "github.com/gojuno/go-checkout"
...
// Init client
client := checkout.New(
	checkout.OptSecretKey("your_secret_key"),
)

// Create new payment
payment, err := client.Payment().Create(
	context.Background(),
	"payment_idempotency_key",
	&checkout.CreateParams{
        Source:   checkout.Source{
            Type: checkout.SourceTypeID,
            ID:   "src_vjkl7cyod4zejpkk5dwpvla7ca",
        },
        Amount:   2000,
        Currency: "USD",
	},
)

Custom HTTP client

By default client uses http.DefaultClient. You can set custom HTTP client using checkout.OptHTTPClient option:

httpClient := &http.Client{
	Timeout: time.Minute,
}

client := checkout.New(
	checkout.OptSecretKey("your_secret_key"),
	checkout.OptHTTPClient(httpClient),
)

You can use any HTTP client, implementing checkout.HTTPClient interface with method Do(r *http.Request) (*http.Response, error). Built-in net/http client implements it, of course.

Sandbox

Checkout.com supports sandbox and live environment. By default, client will use live endpoint. To use sandbox define sandbox endpoint when client is created.

client := checkout.New(
	checkout.OptSecretKey("your_secret_key"),
	checkout.OptEndpoint(checkout.EndpointSandbox),
)

# Functions

New creates new client with given options.
OptEndpoint returns option with given API endpoint.
OptHTTPClient returns option with given HTTP client.
OptSecretKey returns option with given secret key.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
Client contains API parameters and provides set of API entity clients.
No description provided by the author
No description provided by the author
ErrorResponse represents API error response.
No description provided by the author
PaymentClient is a client for work with Payment entity.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ServerError represents possible server error.
No description provided by the author
UnknownError represents possible unknown error.
No description provided by the author

# Interfaces

Caller makes HTTP call with given options and decode response into given struct.
HTTPClient is interface fot HTTP client.

# Type aliases

No description provided by the author
Option is a callback for redefine client parameters.
No description provided by the author
No description provided by the author
No description provided by the author