coingate

package module
v0.0.0-...-6afb5ef Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2017 License: MIT Imports: 10 Imported by: 0

README

Coingate.com Go API client

GoDoc Go Report Card Build Status Coverage Status

Usage is very simple:

package main

import (
	"log"
	"github.com/chekalskiy/go-coingate"
)

func main() {
    Coingate := coingate.New(1234, "Key", "Secret", false)
    
    order, err := Coingate.CreateOrder(coingate.OrderRequest{
        Price: "10.00",
        Currency: "USD",
        ReceiveCurrency: "BTC",
    })
    
    if err != nil {
        log.Fatalln(err)
    }
    
    log.Println(order)
}

Callbacks

When order status is changing, Coingate sends you a callback on URL which you specified when created the order.

You can see here how to handle it. You can get CallbackData struct with callback data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallbackData

type CallbackData struct {
	ID              int       `json:"id"`
	OrderID         string    `json:"order_id"`
	Status          string    `json:"status"`
	Price           string    `json:"price"`
	Currency        string    `json:"currency"`
	ReceiveCurrency string    `json:"receive_currency"`
	ReceiveAmount   string    `json:"receive_amount"`
	BtcAmount       string    `json:"btc_amount"`
	CreatedAt       time.Time `json:"created_at"`
}

CallbackData is a struct of POST fields which we receive as a callback from Coingate

type Coingate

type Coingate struct {
	// contains filtered or unexported fields
}

Coingate main class

func New

func New(appID int, apiKey string, apiSecret string, isSandbox bool) *Coingate

New creates a new Coingate instance

It requires app data which you can get on https://coingate.com

func (*Coingate) CreateOrder

func (c *Coingate) CreateOrder(d CreateOrderRequest) (Order, error)

CreateOrder creates new order with specified params

func (*Coingate) GetOrder

func (c *Coingate) GetOrder(id int) (Order, error)

GetOrder gets information about order by it's id

func (*Coingate) ListOrders

func (c *Coingate) ListOrders(d ListOrdersRequest) (Orders, error)

ListOrders gets list of orders

func (*Coingate) Ping

func (c *Coingate) Ping() bool

Ping requests the ping endpoint

func (*Coingate) ProcessCallback

func (c *Coingate) ProcessCallback(r *http.Request) (CallbackData, error)

ProcessCallback gets a http.Request and parses POST fields to struct CallbackData

type CreateOrderRequest

type CreateOrderRequest struct {
	OrderID         string `json:"order_id"`
	Price           string `json:"price"`
	Currency        string `json:"currency"`
	ReceiveCurrency string `json:"receive_currency"`
	Title           string `json:"title"`
	Description     string `json:"description"`
	CallbackURL     string `json:"callback_url"`
	CancelURL       string `json:"cancel_url"`
	SuccessURL      string `json:"success_url"`
}

CreateOrderRequest is a struct with fields for creating order request

type ListOrdersRequest

type ListOrdersRequest struct {
	PerPage int    `json:"per_page"`
	Page    int    `json:"page"`
	Sort    string `json:"sort"`
}

ListOrdersRequest is a struct with GET parameters for ListOrders request

type Order

type Order struct {
	ID             int       `json:"id"`
	Currency       string    `json:"currency"`
	BitcoinURI     string    `json:"bitcoin_uri"`
	Status         string    `json:"status"`
	Price          string    `json:"price"`
	BtcAmount      string    `json:"btc_amount"`
	CreatedAt      time.Time `json:"created_at"`
	ExpireAt       time.Time `json:"expire_at"`
	BitcoinAddress string    `json:"bitcoin_address"`
	OrderID        string    `json:"order_id"`
	PaymentURL     string    `json:"payment_url"`
}

Order is The Order

type Orders

type Orders struct {
	CurrentPage int     `json:"current_page"`
	PerPage     int     `json:"per_page"`
	TotalOrders int     `json:"total_orders"`
	TotalPages  int     `json:"total_pages"`
	Orders      []Order `json:"orders"`
}

Orders is a list of orders

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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