Documentation ¶
Index ¶
- Constants
- func New(appId, privateKey, publicKey string, isProd bool, opts ...OptionFunc) (client *Client, e *BizErr)
- func Nonce() string
- func URLValuesToJsonString(param url.Values) (s string, err error)
- type BizErr
- type Client
- func (c *Client) CheckRequestParams(request *Request) *BizErr
- func (c *Client) DecryptRequestData(request *Request) (ds string, e *BizErr)
- func (c *Client) DoRequest(method string, params map[string]interface{}) (data []byte, e *BizErr)
- func (c *Client) DoRequestAndVerify(method string, params map[string]interface{}, result interface{}) *BizErr
- func (c *Client) FormatResponse(code, message, method string, data interface{}) (res *Response, e *BizErr)
- func (c *Client) SetApiDomain(url string)
- func (c *Client) URLValues(method string, params map[string]interface{}) (value url.Values, e *BizErr)
- func (c *Client) VerifyRequestSign(req *Request) (bool, *BizErr)
- func (c *Client) VerifyResponseSign(res *Response) (bool, *BizErr)
- func (c *Client) VerifySign(data url.Values) (ok bool, e *BizErr)
- func (c *Client) VerifySignWithDecryptResponse(data []byte, result interface{}) (e *BizErr)
- type Code
- type OptionFunc
- type Request
- type Response
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" MIMEApplicationJSON = "application/json" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEMultipartForm = "multipart/form-data" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BizErr ¶
func (*BizErr) GetMessage ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CheckRequestParams ¶
func (*Client) DecryptRequestData ¶
func (*Client) DoRequestAndVerify ¶
func (*Client) FormatResponse ¶
func (*Client) SetApiDomain ¶
func (*Client) VerifyResponseSign ¶
func (*Client) VerifySignWithDecryptResponse ¶
type Code ¶
type Code string
const ( CSuccess Code = "200" // 成功 CDataDecryptFailure Code = "3001" // 数据解密失败 CSignFailure Code = "3002" // 签名校验失败 CParamInvalid Code = "4000" // 参数无效 CNotAppIdParam Code = "4001" // 缺少参数app_id CNotSignParam Code = "4002" // 缺少参数sign CNotNonceParam Code = "4003" // 缺少参数nonce CNotDataParam Code = "4004" // 缺少业务参数 CNotConfig Code = "4005" // 缺少配置参数 CNotMethod Code = "4006" // 缺少参数method CNotTimestamp Code = "4007" // 缺少参数timestamp CNotTimeExpired Code = "4008" // 请求已过期(timestamp超过10分钟) CCertError Code = "4042" // 密钥或证书错误 CMethodNotExist Code = "4051" // method路由不存在 CApiResBizError Code = "4100" // 接口返回业务错误数据 CTodayException Code = "5001" // 交易平台服务异常 CPlatformException Code = "5002" // 一级平台服务异常 CDataDecodeFailure Code = "5003" // 数据解析失败 CApiRequestFailure Code = "5004" // 接口请求失败 CApiResponseFailure Code = "5005" // 接口返回数据异常 CUnknown Code = "5500" // 未知异常 CUserNotFound Code = "20101" //未找到用户 CUserRealNameDiff Code = "20102" //用户实名信息不一致 )
func (*Code) UnmarshalJSON ¶
type OptionFunc ¶
type OptionFunc func(c *Client)
func WithApiDomain ¶
func WithApiDomain(apiDomain string) OptionFunc
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) OptionFunc
func WithLogger ¶
func WithLogger(entry *logrus.Entry) OptionFunc
func WithTimeLocation ¶
func WithTimeLocation(location *time.Location) OptionFunc
Click to show internal directories.
Click to hide internal directories.