Documentation ¶
Overview ¶
Package bitpay provides a Go client for the Bitpay REST API
Docs: https://bitpay.com/api
Index ¶
- Constants
- Variables
- type Application
- type ApplicationOrg
- type ApplicationUser
- type Bill
- type BillItem
- type BitpayClient
- type Buyer
- type Client
- func (c *Client) AcceptInvoiceAdjustment(invoiceID string, adjustment InvoiceAdjustment) (*http.Response, error)
- func (c *Client) ClaimToken(label, clientID, pairingCode string) (TokenResp, error)
- func (c *Client) CreateApplication(a Application) (*http.Response, error)
- func (c *Client) CreateBill(b Bill) (*http.Response, error)
- func (c *Client) CreateInvoice(i Invoice) (*http.Response, error)
- func (c *Client) CreateInvoiceNotification(invoiceID string) (*http.Response, error)
- func (c *Client) CreateInvoiceRefund(invoiceID string, r InvoiceRefund) (*http.Response, error)
- func (c *Client) CreatePayout(p Payout) (*http.Response, error)
- func (c *Client) CreatePayoutsReports() (*http.Response, error)
- func (c *Client) CreateSession() (Session, *http.Response, error)
- func (c *Client) DeleteInvoiceRefund(invoiceID, refundID string) (*http.Response, error)
- func (c *Client) DeletePayout(payoutID string) (*http.Response, error)
- func (c *Client) GetBill(ID string) (*Bill, *http.Response, error)
- func (c *Client) GetInvoice(ID string) (*Invoice, *http.Response, error)
- func (c *Client) GetInvoiceEvents(ID string) (*EventResp, *http.Response, error)
- func (c *Client) GetPayout(ID string) (*Payout, *http.Response, error)
- func (c *Client) GetRateForCurrency(currencyCode string) (*Rate, *http.Response, error)
- func (c *Client) GetUser() (*User, *http.Response, error)
- func (c *Client) NewRequest(method, url string, payload interface{}) (*http.Request, error)
- func (c *Client) NewRequestWithAuth(method, endpoint string, payload interface{}) (*http.Request, error)
- func (c *Client) NewToken(label, clientID string, facade Facade) (TokenResp, error)
- func (c *Client) QueryBills() ([]Bill, *http.Response, error)
- func (c *Client) QueryCurrencies() ([]Currency, *http.Response, error)
- func (c *Client) QueryInvoices() ([]Invoice, *http.Response, error)
- func (c *Client) QueryPayouts() ([]Payout, *http.Response, error)
- func (c *Client) QueryRates() ([]Rate, *http.Response, error)
- func (c *Client) Send(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) UpdateBill(b Bill) (*http.Response, error)
- func (c *Client) UpdatePayout(p Payout) (*http.Response, error)
- func (c *Client) UpdateUser(u User) (*User, *http.Response, error)
- type Currency
- type EventResp
- type Facade
- type Instruction
- type Invoice
- type InvoiceAdjustment
- type InvoiceRefund
- type Payout
- type Policy
- type Rate
- type Response
- type Session
- type TokenResp
- type User
Constants ¶
const ( // APIBaseSandBox points to the sandbox (for testing) version of the API APIBaseTest = "https://test.bitpay.com" // APIBaseLive points to the live version of the API APIBaseProd = "https://bitpay.com" )
Variables ¶
var ( // Debug is a flag to enable/disable debug messages Debug bool FacadePublic Facade = "public" FacadePOS Facade = "pos" FacadeMerchant Facade = "merchant" )
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { Users []ApplicationUser `json:"users"` Orgs []ApplicationOrg `json:"orgs"` }
Application maps to a resource at the applications endpoint
type ApplicationOrg ¶
type ApplicationOrg struct { Name string `json:"name"` Address1 string `json:"address1"` Address2 string `json:"address2"` City string `json:"city"` State string `json:"state"` Zip string `json:"zip"` Country string `json:"country"` IsNonProfit bool `json:"isNonProfit,omitempty"` USTaxID string `json:"usTaxId,omitempty"` Industry string `json:"industry"` Website string `json:"website"` CartPOS string `json:"cartPos,omitempty"` AffiliateOID string `json:"affiliateOid,omitempty"` }
type ApplicationUser ¶
type Bill ¶
type Bill struct { ID string `json:"id,omitempty"` Items []BillItem `json:"items"` Currency string `json:"currency,omitempty"` ShowRate string `json:"showRate,omitempty"` Archived string `json:"archived,omitempty"` Name string `json:"name,omitempty"` Address1 string `json:"address1,omitempty"` Address2 string `json:"address2,omitempty"` City string `json:"city,omitempty"` State string `json:"state,omitempty"` Zip string `json:"zip,omitempty"` Country string `json:"country,omitempty"` Email string `json:"email,omitempty"` Phone string `json:"phone,omitempty"` }
Bill maps to a resource at the bills endpoint
type BillItem ¶
type BillItem struct { Description string `json:"description"` Price int64 `json:"price"` Quantity int64 `json:"quantity"` }
BillItem maps to an entry in the items array of Bill
type BitpayClient ¶
BitpayClient maps to a resource in clients endpoint
type Buyer ¶
type Buyer struct { Name string `json:"name,omitempty"` Address1 string `json:"address1,omitempty"` Address2 string `json:"address2,omitempty"` Locality string `json:"locality,omitempty"` Region string `json:"region,omitempty"` PostalCode string `json:"postalCode,omitempty"` Country string `json:"country,omitempty"` Email string `json:"email,omitempty"` Phone string `json:"phone,omitempty"` }
Buyer maps to the buyer object in an Invoice
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Bitpay REST API Client
func NewClientWithAuth ¶
NewClientWithAuth returns a new client with keys and SIN
func (*Client) AcceptInvoiceAdjustment ¶
func (c *Client) AcceptInvoiceAdjustment(invoiceID string, adjustment InvoiceAdjustment) (*http.Response, error)
AcceptInvoiceAdjustment accepts the overpayment or underpayment for the invoice.
func (*Client) ClaimToken ¶
ClaimToken claims a generated token by using pairing code
func (*Client) CreateApplication ¶
func (c *Client) CreateApplication(a Application) (*http.Response, error)
CreateApplication creates an application for a new merchant account
func (*Client) CreateBill ¶
CreateBill creates a bill for the calling merchant
func (*Client) CreateInvoice ¶
CreateInvoice creates an invoice for the calling merchant
func (*Client) CreateInvoiceNotification ¶
CreateInvoiceNotification resends the IPN for the specified invoice
func (*Client) CreateInvoiceRefund ¶
CreateInvoiceRefund creates a refund request for a given invoice
func (*Client) CreatePayout ¶
CreatePayout creates a payout batch request.
func (*Client) CreatePayoutsReports ¶
CreatePayoutsReports creates and returns a payout request report TODO: implement
func (*Client) CreateSession ¶
CreateSession creates an API session to protect against replay attacks and ensure requests are received in the same order they are sent.
func (*Client) DeleteInvoiceRefund ¶
DeleteInvoiceRefund cancels a pending refund request
func (*Client) DeletePayout ¶
DeletePayout cancels the given payout request if status is still new.
func (*Client) GetInvoice ¶
GetInvoice returns the specified invoice by ID for the calling merchant
func (*Client) GetInvoiceEvents ¶
GetInvoiceEvents returns a bus token which can be used to subscribe to invoice events
func (*Client) GetRateForCurrency ¶
GetRateForCurrency returns the exchange rate for a given currency.
func (*Client) NewRequest ¶
NewRequest constructs a request. If payload is not empty, it will be marshalled into JSON
func (*Client) NewRequestWithAuth ¶
func (c *Client) NewRequestWithAuth(method, endpoint string, payload interface{}) (*http.Request, error)
NewRequestWithAuth constructs a request. Will do the following things: 1. If payload is not empty, it will be marshalled into JSON. 2. Applies signing and auth headers. 3. Add token and guid to the body
func (*Client) QueryBills ¶
QueryBills returns all of the caller's bills.
func (*Client) QueryCurrencies ¶
QueryCurrencies returns the list of supported currencies.
func (*Client) QueryInvoices ¶
QueryInvoices returns invoices for the calling merchant filtered by query.
func (*Client) QueryPayouts ¶
QueryPayouts returns all of the caller's payout requests by status
func (*Client) QueryRates ¶
QueryRates returns a list of exchange rates.
func (*Client) Send ¶
Send makes a request to the API, the response body will be unmarshaled into v, or if v is an io.Writer, the response will be written to it without decoding
func (*Client) UpdateBill ¶
UpdateBill updates a specified bill by ID
func (*Client) UpdatePayout ¶
UpdatePayout sets the rate for a payout request and/or mark as funded. TODO: Reimplement
type Currency ¶
type Currency struct { Code string `json:"code"` Symbol string `json:"symbol"` Precision int `json:"precision"` ExchangePCTFee int64 `json:"exchangePctFee"` PayoutEnabled bool `json:"payoutEnabled"` Name string `json:"name"` Plural string `json:"plural"` Alts string `json:"alts"` PayoutFields []string `json:"payoutFields"` }
Currency maps to a resource at the currencies endpoint
type EventResp ¶
type EventResp struct { URL string `json:"url"` Token string `json:"token"` Events []string `json:"events"` Actions []string `json:"actions"` }
EventResp maps to the response from the GET /invoices/:invoiceId/events
type Facade ¶
type Facade string
Facade is a named collection of capabilitites https://test.bitpay.com/api#facades
type Instruction ¶
type Instruction struct { Amount int64 `json:"amount"` Address string `json:"address"` Label string `json:"label"` }
Instruction maps to an item in Instructions field of Payout
type Invoice ¶
type Invoice struct { ID string `json:"id,omitempty"` Price int64 `json:"price"` Currency string `json:"currency"` OrderID string `json:"orderID,omitempty"` ItemDesc string `json:"itemDesc,omitempty"` ItemCode string `json:"itemCode,omitempty"` NotificationEmail string `json:"notificationEmail,omitempty"` NotificationURL string `json:"notificationURL,omitempty"` RedirectURL string `json:"redirectURL,omitempty"` POSData string `json:"posData,omitempty"` TransactionSpeed string `json:"transactionSpeed,omitempty"` FullNotifications string `json:"fullNotifications,omitempty"` Physical string `json:"physical,omitempty"` Buyer Buyer `json:"buyer,omitempty"` }
Invoice maps to a resource at the invoices endpoint
type InvoiceAdjustment ¶
type InvoiceAdjustment string
InvoiceAdjustment is used when accepting the overpayment or underpayment for an invoice.
var ( InvoiceAdjustmentAcceptUnderpayment InvoiceAdjustment = "acceptUnderpayment" InvoiceAdjustmentAcceptOverpayment InvoiceAdjustment = "acceptOverpayment" )
type InvoiceRefund ¶
type InvoiceRefund struct { RequestID string `json:"requestID,omitempty"` BitcoinAddress string `json:"bitcoinAddress,omitempty"` Amount int64 `json:"amount,omitempty"` Currency string `json:"currency,omitempty"` }
InvoiceRefund maps to a resource at the invoice refunds endpoint
type Payout ¶
type Payout struct { Instructions []Instruction `json:"instructions"` Amount int64 `json:"amount"` Currency string `json:"currency"` EffectiveDate time.Time `json:"effectiveDate"` Reference string `json:"reference,omitemtpy"` PricingMethod string `json:"pricingMethod,omitempty"` NotificationEmail string `json:"notificationEmail,omitempty"` NotificationURL string `json:"notificationURL,omitempty"` }
Payout maps to a resource at the payouts endpoint
type Response ¶
type Response struct { Error string `json:"error"` Data json.RawMessage `json:"data"` }
Response represents a response from Bitpay API, it contains either an error or data