alipaysdk

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerUrlProduction  = "https://openapi.alipay.com/gateway.do"    // 正式环境请求地址
	ServerUrlDevelopment = "https://openapi.alipaydev.com/gateway.do" // 沙箱环境请求地址

	PublicAppAuthUrlProduction  = "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm"    // 正式环境授权登录地址
	PublicAppAuthUrlDevelopment = "https://openauth.alipaydev.com/oauth2/publicAppAuthorize.htm" // 沙箱环境授权登录地址

	AppToAppAuthUrlProduction  = "https://openauth.alipay.com/oauth2/appToAppAuth.htm"    // 正式环境第三方授权登录地址
	AppToAppAuthUrlDevelopment = "https://openauth.alipaydev.com/oauth2/appToAppAuth.htm" // 沙箱环境第三方授权登录地址
)

Variables

This section is empty.

Functions

func GetRequest

func GetRequest(url string) (string, error)

func HttpRequest

func HttpRequest(method, url string, value []byte) (string, error)

func Printf added in v1.0.1

func Printf(format string, v ...interface{})

func RsaSign

func RsaSign(content, privateKeyString string, hash crypto.Hash) (string, error)

func RsaVerify added in v1.0.3

func RsaVerify(content, signString, alipayPublicKey string, hash crypto.Hash) error

func SetDebug added in v1.0.1

func SetDebug(debug bool)

Types

type AuthClientData

type AuthClientData struct {
	AppId       string   `json:"app_id"`       // 应用 id
	AuthUrl     string   `json:"auth_url"`     // 授权登录地址
	RedirectUri string   `json:"redirect_uri"` // 授权回调地址
	State       string   `json:"state"`        // 随机字符串,回调时返回给服务器
	Scopes      []string `json:"scopes"`       // 接口授权值
}

type Client

type Client interface {
	DefaultClient(serverUrl, appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData
	DefaultProductionClient(appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData
	DefaultDevelopmentClient(appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData
	DefaultSimpleProductionClient(appId, privateKey, alipayPublicKey string) *ClientData
	DefaultSimpleDevelopmentClient(appId, privateKey, alipayPublicKey string) *ClientData

	DefaultPublicAppAuthUrl(authUrl, appId, redirectUri, state string, scopes string) string
	DefaultProductionPublicAppAuthUrl(appId, redirectUri, state string, scopes string) string
	DefaultDevelopmentPublicAppAuthUrl(appId, redirectUri, state string, scopes string) string

	DefaultAppToAppAuthUrl(authUrl, appId, redirectUri string) string
	DefaultProductionAppToAppAuthUrl(appId, redirectUri string) string
	DefaultDevelopmentAppToAppAuthUrl(appId, redirectUri string) string

	SetAppAuthToken(appAuthToken string)
	SetGrantTypeAndCode(grantType, code string) error
	SetAuthToken(authToken string)
	SetReturnUrl(returnUrl string)
	SetNotifyUrl(notifyUrl string)

	RequestUrl(method string, bizContent interface{}) (string, error)
	SendRequest(method string, bizContent interface{}) (string, error)
}

type ClientData

type ClientData struct {
	ServerUrl       string      `json:"server_url"`        // 支付宝网关
	PublicKey       string      `json:"public_key"`        // 应用公钥
	PrivateKey      string      `json:"private_key"`       // 应用私钥
	AlipayPublicKey string      `json:"alipay_public_key"` // 支付宝公钥
	RequestData     RequestData `json:"request_data"`      // 公共请求参数
}

func (*ClientData) CheckAsyncNotification added in v1.0.2

func (client *ClientData) CheckAsyncNotification(query string) (bool, error)

func (*ClientData) ComposeParameterString

func (client *ClientData) ComposeParameterString() (string, string, error)

func (*ClientData) DefaultAppToAppAuthUrl

func (client *ClientData) DefaultAppToAppAuthUrl(authUrl, appId, redirectUri string) string

func (*ClientData) DefaultClient

func (client *ClientData) DefaultClient(serverUrl, appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData

func (*ClientData) DefaultDevelopmentAppToAppAuthUrl

func (client *ClientData) DefaultDevelopmentAppToAppAuthUrl(appId, redirectUri string) string

func (*ClientData) DefaultDevelopmentClient

func (client *ClientData) DefaultDevelopmentClient(appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData

func (*ClientData) DefaultDevelopmentPublicAppAuthUrl

func (client *ClientData) DefaultDevelopmentPublicAppAuthUrl(appId, redirectUri, state string, scopes string) string

func (*ClientData) DefaultProductionAppToAppAuthUrl

func (client *ClientData) DefaultProductionAppToAppAuthUrl(appId, redirectUri string) string

func (*ClientData) DefaultProductionClient

func (client *ClientData) DefaultProductionClient(appId, format, charset, signType, privateKey, alipayPublicKey string) *ClientData

func (*ClientData) DefaultProductionPublicAppAuthUrl

func (client *ClientData) DefaultProductionPublicAppAuthUrl(appId, redirectUri, state string, scopes string) string

func (*ClientData) DefaultPublicAppAuthUrl

func (client *ClientData) DefaultPublicAppAuthUrl(authUrl, appId, redirectUri, state string, scopes string) string

func (*ClientData) DefaultSimpleDevelopmentClient

func (client *ClientData) DefaultSimpleDevelopmentClient(appId, privateKey, alipayPublicKey string) *ClientData

func (*ClientData) DefaultSimpleProductionClient

func (client *ClientData) DefaultSimpleProductionClient(appId, privateKey, alipayPublicKey string) *ClientData

func (*ClientData) RequestUrl

func (client *ClientData) RequestUrl(method string, bizContent interface{}) (string, error)

func (*ClientData) SendRequest

func (client *ClientData) SendRequest(method string, bizContent interface{}) (string, error)

func (*ClientData) SetAppAuthToken

func (client *ClientData) SetAppAuthToken(appAuthToken string)

func (*ClientData) SetAuthToken

func (client *ClientData) SetAuthToken(authToken string)

func (*ClientData) SetGrantTypeAndCode

func (client *ClientData) SetGrantTypeAndCode(grantType, code string) error

func (*ClientData) SetNotifyUrl

func (client *ClientData) SetNotifyUrl(notifyUrl string)

func (*ClientData) SetReturnUrl

func (client *ClientData) SetReturnUrl(returnUrl string)

func (*ClientData) Validate

func (client *ClientData) Validate() error

type RequestData

type RequestData struct {
	// 公共参数
	AppId     string `json:"app_id"`         // 应用 id
	Method    string `json:"method"`         // 接口名称
	Format    string `json:"format"`         // 格式
	Charset   string `json:"charset"`        // 请求使用的编码
	SignType  string `json:"sign_type"`      // 生成签名的算法
	Sign      string `json:"sign,omitempty"` // 签名
	Timestamp string `json:"timestamp"`      // 时间
	Version   string `json:"version"`        // 版本

	// 应用授权
	AppAuthToken string `json:"app_auth_token,omitempty"`

	// 请求参数集合
	BizContent string `json:"biz_content,omitempty"`

	// 其他参数,按需使用
	GrantType    string `json:"grant_type,omitempty"`
	Code         string `json:"code,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	AuthToken    string `json:"auth_token,omitempty"`
	ReturnUrl    string `json:"return_url,omitempty"` // 回调地址
	NotifyUrl    string `json:"notify_url,omitempty"` // 异步通知地址
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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