Documentation
¶
Index ¶
- Constants
- func GeneratePostData(signDataJsonString string, sign string) map[string]string
- func GenerateSignString(body interface{}, header interface{}) (str string)
- func MarshalNoEscapeHTML(v interface{}) ([]byte, error)
- func NewSandV4Client(options ...SandV4Option) (*sandV4Client, error)
- func NewSandV5Client(options ...SandV5Option) (*sandV5Client, error)
- type AccountInfoQueryReq
- type AccountInfoQueryResponse
- type B2cPayeeReq
- type B2cReq
- type B2cResponse
- type Client
- type ClientOption
- type CloseAccountConfirmReq
- type CloseAccountReq
- type Config
- type Data
- type HeadOption
- type Header
- type OrderQueryBody
- type OrderQueryResponseBodyData
- type OrderQueryResponseData
- type OrderQueryResponseHeadData
- type PemBlockType
- type PostData
- type PrivateKey
- type PublicKey
- type Response
- type SandV4Option
- type SandV5Option
- type X
Constants ¶
const OK = "000000"
Variables ¶
This section is empty.
Functions ¶
func GeneratePostData ¶
func GenerateSignString ¶
func GenerateSignString(body interface{}, header interface{}) (str string)
func MarshalNoEscapeHTML ¶
MarshalNoEscapeHTML marshal with no escape HTML
func NewSandV4Client ¶
func NewSandV4Client(options ...SandV4Option) (*sandV4Client, error)
func NewSandV5Client ¶
func NewSandV5Client(options ...SandV5Option) (*sandV5Client, error)
Types ¶
type AccountInfoQueryReq ¶
type AccountInfoQueryReq struct { Version string `json:"version"` Mid string `json:"mid"` CustomerOrderNo string `json:"customerOrderNo"` SignType string `json:"signType"` EncryptType string `json:"encryptType"` Timestamp string `json:"timestamp,omitempty"` BizUserNo string `json:"bizUserNo,omitempty"` EncryptKey string `json:"encryptKey,omitempty"` Data string `json:"data,omitempty"` Sign string `json:"sign,omitempty"` }
type B2cPayeeReq ¶
type B2cReq ¶
type B2cReq struct { Version string `json:"version"` Mid string `json:"mid"` CustomerOrderNo string `json:"customerOrderNo"` SignType string `json:"signType"` EncryptType string `json:"encryptType"` Timestamp string `json:"timestamp,omitempty"` EncryptKey string `json:"encryptKey,omitempty"` Data string `json:"data,omitempty"` Sign string `json:"sign,omitempty"` AccountType string `json:"accountType,omitempty"` OrderAmt float64 `json:"orderAmt,omitempty"` Payee B2cPayeeReq `json:"payee,omitempty"` Postscript string `json:"postscript,omitempty"` Remark string `json:"remark,omitempty"` }
type B2cResponse ¶
type Client ¶
type Client interface { // Do 请求杉德API Do(ctx context.Context, reqURL string, form url.Values) (*Data, error) // Form 生成统一的POST表单(用于API请求或前端表单提交) Form(method, productID string, body X, options ...HeadOption) (url.Values, error) // Verify 验证并解析杉德API结果或回调通知 Verify(form url.Values) (*Data, error) }
Client 杉德支付客户端
type ClientOption ¶
type ClientOption func(c *client)
ClientOption 客户端配置项
func WithHTTPClient ¶
func WithHTTPClient(cli *http.Client) ClientOption
WithHTTPClient 自定义http.Client
type CloseAccountConfirmReq ¶
type CloseAccountConfirmReq struct { Version string `json:"version"` Mid string `json:"mid"` CustomerOrderNo string `json:"customerOrderNo"` OriCustomerOrderNo string `json:"oriCustomerOrderNo"` SignType string `json:"signType"` EncryptType string `json:"encryptType"` Timestamp string `json:"timestamp,omitempty"` EncryptKey string `json:"encryptKey,omitempty"` Data string `json:"data,omitempty"` Sign string `json:"sign,omitempty"` AccountType string `json:"accountType,omitempty"` BizUserNo string `json:"bizUserNo,omitempty"` SmsCode string `json:"smsCode,omitempty"` }
type CloseAccountReq ¶
type CloseAccountReq struct { Version string `json:"version"` Mid string `json:"mid"` CustomerOrderNo string `json:"customerOrderNo"` SignType string `json:"signType"` EncryptType string `json:"encryptType"` Timestamp string `json:"timestamp,omitempty"` EncryptKey string `json:"encryptKey,omitempty"` Data string `json:"data,omitempty"` Sign string `json:"sign,omitempty"` AccountType string `json:"accountType,omitempty"` OrderAmt float64 `json:"orderAmt,omitempty"` BizUserNo string `json:"bizUserNo,omitempty"` BizType string `json:"bizType,omitempty"` Postscript string `json:"postscript,omitempty"` Remark string `json:"remark,omitempty"` NotifyUrl string `json:"notifyUrl,omitempty"` FrontUrl string `json:"returnUrl,omitempty"` }
type Config ¶
type Config struct { MID string // 商户ID KeyFile string // 商户私钥(PEM格式) CertFile string // 杉德公钥(PEM格式) }
Config 客户端配置
type HeadOption ¶
type HeadOption func(h X)
HeadOption 报文头配置项
func WithAccessType ¶
func WithAccessType(at string) HeadOption
WithAccessType 设置接入类型:1 - 普通商户接入(默认);2 - 平台商户接入
func WithChannelType ¶
func WithChannelType(ct string) HeadOption
WithChannelType 设置渠道类型:07 - 互联网(默认);08 - 移动端
func WithPLMid ¶
func WithPLMid(id string) HeadOption
WithPLMid 设置平台ID:接入类型为2时必填,在担保支付模式下填写核心商户号;在杉德宝平台终端模式下填写平台商户号
func WithVersion ¶
func WithVersion(v string) HeadOption
WithVersion 设置版本号:默认:1.0;功能产品号为微信小程序或支付宝生活号,对账单需获取营销优惠金额字段传:3.0
type OrderQueryBody ¶
type OrderQueryResponseBodyData ¶
type OrderQueryResponseBodyData struct {
OrderStatus string `json"orderStatus"`
}
type OrderQueryResponseData ¶
type OrderQueryResponseData struct { Head *OrderQueryResponseHeadData `json:"head"` Body *OrderQueryResponseBodyData `json:"body"` }
type OrderQueryResponseHeadData ¶
type OrderQueryResponseHeadData struct {
RespCode string `json"respCode"`
}
type PemBlockType ¶
type PemBlockType string
PemBlockType pem block type which taken from the preamble.
const ( // RSAPKCS1 private key in PKCS#1 RSAPKCS1 PemBlockType = "RSA PRIVATE KEY" // RSAPKCS8 private key in PKCS#8 RSAPKCS8 PemBlockType = "PRIVATE KEY" )
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
PrivateKey RSA private key
func NewPrivateKeyFromPemFile ¶
func NewPrivateKeyFromPemFile(pemFile string) (*PrivateKey, error)
NewPrivateKeyFromPemFile returns new private key with pem file.
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
PublicKey RSA public key
func NewPublicKeyFromDerFile ¶
NewPublicKeyFromDerFile returns public key with DER file. NOTE: PEM format with -----BEGIN CERTIFICATE----- | -----END CERTIFICATE----- openssl x509 -inform der -in cert.cer -out cert.pem
type SandV4Option ¶
type SandV4Option func(c *sandV4Client)
ClientOption 客户端配置项
func WithV4MerNo ¶
func WithV4MerNo(merNo string) SandV4Option
merNo, prvKeyFile, pubKeyFile, notifyUrl, returnUrl string
func WithV4NotifyUrl ¶
func WithV4NotifyUrl(file string) SandV4Option
func WithV4PrvKeyFile ¶
func WithV4PrvKeyFile(file string) SandV4Option
func WithV4PubKeyFile ¶
func WithV4PubKeyFile(file string) SandV4Option
func WithV4ReturnUrl ¶
func WithV4ReturnUrl(file string) SandV4Option
func WithV4UserFlag ¶
func WithV4UserFlag(flag string) SandV4Option
type SandV5Option ¶
type SandV5Option func(c *sandV5Client)
ClientOption 客户端配置项
func WithMerNo ¶
func WithMerNo(merNo string) SandV5Option
merNo, prvKeyFile, pubKeyFile, notifyUrl, returnUrl string
func WithNotifyUrl ¶
func WithNotifyUrl(file string) SandV5Option
func WithPrvKeyFile ¶
func WithPrvKeyFile(file string) SandV5Option
func WithPubKeyFile ¶
func WithPubKeyFile(file string) SandV5Option
func WithReturnUrl ¶
func WithReturnUrl(file string) SandV5Option
func WithUserFlag ¶
func WithUserFlag(flag string) SandV5Option