Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.19 KB

README.md

File metadata and controls

51 lines (39 loc) · 1.19 KB

merchant-go-stone-openbank

A forked Go library of go-stone-openbank to connect Stone Open Banking API

How to install

go get github.com/stone-payments/merchant-go-stone-openbank

Example Usage

package main

import (
	openbank "github.com/stone-payments/merchant-go-stone-openbank"
	"github.com/stone-payments/merchant-go-stone-openbank/types"
)

func main() {
	clientID := os.Getenv("STONE_CLIENT_ID")
	privKeyPath := os.Getenv("STONE_PRIVATE_KEY")
	consentURL := os.Getenv("STONE_CONSENT_REDIRECT_URL")

	pemPrivKey := readFileContent(privKeyPath)

	client, err := openbank.NewClient(
		openbank.WithClientID(clientID),
		openbank.SetConsentURL(consentURL),
		openbank.WithPEMPrivateKey(pemPrivKey),
		openbank.UseSandbox(),
	//	openbank.EnableDebug(),
	)
	if err != nil {
		log.Fatal(err)
	}

	err := client.Authenticate(context.Background())
	if err != nil {
		log.Fatal(err)
	}
}

func readFileContent(path string) []byte {
	content, _ := ioutil.ReadFile(path)
	return content
}

see full example