sandpay

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

README

sandpay

杉德支付 Go SDK

Documentation

Index

Constants

View Source
const OK = "000000"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 杉德支付客户端

func NewClient

func NewClient(mchID string, options ...Option) *Client

NewClient 生成杉德支付客户端

func (*Client) Do

func (c *Client) Do(ctx context.Context, reqURL string, form *Form) (*Form, error)

Do 请求杉德API

func (*Client) MchID

func (c *Client) MchID() string

MchID 返回商品ID

func (*Client) Verify

func (c *Client) Verify(form url.Values) (*Form, error)

Verify 验证并解析杉德API结果或回调通知

type Form

type Form struct {
	Head V `json:"Head"`
	Body V `json:"body"`
}

Form 数据表单

func NewReqForm

func NewReqForm(method, productID string, body V, options ...HeadOption) *Form

NewReqForm 生成请求数据表单

func (*Form) URLEncode

func (f *Form) URLEncode(mid string, key *crypts.PrivateKey) (string, error)

URLEncode 数据表单格式化为POST表单

type HeadOption

type HeadOption func(form *Form)

HeadOption 报文头配置项

func WithAccessType

func WithAccessType(v string) HeadOption

WithAccessType 设置接入类型:1 - 普通商户接入(默认);2 - 平台商户接入

func WithChannelType

func WithChannelType(v 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 Option

type Option func(c *Client)

Option 自定义设置项

func WithHttpClient

func WithHttpClient(cli *http.Client) Option

WithHttpClient 设置自定义 HTTP Client

func WithLogger

func WithLogger(fn func(ctx context.Context, err error, data map[string]string)) Option

WithLogger 设置日志记录

func WithPrivateKey

func WithPrivateKey(key *crypts.PrivateKey) Option

WithPrivateKey 设置商户RSA私钥

func WithPublicKey

func WithPublicKey(key *crypts.PublicKey) Option

WithPublicKey 设置平台RSA公钥

type V

type V = values.V

Jump to

Keyboard shortcuts

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