Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptOpenDataToStruct(encryptedData, secretKey string, beanPtr interface{}) (err error)
- type AliPayOpenAppMiniTemplateMessageSendData
- type AliPayOpenAppMiniTemplateMessageSendResponse
- type AlipaySystemOauthTokenData
- type AlipaySystemOauthTokenResponse
- type AlipayUserInfoShareData
- type AlipayUserInfoShareResponse
- type BodyMap
- func (bm BodyMap) CheckEmptyError(keys ...string) error
- func (bm BodyMap) Get(key string) string
- func (bm BodyMap) GetInterface(key string) interface{}
- func (bm BodyMap) GetString(key string) string
- func (bm BodyMap) Marshal() (jb string)
- func (bm BodyMap) Remove(key string)
- func (bm BodyMap) Reset()
- func (bm BodyMap) Set(key string, value interface{}) BodyMap
- func (bm BodyMap) SetBodyMap(key string, value func(b BodyMap)) BodyMap
- func (bm BodyMap) Unmarshal(ptr interface{}) (err error)
- type Client
- func (c *Client) AlipayOpenAppMiniTemplateMessageSend(bm BodyMap) (aliRsp *AliPayOpenAppMiniTemplateMessageSendResponse, err error)
- func (c *Client) AlipaySystemOauthToken(bm BodyMap) (aliRsp *AlipaySystemOauthTokenResponse, err error)
- func (c *Client) AlipayUserInfoShare(authToken string) (aliRsp *AlipayUserInfoShareResponse, err error)
- func (this *Client) AutoVerifySign(bs []byte, alipayCertSn, sign string) (err error)
- func (c *Client) SetCertSn(...) (err error)
- type Code
- type ErrorResponse
Constants ¶
View Source
const ( ProdURL = "https://openapi.alipay.com/gateway.do" // 正式环境请求地址 SandboxURL = "https://openapi.alipaydev.com/gateway.do" // 沙箱环境请求地址 )
View Source
const ( Format = "JSON" // 请求格式 Charset = "utf-8" // 字节编码 Version = "1.0" // 版本 SignType = "RSA2" // 签名方式 TimeFormat = "2006-01-02 15:04:05" // 日期格式 ContentType = "application/x-www-form-urlencoded;charset=utf-8" // form表单格式 )
View Source
const ( EMPTY = "" CertificateEnd = "-----END CERTIFICATE-----" )
View Source
const ( HttpGetMethod = "GET" HttpPostMethod = "POST" )
Variables ¶
View Source
var ( ErrInitParamsMissed = errors.New("客户端初始化参数异常") MissParamErr = errors.New("参数不能为空") ErrAliCertSnNotMatch = errors.New("当前使用的支付宝公钥证书SN与网关响应报文中的SN不匹配") ErrGetSignData = errors.New("获取报文签名数据失败") ErrVerifySignature = errors.New("验签签名失败") )
View Source
var ( AppID = "2017051700859121" PrivateKey = "" /* 1588-byte string literal not displayed */ AppCertPublicKey = `` /* 1290-byte string literal not displayed */ AlipayRootCert = `` /* 5043-byte string literal not displayed */ AlipayCertPublicKeyRsa2 = `` /* 2666-byte string literal not displayed */ )
Functions ¶
func DecryptOpenDataToStruct ¶
DecryptOpenDataToStruct 解密支付宝开放数据到 结构体
encryptedData:包括敏感数据在内的完整用户信息的加密数据 secretKey:AES密钥,支付宝管理平台配置 beanPtr:需要解析到的结构体指针 文档:https://opendocs.alipay.com/mini/introduce/aes 文档:https://opendocs.alipay.com/open/common/104567
Types ¶
type AliPayOpenAppMiniTemplateMessageSendData ¶
type AliPayOpenAppMiniTemplateMessageSendData struct {
*ErrorResponse
}
type AliPayOpenAppMiniTemplateMessageSendResponse ¶
type AliPayOpenAppMiniTemplateMessageSendResponse struct { Response *AliPayOpenAppMiniTemplateMessageSendData `json:"alipay_open_app_mini_templatemessage_send_response"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` Sign string `json:"sign"` }
type AlipaySystemOauthTokenData ¶
type AlipaySystemOauthTokenData struct { AccessToken string `json:"access_token,omitempty"` AlipayUserId string `json:"alipay_user_id,omitempty"` ExpiresIn int64 `json:"expires_in,omitempty"` ReExpiresIn int64 `json:"re_expires_in,omitempty"` RefreshToken string `json:"refresh_token,omitempty"` UserId string `json:"user_id,omitempty"` }
type AlipaySystemOauthTokenResponse ¶
type AlipaySystemOauthTokenResponse struct { Response *AlipaySystemOauthTokenData `json:"alipay_system_oauth_token_response,omitempty"` ErrorResponse *ErrorResponse `json:"error_response,omitempty"` AlipayCertSn string `json:"alipay_cert_sn,omitempty"` Sign string `json:"sign,omitempty"` }
type AlipayUserInfoShareData ¶
type AlipayUserInfoShareData struct {}
type AlipayUserInfoShareResponse ¶
type AlipayUserInfoShareResponse struct {}
type BodyMap ¶
type BodyMap map[string]interface{}
func DecryptOpenDataToBodyMap ¶
DecryptOpenDataToBodyMap 解密支付宝开放数据到 BodyMap
encryptedData:包括敏感数据在内的完整用户信息的加密数据 secretKey:AES密钥,支付宝管理平台配置 文档:https://opendocs.alipay.com/mini/introduce/aes 文档:https://opendocs.alipay.com/open/common/104567
func (BodyMap) CheckEmptyError ¶
CheckEmptyError 校验指定key是否为空
func (BodyMap) GetInterface ¶
GetInterface 获取原始参数
func (BodyMap) SetBodyMap ¶
SetBodyMap 回调函数设置 bm
type Client ¶
func (*Client) AlipayOpenAppMiniTemplateMessageSend ¶
func (c *Client) AlipayOpenAppMiniTemplateMessageSend(bm BodyMap) (aliRsp *AliPayOpenAppMiniTemplateMessageSendResponse, err error)
AlipayOpenAppMiniTemplateMessageSend 小程序发送模板消息 文档地址: https://opendocs.alipay.com/mini/02cth2
func (*Client) AlipaySystemOauthToken ¶
func (c *Client) AlipaySystemOauthToken(bm BodyMap) (aliRsp *AlipaySystemOauthTokenResponse, err error)
AlipaySystemOauthToken 换取授权访问令牌 文档地址: https://opendocs.alipay.com/open/02xtla
func (*Client) AlipayUserInfoShare ¶
func (c *Client) AlipayUserInfoShare(authToken string) (aliRsp *AlipayUserInfoShareResponse, err error)
AlipayUserInfoShare 支付宝会员授权信息查询 文档地址: https://opendocs.alipay.com/open/02xtlb
func (*Client) AutoVerifySign ¶
AutoVerifySign 自动验签 bs: 响应完整字节数据 alipayCertSn:支付宝返回的证书序号 sign: 支付宝响应的签名
type Code ¶
type Code string
const ( CodeSuccess Code = "10000" // 接口调用成功 CodeUnknowError Code = "20000" // 服务不可用 CodeInvalidAuthToken Code = "20001" // 授权权限不足 CodeMissingParam Code = "40001" // 缺少必选参数 CodeInvalidParam Code = "40002" // 非法的参数 CodeBusinessFailed Code = "40004" // 业务处理失败 CodePermissionDenied Code = "40006" // 权限不足 )
type ErrorResponse ¶
type ErrorResponse struct { Code Code `json:"code"` Msg string `json:"msg"` SubCode string `json:"sub_code,omitempty"` SubMsg string `json:"sub_msg,omitempty"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.