Documentation
¶
Overview ¶
Package unifiedorder 执行微信的下单操作
相对于 pay.Post,会便利很多,不需要每次都指定所有参数。
p := pay.New(...) oconf := unifiedorder.New(p, pay.TradeTypeJSSDK, ...) // 下单支付 o := oconf.NewOrder() o.Body = "..." o.Goods(...) o.Pay(...) // 另一笔支付操作 o = oconf.NewOrder() o.Body = "..." o.Goods(...) o.Pay(...)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BrandWCPayRequest ¶
type BrandWCPayRequest struct {
AppID string `json:"appId"`
TimeStamp string `json:"timeStamp"`
NonceString string `json:"nonceStr"`
Package string `json:"package"`
SignType string `json:"signType"`
PaySign string `json:"paySign"`
}
BrandWCPayRequest 返回给微信浏览器的数据
type Good ¶
type Good struct {
ID string `json:"goods_id"`
WxpayGoodsID string `json:"wxpay_goods_id,omitempty"`
Name string `json:"goods_name"`
Quantity int `json:"quantity"` // 数量
Price int `json:"price"` // 价格,单位:分
Category string `json:"goods_category,omitempty"`
Body string `json:"body,omitempty"`
}
Good 商品详情
type Order ¶
type Order struct {
DeviceInfo string // 设备号
SignType string // 签名类型
FeeType string // 货币类型,默认 CNY
SpbillCreateIP string // 终端 IP
ExpireIn time.Duration // 交易结束时间
NotifyURL string // 通知地址
TradeType string // 交易类型
Credit bool // 是否允许使用信用卡
Body string // 商品描述
Attach string // 附加数据
OutTradeNO string // 商户订单号
TotalFee int // 总金额
Start time.Time // 交易起始时间
Tag string // 商品标记
ProductID string // 商品 ID
OpenID string // 用户标识
// contains filtered or unexported fields
}
Order 订单数据
订单数据中,包含了大量相同的数据,这些数据在每次 支付时都重新声明是极大的浪费,所以建议先声明一个 包含这些公用数据的 Order 实例,之后用 Order.NewOrder() 生成一个新的 Order 实例,这个新的实例就继承这些数据。比如:
conf := unifiedorder.New(...) conf.DeviceInfo = "WEB" conf.SignType = pay.SignTypeMD5 o1 := conf.NewOrder() // 继承了 conf.DeviceInfo 等数据 o1.Body = "..." o1.Pay(...) o2 := conf.NewOrder() // 依然从 conf 继承了 DeviceInfo 等数据
type Return ¶
type Return struct {
TradeType string
PrepayID string
CodeURL string // 二维码链接
// contains filtered or unexported fields
}
Return 表示统一下单功能的返回值类型。
func (*Return) GetBrandWCPayRequest ¶
func (r *Return) GetBrandWCPayRequest(signType string) (*BrandWCPayRequest, error)
GetBrandWCPayRequest 获取 BrandWCPayRequest 数据
Click to show internal directories.
Click to hide internal directories.