shopline

package module
v0.0.0-...-7e9db1a Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2017 License: MIT Imports: 14 Imported by: 0

README

go-shopline

Itau shopline for Google Go.

Install

go get github.com/gabstv/go-shopline

Examples

Get Bank Redirect Page
import(
	"github.com/gabstv/go-shopline"
)

func main(){
	ws := shopline.New("COD_EMP", "KEY")

	boleto := shopline.BoletoDef{}
	boleto.Observacao = "3"
	boleto.Obs1 = "NAO ACEITAR APOS O VENCIMENTO"
	boleto.Obs2 = "NUMERO DO ORCAMENTO: 12"
	boleto.NomeCliente = "Teste"
	boleto.CodigoInscricao = shopline.CPF
	boleto.NumeroInscricao = "45918713638"
	boleto.Endereco = "Praca da Se"
	boleto.Bairro = "Centro"
	boleto.CEP = "00001000"
	boleto.Cidade = "Sao Paulo"
	boleto.Estado = "SP"
	boleto.Vencimento = time.Now().AddDate(0, 0, 4)
	boleto.URL_Retorno = ""
	boleto.Pedido = 123456
	boleto.Valor = 3.5
	htmlstring, err := ws.GetBoletoRedirectHTML(boleto)
	if err != nil {
		print(err.Error()+"\n")
		return
	}
	print(htmlstring+"\n")
}
Get Boleto PDF
import(
	"github.com/gabstv/go-shopline"
	"fmt"
)

func main(){
	ws := shopline.New("COD_EMP", "KEY")

	boleto := shopline.BoletoDef{}
	boleto.Observacao = "3"
	boleto.Obs1 = "NAO ACEITAR APOS O VENCIMENTO"
	boleto.Obs2 = "NUMERO DO ORCAMENTO: 12"
	boleto.NomeCliente = "Teste"
	boleto.CodigoInscricao = shopline.CPF
	boleto.NumeroInscricao = "45918713638"
	boleto.Endereco = "Praca da Se"
	boleto.Bairro = "Centro"
	boleto.CEP = "00001000"
	boleto.Cidade = "Sao Paulo"
	boleto.Estado = "SP"
	boleto.Vencimento = time.Now().AddDate(0, 0, 4)
	boleto.URL_Retorno = ""
	boleto.Pedido = 123456
	boleto.Valor = 3.5
	boletopdf, err := ws.GetBoletoPDF(boleto, "https://www.example.com")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println("Boleto bytes:", boletopdf)
}

Documentation

Index

Constants

View Source
const (
	URL_BOLETO         = "https://shopline.itau.com.br/shopline/Impressao.aspx"
	URL_BOLETO_HOMOLOG = "https://shopline.itau.com.br/shopline/emissao_teste.asp"
	URL_CONSULTA       = "https://shopline.itau.com.br/shopline/consulta.aspx"
	URL_SHOPLINE       = "https://shopline.itau.com.br/shopline/shopline.aspx"
	CPF                = "01"
	CNPJ               = "02"
	// status pagamento
	STAT_PAGAMENTO_EFETUADO           = "00"
	STAT_SIT_PAGAMENTO_NAO_FINALIZADO = "01"
	STAT_ERR_NA_CONSULTA              = "02"
	STAT_PEDIDO_NAO_LOCALIZADO        = "03"
	STAT_BOLETO_EMITIDO_COM_SUCESSO   = "04"
	STAT_PGTO_EFETUADO_AG_COMPENSACAO = "05"
	STAT_PGTO_NAO_COMPENSADO          = "06"
)

Variables

View Source
var (
	R = false
)

Functions

func StripDCFromRedirectHTML

func StripDCFromRedirectHTML(html string) (string, error)

Types

type BoletoDef

type BoletoDef struct {
	Pedido          int
	Valor           float64
	Observacao      string
	NomeCliente     string
	CodigoInscricao string
	NumeroInscricao string
	CEP             string
	Endereco        string
	Bairro          string
	Cidade          string
	Estado          string
	Vencimento      time.Time
	URL_Retorno     string
	Obs1            string
	Obs2            string
	Obs3            string
}

func (BoletoDef) Clean

func (b BoletoDef) Clean() BoletoDef

func (BoletoDef) ToToken

func (b BoletoDef) ToToken() string

type SondaResult

type SondaResult struct {
	XMLName       xml.Name   `xml:"PARAMETER"`
	Z             []XMLParam `xml:"PARAM"`
	CodigoEmpresa string
	Pedido        int
	Valor         float64
	TipoPgto      string
	SitPgto       string
	DtPgto        time.Time
}

func (*SondaResult) GetRawVal

func (s *SondaResult) GetRawVal(name string) string

func (*SondaResult) Unwrap

func (s *SondaResult) Unwrap()

type Webservice

type Webservice struct {
	Codigo      string
	Chave       string
	ChaveItau   string
	Homologacao bool
}

func New

func New(codigo, chave string) *Webservice

func (*Webservice) GetBoletoDCPDF

func (ws *Webservice) GetBoletoDCPDF(dc string, shoplineid int, referer string) ([]byte, error)

encapsula o boleto e retorna o PDF referer: https://www.example.com

func (*Webservice) GetBoletoPDF

func (ws *Webservice) GetBoletoPDF(boleto BoletoDef, referer string) ([]byte, error)

encapsula o boleto e retorna o PDF referer: https://www.example.com

func (*Webservice) GetBoletoRedirectHTML

func (ws *Webservice) GetBoletoRedirectHTML(boleto BoletoDef) (string, error)

func (*Webservice) GetDC

func (ws *Webservice) GetDC(boleto BoletoDef) (string, error)

func (*Webservice) Sonda

func (ws *Webservice) Sonda(pedido int) (*SondaResult, error)

type XMLParam

type XMLParam struct {
	Id    string `xml:"ID,attr"`
	Value string `xml:"VALUE,attr"`
}

Jump to

Keyboard shortcuts

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