xftpay

package
v0.0.0-...-3b7ab86 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Key string

	OsInfo   string
	LogLevel = 2
)

Functions

func GenMD5Sign

func GenMD5Sign(data interface{}, key string) (d interface{}, err error)

func GenSign

func GenSign(data []byte, privateKey []byte) (sign []byte, err error)

用商户的私钥去生成签名目前在创建订单的时候使用

func JsonDecode

func JsonDecode(p []byte, v interface{}) error

简单封装了json的UnMarshal功能 Example pingpp.JsonDecode(param1, param2) param1:需要转换成结构体的json数据 param2:转换后数据容器

func JsonEncode

func JsonEncode(v interface{}) ([]byte, error)

简单封装了json的Marshal功能 pingpp.JsonEncode(param1)

func MD5

func MD5(str string) string

func SetBackend

func SetBackend(backend SupportedBackend, b Backend)

设定后端处理对象

func Struct2Map

func Struct2Map(obj interface{}) map[string]interface{}

func Verify

func Verify(data []byte, publicKey []byte, sign []byte) (err error)

用ping++公钥去验证签名目前在Webhook时候使用

func Version

func Version() string

Types

type ApiBackend

type ApiBackend struct {
	Type       SupportedBackend
	URL        string
	HTTPClient *http.Client
}

ApiBackend api相关的后端类型

func (ApiBackend) Call

func (s ApiBackend) Call(method, path, key string, form *url.Values, params []byte, v interface{}) error

Call 后端处理请求方法

func (*ApiBackend) Do

func (s *ApiBackend) Do(req *http.Request, v interface{}) error

Do 处理 http 请求

func (*ApiBackend) NewRequest

func (s *ApiBackend) NewRequest(method, path, key, contentType string, body io.Reader, params []byte) (*http.Request, error)

NewRequest 建立http请求对象

type Backend

type Backend interface {
	Call(method, path, key string, body *url.Values, params []byte, v interface{}) error
}

func GetBackend

func GetBackend(backend SupportedBackend) Backend

通过不同的参数获取不同的后端对象

type Backends

type Backends struct {
	API Backend
}

type CommonRequest

type CommonRequest struct {
	AppID string
}

type SupportedBackend

type SupportedBackend string
const (
	TotalBackends                  = 1
	APIBackend    SupportedBackend = "api"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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