epay

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SubmitUrl = "/submit.php"
	MAPIUrl   = "/mapi.php"
)

Variables

This section is empty.

Functions

func GenerateParams

func GenerateParams(params map[string]string, secret string) map[string]string

GenerateParams 生成加签参数

Types

type Client

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

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient 创建一个新的易支付客户端

func (*Client) MApiSubmit

func (c *Client) MApiSubmit(ctx context.Context, args *MApiSubmitArgs) (*MApiSubmitRes, *http.Response, error)

func (*Client) Submit

func (c *Client) Submit(_ context.Context, args *SubmitArgs) (string, map[string]string, error)

Submit implements Service.Submit

func (*Client) Verify

func (c *Client) Verify(_ context.Context, params map[string]string) (*VerifyRes, error)

type CommonErrorRes

type CommonErrorRes struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type Config

type Config struct {
	PartnerID int
	AppSecret string
	Endpoint  string
}

type DeviceType

type DeviceType string
var (
	PC     DeviceType = "pc"     // PC PC端
	MOBILE DeviceType = "mobile" // MOBILE 移动端
	WECHAT DeviceType = "wechat" // WECHAT 微信
)

type MApiSubmitArgs

type MApiSubmitArgs struct {
	Type       PaymentType `json:"type"`             // Type 支付类型
	OutTradeNo string      `json:"out_trade_no"`     // OutTradeNo 商户订单号
	NotifyUrl  string      `json:"notify_url"`       // NotifyUrl 异步通知地址
	ReturnUrl  *string     `json:"return_url"`       // ReturnUrl 同步通知地址
	Name       string      `json:"name"`             // Name 商品名称
	Money      string      `json:"money"`            // Money 金额 保留两位小数
	ClientIP   string      `json:"clientip"`         // ClientIP 客户端IP
	Device     *DeviceType `json:"device,omitempty"` // Device 设备类型
	Param      *string     `json:"param,omitempty"`  // Param 附加参数
	Sign       string      `json:"sign"`             // Sign 签名
	SignType   string      `json:"sign_type"`        // SignType 签名类型
}

type MApiSubmitRes

type MApiSubmitRes struct {
	Code      int    `json:"code"`
	Msg       string `json:"msg"`
	TradeNo   string `json:"trade_no"`
	PayUrl    string `json:"payurl"`
	QRCode    string `json:"qrcode"`
	UrlScheme string `json:"urlscheme"`
}

type PaymentType

type PaymentType string
var (
	Alipay    PaymentType = "alipay" // Alipay 支付宝
	WechatPay PaymentType = "wxpay"  // WechatPay 微信
)

type Service

type Service interface {
	Submit(ctx context.Context, args *SubmitArgs) (string, map[string]string, error) // Submit 生成支付链接和参数
	Verify(ctx context.Context, params map[string]string) (*VerifyRes, error)        // Verify 验证回调参数是否符合签名

	MApiSubmit(ctx context.Context, args *MApiSubmitArgs) (*MApiSubmitRes, *http.Response, error) // MApiSubmit 生成支付链接和参数
}

Service 易支付API

type SubmitArgs

type SubmitArgs struct {
	Type           PaymentType // 支付类型
	ServiceTradeNo string      // 商家订单号
	Name           string      // 商品名称
	Money          string      // 金额
	NotifyUrl      string      // 异步通知地址
	ReturnUrl      string      // 返回地址
}

type VerifyRes

type VerifyRes struct {
	Type           PaymentType // 支付类型
	TradeNo        string      `mapstructure:"trade_no"`     // 易支付订单号
	ServiceTradeNo string      `mapstructure:"out_trade_no"` // 商家订单号
	Name           string      ``                            // 商品名称
	Money          string      ``                            // 金额
	TradeStatus    string      `mapstructure:"trade_status"` // 订单支付状态
	VerifyStatus   bool        `mapstructure:"-"`            // 签名检验
}

Jump to

Keyboard shortcuts

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