bitpay

command module
v0.0.0-...-1a525eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2014 License: MIT Imports: 7 Imported by: 0

README

#Bitpay

Bitpay command line tool and REST API client for Go https://bitpay.com/api

GoDoc

Status

Currently, not all endpoints are working yet and the request signing seems to be rejected by the API. The new Bitpay API version 2.0.0 is lacking in documentation and the example libraries (PHP, Ruby, Nodejs) also don't work. Hopefully it will be fixed soon by the Bitpay team.

Installation

go get github.com/fundary/bitpay

Usage

Command line tool

The command line tool enable generating and managing client IDs and tokens. To see all the commands and option, run:

bitpay help

For example, to create a new token, run:

bitpay new-token "Label for the token" TfLgB8tzxxwsefunU3Ec8cjt81bJuvYxX1P merchant --env=test

Go package

The Go client package can be imported and used directly. First generate keys and token using the command line tool. Then pass it to your application.

package main

import(
	"github.com/fundary/bitpay/client"
)

func main() {
	privateKey := os.Getenv("BITPAY_PRIVATE_KEY")
	if privateKey == "" {
		panic("Bitpay private key is missing")
	}

	token := os.Getenv("BITPAY_TOKEN")
	if token == "" {
		panic("Bitpay token is missing")
	}

	bitpay = NewClientWithAuth(
		privateKey,
		token,
		APIBaseTest,
	)

	// Get rates
	rates, resp, err := bitpay.QueryRates()

	// Create invoice
	invoice, _, err := bitpay.CreateInvoice(Invoice{
		Price:             100,
		Currency:          "USD",
		NotificationURL: 'http://your-ipn-server'
	})
	if err != nil {
		panic(err)
	}
	log.Println("Invoice ID", invoice.ID)
}

TODO

  • Make all tests pass
  • Use sessions
  • Allow persisting generated keys and folders to encrypted files

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package bitpay provides a Go client for the Bitpay REST API Docs: https://bitpay.com/api
Package bitpay provides a Go client for the Bitpay REST API Docs: https://bitpay.com/api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL