client

package
v2.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2015 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

The client package provides convenience methods for authenticating with Bitpay and creating basic invoices.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Pem      string
	ApiUri   string
	Insecure bool
	ClientId string
	Token    Token
}

The Client struct maintains the state of the current client. To use a client from session to session, the Pem and Token will need to be saved and used in the next client. The ClientId can be recreated by using the key_util.GenerateSinFromPem func, and the ApiUri will generally be https://bitpay.com. Insecure should generally be set to false or not set at all, there are a limited number of test scenarios in which it must be set to true.

func (*Client) CreateInvoice

func (client *Client) CreateInvoice(price float64, currency string) (inv invoice, err error)

CreateInvoice returns an invoice type or pass the error from the server. The method will create an invoice on the BitPay server.

func (*Client) GetInvoice

func (client *Client) GetInvoice(invId string) (inv invoice, err error)

GetInvoice is a public facade method, any client which has the ApiUri field set can retrieve an invoice from that endpoint, provided they have the invoice id.

func (*Client) GetToken

func (client *Client) GetToken(facade string) (token string, err error)

func (*Client) GetTokens

func (client *Client) GetTokens() (tokes []map[string]string, err error)

func (*Client) PairClient

func (client *Client) PairClient(paylo map[string]string) (tok Token, err error)

func (*Client) PairWithCode

func (client *Client) PairWithCode(str string) (tok Token, err error)

PairWithCode retrieves a token from the server and authenticates the keys of the calling client. The string passed to the client is a "pairing code" that must be retrieved from https://bitpay.com/dashboard/merchant/api-tokens. PairWithCode returns a Token type that must be assigned to the Token field of a client in order for that client to create invoices. For example `client.Token = client.PairWithCode("abcdefg")`.

func (*Client) PairWithFacade

func (client *Client) PairWithFacade(str string) (tok Token, err error)

PairWithFacade

func (*Client) Post

func (client *Client) Post(path string, paylo map[string]string) (response *http.Response, err error)

type Token

type Token struct {
	Token             string
	Facade            string
	DateCreated       float64
	PairingExpiration float64
	Resource          string
	PairingCode       string
}

The Token struct is a go mapping of a subset of the JSON returned from the server with a request to authenticate (pair).

Jump to

Keyboard shortcuts

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