square-go-sdk

Square Go SDK helps you call square API easily

APACHE-2.0 License

Stars
1
Committers
2

Square Go SDK

Tags

go square

Installation

go install github.com/KoeInoue/square-go-sdk

or

import the package in a file where you want to use the package

import "github.com/KoeInoue/square-go-sdk"

then run

go mod tidy

Minimal Example

  1. Set environment variables
export SQUARE_ACCESS_TOKEN=yourSandboxAccessToken
export ENV=dev

※ ENV is a variable that just identifies the environment

  1. Write code
package main

import (
    "os"

    "github.com/KoeInoue/square-go-sdk"
    "github.com/KoeInoue/square-go-sdk/http"
    "github.com/KoeInoue/square-go-sdk/models"
)

func main() {
    client := getClient()
    client.CustomerApi.CreateCustomer()
}

func getClient() *http.Client {
    envType := os.Getenv("ENV")
    accessToken := os.Getenv("SQUARE_ACCESS_TOKEN")

    if envType != "production" {
        return http.NewClient(square.Config[square.Sandbox]{
            AccessToken: accessToken,
            Environment: square.Environments.Sandbox,
        })
    } else {
        return http.NewClient(square.Config[square.Production]{
            AccessToken: accessToken,
            Environment: square.Environments.Production,
        })
    }
}


SDK Reference

Payments

Subscriptions

Item

Customers

Contributors

Package Rankings
Top 9.05% on Proxy.golang.org
Badges
Extracted from project README
Go Test
Related Projects