toutiao

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 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 //开发者自定义字段,回调原样回传
	RefundNotifyUrl string //退款回调地址
}

func NewClient

func NewClient(appId, SALT, token, extra 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) Refund added in v0.6.8

func (c *Client) Refund(outTradeNo, outRefundNo, refundDesc string, refundFee int64) (refundNo string, err error)

申请退款

func (*Client) RefundNotify added in v0.6.8

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

退款回调

func (*Client) RefundQuery added in v0.6.8

func (c *Client) RefundQuery(outRefundNo string) (rslt *RefundQueryData, err error)

退款查询

func (*Client) SetRefundNotifyUrl added in v0.6.8

func (c *Client) SetRefundNotifyUrl(refundNotifyUrl string)

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"` //渠道网关号
}

type RefundNotifyMsgData added in v0.6.8

type RefundNotifyMsgData struct {
	Appid        string `json:"appid"`
	CpRefundno   string `json:"cp_refundno"`   //开发者自定义的退款单号
	CpExtra      string `json:"cp_extra"`      //预下单时开发者传入字段
	Status       string `json:"status"`        //退款状态 PROCESSING-处理中|SUCCESS-成功|FAIL-失败
	RefundAmount int64  `json:"refund_amount"` //退款金额
}

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

type RefundQueryData added in v0.6.8

type RefundQueryData struct {
	RefundNo     string `json:"refund_no"`
	RefundAmount int64  `json:"refund_amount"`
	RefundStatus string `json:"refund_status"` //退款状态,成功-SUCCESS;失败-FAIL
}

type RefundQueryResp added in v0.6.8

type RefundQueryResp struct {
	ErrNo      int64            `json:"err_no"`
	ErrTips    string           `json:"err_tips"`
	RefundInfo *RefundQueryData `json:"refundInfo"`
}

查询退款应答参数

type RefundResp added in v0.6.8

type RefundResp struct {
	ErrNo    int64  `json:"err_no"`
	ErrTips  string `json:"err_tips"`
	RefundNo string `json:"refund_no"`
}

申请退款应答参数

Jump to

Keyboard shortcuts

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