code-payments / code-sdk-go

Golang port of the code-sdk core library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code SDK - Go

Code SDK - Go

Release PkgGoDev Tests GitHub License

The Code Golang SDK is a module that allows Go developers to integrate Code into their applications. Seamlessly start accepting payments with minimal setup and just a few lines of code.

See the documentation for more details.

What is Code?

Code is a mobile wallet app leveraging self-custodial blockchain technology to provide an instant, global, and private payments experience.

Installation

You can install the Code Golang SDK using to Go toolset:

go get github.com/code-payments/code-sdk-go

Usage

Here's a simple example showcasing how to create a payment intent using the Golang SDK:

package main

import (
	"context"
	"log"

	codesdk "github.com/code-payments/code-sdk-go/sdk"
)

func check(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	ctx := context.Background()

	// Setup the Code web client
	client := codesdk.NewWebClient()

	// Specify payment request details
	intent, err := codesdk.NewPaymentRequestIntent(
		// Or the string "usd"
		codesdk.USD,
		// Minimum amount is $0.05 USD
		0.05,
		// Code Deposit Address or any Kin token account
		"E8otxw1CVX9bfyddKu3ZB3BVLa4VVF9J7CTPdnUwT9jR",
	)
	check(err)

	// Create a payment request intent
	_, err = client.CreatePaymentRequest(ctx, intent)
	check(err)

	// Check the intent status
	_, err = client.GetIntentStatus(ctx, intent.GetIntentId())
	check(err)
}

Getting Help

If you have any questions or need help integrating Code into your website or application, please reach out to us on Discord or Twitter.

Contributing

For now the best way to contribute is to share feedback on Discord. This will evolve as we continue to build out the platform and open up more ways to contribute.

About

Golang port of the code-sdk core library

License:MIT License


Languages

Language:Go 92.5%Language:HTML 4.7%Language:Makefile 2.3%Language:Dockerfile 0.4%