toutiao

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapToString

func MapToString(params Params) string

Types

type Client

type Client struct {
	AppId     string //传入的appID
	NotifyURL string //异步通知地址
	OrderTime int    //订单有效分钟数
	SALT      string //向小程序平台发送请求时的密钥
	Token     string //小程序平台向开发者服务端发送请求时的密钥
	Extra     string //开发者自定义字段,回调原样回传
}

func NewClient

func NewClient(appId, SALT, token string, notifyUrl string, orderTime int) *Client

NewClient 一个新的配置信息

func (*Client) CreateOrder

func (c *Client) CreateOrder(body, outTradeNo string, totalFee int64) (rslt *OrderInfo, err error)

预下单

func (*Client) Notify

func (c *Client) Notify(req *http.Request) (msgData *NotifyMsgData, ret *NotifyReturn, err error)

回调

func (*Client) QueryOrder

func (c *Client) QueryOrder(outTradeNo string) (rslt *QueryOrderRespData, err error)

订单查询

func (*Client) ValidSign

func (c *Client) ValidSign(params Params) bool

ValidSign 验证签名

type CreateOrderReq

type CreateOrderReq struct {
	AppId       string `json:"app_id"`
	Sign        string `json:"sign"`
	OutOrderNo  string `json:"out_order_no"`
	TotalAmount int64  `json:"total_amount"`
	Subject     string `json:"subject"`
	Body        string `json:"body"`
	ValidTime   int64  `json:"valid_time"`
	CpExtra     string `json:"cp_extra"`
	NotifyUrl   string `json:"notify_url"`
	DisableMsg  int64  `json:"disable_msg"`
}

type CreateOrderResp

type CreateOrderResp struct {
	ErrNo   int64      `json:"err_no"`
	ErrTips string     `json:"err_tips"`
	Data    *OrderInfo `json:"data"`
}

预下单应答参数

type NotifyMsgData

type NotifyMsgData struct {
	Appid     string `json:"appid"`
	CpOrderno string `json:"cp_orderno"` //开发者传入订单号
	Way       string `json:"way"`        //way 字段中标识了支付渠道:2-支付宝,1-微信
	CpExtra   string `json:"cp_extra"`   //预下单时开发者传入字段
}

回调信息包括 msg 信息为以下内容序列化得到的 json 字符串

type NotifyReq

type NotifyReq struct {
	Timestamp    int64  `json:"timestamp"`
	Nonce        string `json:"nonce"`         //随机数
	Msg          string `json:"msg"`           //订单信息的json字符串
	Type         string `json:"type"`          //回调类型标记,支付成功回调为"payment"
	MsgSignature string `json:"msg_signature"` //签名
}

支付回调请求参数

type NotifyReturn

type NotifyReturn struct {
	ErrNo  int64  `json:"err_no"`
	ErrTip string `json:"err_tips"`
}

回调响应参数

type OrderInfo

type OrderInfo struct {
	OrderId    string `json:"order_id"`
	OrderToken string `json:"order_token"`
}

type Params

type Params map[string]interface{}

Params Params

func StringToMap

func StringToMap(content []byte) Params

func (Params) ContainsKey

func (p Params) ContainsKey(key string) bool

ContainsKey 判断key是否存在

func (Params) GetInt64

func (p Params) GetInt64(k string) int64

GetInt64 GetInt64

func (Params) GetString

func (p Params) GetString(k string) string

GetString GetString

func (Params) SetInt64

func (p Params) SetInt64(k string, i int64) Params

SetInt64 SetInt64

func (Params) SetString

func (p Params) SetString(k, s string) Params

SetString SetString

type QueryOrderResp

type QueryOrderResp struct {
	ErrNo       int64               `json:"err_no"`
	ErrTips     string              `json:"err_tips"`
	OutOrderNo  string              `json:"out_order_no"`
	OrderId     string              `json:"order_id"`
	PaymentInfo *QueryOrderRespData `json:"payment_info"`
}

查询订单应答参数

type QueryOrderRespData added in v0.6.4

type QueryOrderRespData struct {
	TotalFee         int64  `json:"total_fee"`
	OrderStatus      string `json:"order_status"`       //PROCESSING-处理中|SUCCESS-成功|FAIL-失败|TIMEOUT-超时
	PayTime          string `json:"pay_time"`           //支付时间
	Way              int64  `json:"way"`                //支付渠道 2-支付宝,1-微信,3-银行卡
	ChannelNo        string `json:"channel_no"`         //渠道单号
	ChannelGatewayNo string `json:"channel_gateway_no"` //渠道网关号
}

Jump to

Keyboard shortcuts

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