Giter Club home page Giter Club logo

go-btcpay's Introduction

Go-BTCPay

License: MIT testing

-- Work in progress --

A Golang SDK for the BTCPay Server Greenfield API v1.

๐Ÿ’ก About

This package provies full access to the Greenfield API v1 from a BTCPayServer. Every API call returns, if available, a corresponding go struct, a HTTP status code and an error.

It's possible to control the individual calls by passing a context for each function and method.

๐Ÿš€ Getting started

๐Ÿง‘โ€๐Ÿ’ป Create a client

You can create a client either by using basic authentication or by using an API Key.

package main

import (
    "context"
    "fmt"
    "github.com/jon4hz/go-btcpay"
)

func main() {
    // create empty context interface
    ctx := context.Background()

    // Create a basicAuth client
    client := btcpay.NewBasicClient("https://mybtcpayserver.com", "myUsername", "myPassword")

    // Print informations about the server, etc
    fmt.Println(client.GetServerInfo(ctx))

    // Does the same but with an APIKey instead of basicAuth
    // Create a client with an APIKey
    client2 := btcpay.NewClient("https://mybtcpayserver.com", btcpay.APIKey("myAPIKey")

    // Print informations about the server, etc again but use the APIKey based client
    fmt.Println(client2.GetServerInfo(ctx))
}

๐Ÿ“ Create an invoice

You can create an invoice by using the previously created client.

// assign a store to the client
client.Store.ID = btcpay.StoreID("YourStoreID")

// create the invoice
invoice, _, err := client.CreateInvoice(context.TODO(), &client.Store.ID, &btcpay.InvoiceRequest{
    Amount:   "10",
    Currency: "USD",
})
if err != nil {
   fmt.Println(err)
} else {
    fmt.Println(invoice) // invoice has type *btcpay.InvoiceResponse
}

Calling the method CreateInvoice() works for variable of type *btcpay.Store, too.

// by passing the store from the previously created client, the new store (*btcpay.Store) contains 
// a pointer  back to the initial client 
store = client.Store
// assign a storeID to the store
store.ID = btcpay.StoreID("YourStoreID")

// create the invoice
invoice, _, err := store.CreateInvoice(context.TODO(), &btcpay.InvoiceRequest{
    Amount:   "10",
    Currency: "USD",
})
if err != nil {
   fmt.Println(err)
} else {
    fmt.Println(invoice) // invoice has type *btcpay.InvoiceResponse
}

[more examples will follow soon]

initialented endpoints.

Endpoint Status
/api/v1/api-keys โœ… Fully implemented
/api-keys/authorize โšก๏ธ Testing required
/api/v1/health โœ… Fully implemented
/api/v1/server/info โœ… Fully implemented
/api/v1/users โœ… Fully implemented
/api/v1/users/me/notifications โœ… Fully implemented
/api/v1/stores โš ๏ธ Partially implemented
/api/v1/stores/{storeId}/invoices โœ… Fully implemented
/api/v1/stores/{storeId}/payment-requests โœ… Fully implemented
/api/v1/stores/{storeId}/pull-payments โœ… Fully implemented
/api/v1/stores/{storeId}/payment-methods/OnChain/{cryptoCode}/wallet โณ Work in progress
/misc/lang โœ… Fully implemented
/i โœ… Fully implemented
/api/v1/pull-payments โœ… Fully implemented

๐Ÿ“œ Licensing

This SDK is released under the MIT-License found in the LICENSE file.

go-btcpay's People

Contributors

jon4hz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.