Skip to content
This repository has been archived by the owner on Feb 18, 2023. It is now read-only.

Latest commit

 

History

History
78 lines (61 loc) · 1.98 KB

README.md

File metadata and controls

78 lines (61 loc) · 1.98 KB

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