github.com/flaconi/go-klarna
go get github.com/flaconi/go-klarna

github.com/flaconi/go-klarna

GoLang Klarna client implementation

go get github.com/flaconi/go-klarna
Readme

go-klarna

Build Status Go Report Card GoDoc

About

This library is an implementation for Klarna payment API in go

How to use

Configuration

Config struct encapsulate the client needs of information

type Config struct {
    BaseURL     *url.URL
    APIUsername string
    APIPassword string
    Timeout     time.Duration
}

Client

Is the abstraction of HTTP client, required by each service in order to operate.

import (
        klarna "github.com/Flaconi/go-klarna"
        "net/url"
        "time"
)

func main() {
        uri, _ := url.Parse(klarna.EuroAPI)
        conf := klarna.Config{
                BaseURL:uri,
                Timeout: time.Second * 10,
        }
        client := klarna.NewClient(conf)
}

Now since we have an instance of the client, we can instantiate any service instance with this client ...

Service

Now, since we have a client, let's instantiate a service

import (
        // ...
)

func main() {
        // previous section ...
        client := klarna.NewClient(conf)

        // payment service
        paymentSrv := klarna.NewPaymentSrv(client)
        err := paymentSrv.CancelExistingAuthorization("string-token")
        if nil != err {
                // do something with the error
        }
}

Road map

  • Implement Checkout API service
  • Cover Checkout API service with tests
  • Implement Payment API service
  • Cover Payment API service with tests
  • Implement Order Management service
  • Cover Order Management service with tests
  • Implement Checkout API Callbacks service
  • Cover Checkout API Callbacks service with tests

GitHub Stars

11

LAST COMMIT

5yrs ago

MAINTAINERS

0

CONTRIBUTORS

4

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
v0.0.0-20170107103725-fa2c27ba2a33
3yrs ago
No alternatives found
No tutorials found
Add a tutorial