mch

package
v0.0.0-...-5493e5b Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

README

微信支付证书

微信支付API共四份(证书pkcs12格式、证书pem格式、证书密钥pem格式、CA证书),为接口中强制要求时需携带的证书文件。

证书属于敏感信息,请妥善保管不要泄露和被他人复制。

不同开发语言下的证书格式不同,以下为说明指引:

证书pkcs12格式(apiclient_cert.p12)
	
包含了私钥信息的证书文件,为p12(pfx)格式,由微信支付签发给您用来标识和界定您的身份
部分安全性要求较高的API需要使用该证书来确认您的调用身份
windows上可以直接双击导入系统,导入过程中会提示输入证书密码,证书密码默认为您的商户ID(如:10010000)

证书pem格式(apiclient_cert.pem)

从apiclient_cert.p12中导出证书部分的文件,为pem格式,请妥善保管不要泄漏和被他人复制
部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供
您也可以使用openssl命令来自己导出:openssl pkcs12 -clcerts -nokeys -in apiclient_cert.p12 -out apiclient_cert.pem

证书密钥pem格式(apiclient_key.pem)

从apiclient_cert.p12中导出密钥部分的文件,为pem格式
部分开发语言和环境,不能直接使用p12文件,而需要使用pem,所以为了方便您使用,已为您直接提供
您也可以使用openssl命令来自己导出:openssl pkcs12 -nocerts -in apiclient_cert.p12 -out apiclient_key.pem

CA证书(rootca.pem)

微信支付api服务器上也部署了证明微信支付身份的服务器证书,您在使用api进行调用时也需要验证所调用服务器及域名的真实性
该文件为签署微信支付证书的权威机构的根证书,可以用来验证微信支付服务器证书的真实性
某些环境和工具已经内置了若干权威机构的根证书,无需引用该证书也可以正常进行验证,这里提供给您在未内置所必须根证书的环境中载入使用

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MchCommonConfig *CommonConfig
	MchClient       *core.Client
	MchTLSClient    *core.Client
)

Functions

func CloseOrder2

func CloseOrder2(outTradeNo string) (err error)

CloseOrder2 关闭订单.

func GetInt64Str

func GetInt64Str(d int64) string

func GetIntStr

func GetIntStr(d int) string

func GetLocalIp

func GetLocalIp() string

func GetMchBillno

func GetMchBillno() string

微信红包 商户订单号

func GetOutRefundNo

func GetOutRefundNo() string

生成退款订单号

func GetOutTradeNo

func GetOutTradeNo() string

生成商品订单号

func GetPartnerRefundNo

func GetPartnerRefundNo() string

企业付款 商户订单号

func InitWechatMch

func InitWechatMch(app_id, mch_id, api_key string, certKeys ...string) error

构建通用配置

func JsapiUnifiedOrder

func JsapiUnifiedOrder(totalFee int64, openId, outTradeNo, body, spbillCreateIP, notifyURL, detail, attach, goodsTag string) (resp *pay.UnifiedOrderResponse, err error)

简化 wechat.v2 中部分参数

totalFee 订单总金额,单位为分,详见支付金额 openId 用户在商户appid下的唯一标识 outTradeNo 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号 body 商品或支付单简要描述 spbillCreateIP APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP notifyURL 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数 detail 商品名称明细列表。 attach 附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据

UnifiedOrderResponse PrepayId为微信生成预支付绘画标示,用于后续接口使用,有效期为两小时 TradeType为取值如下:JSAPI,NATIVE,APP, JSAPI--公众号支付、NATIVE--原生扫码支付、APP--app支付,统一下单接口trade_type的传参可参考这里 MICROPAY--刷卡支付,刷卡支付有单独的支付接口,不调用统一下单接口

统一下单

func Md5

func Md5(key string) string

func MicroPay2

func MicroPay2(totalFee int64, outTradeNo, body, spbillCreateIP, authCode string) (resp *pay.MicroPayResponse, err error)

func OrderQuery2

func OrderQuery2(outTradeNo string, params ...string) (resp *pay.OrderQueryResponse, err error)

查询订单

func Refund2

func Refund2(totalFee, refundFee int64, outTradeNo, outRefundNo string, params ...string) (resp *pay.RefundResponse,
	err error)

Refund 申请退款. NOTE: 请求需要双向证书.

func RefundQuery2

func RefundQuery2(outTradeNo string, params ...string) (resp *pay.RefundQueryResponse,
	err error)

RefundQuery 查询退款. out_trade_no // 商户订单号 transaction_id // 微信订单号 out_refund_no // 商户退款单号 refund_id // 微信退款单号

func Reverse2

func Reverse2(outTradeNo string, params ...string) (resp *pay.ReverseResponse, err error)

Reverse 撤销订单. NOTE: 请求需要双向证书.

func UnifiedOrder

func UnifiedOrder(req *pay.UnifiedOrderRequest) (resp *pay.UnifiedOrderResponse, err error)

Types

type CommonConfig

type CommonConfig struct {
	AppId  string `json:"app_id"`  //微信分配的公众号id
	MchId  string `json:"mch_id"`  //微信支付分配的商户号
	ApiKey string `json:"api_key"` //微信支付分配的商户号
}

func (*CommonConfig) SetApiKey

func (m *CommonConfig) SetApiKey(api_key string)

func (*CommonConfig) SetAppId

func (m *CommonConfig) SetAppId(app_id string)

func (*CommonConfig) SetMchId

func (m *CommonConfig) SetMchId(mch_id string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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