mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-11 08:12:26 +08:00
fix some comment and struct field
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
var refundGateway = "https://api.mch.weixin.qq.com/secapi/pay/refund"
|
var refundGateway = "https://api.mch.weixin.qq.com/secapi/pay/refund"
|
||||||
|
|
||||||
//Refund Parameter
|
//RefundParams 调用参数
|
||||||
type RefundParams struct {
|
type RefundParams struct {
|
||||||
TransactionId string
|
TransactionID string
|
||||||
OutRefundNo string
|
OutRefundNo string
|
||||||
TotalFee string
|
TotalFee string
|
||||||
RefundFee string
|
RefundFee string
|
||||||
@@ -18,14 +18,14 @@ type RefundParams struct {
|
|||||||
RootCa string //ca证书
|
RootCa string //ca证书
|
||||||
}
|
}
|
||||||
|
|
||||||
//Refund request
|
//refundRequest 接口请求参数
|
||||||
type refundRequest struct {
|
type refundRequest struct {
|
||||||
AppID string `xml:"appid"`
|
AppID string `xml:"appid"`
|
||||||
MchID string `xml:"mch_id"`
|
MchID string `xml:"mch_id"`
|
||||||
NonceStr string `xml:"nonce_str"`
|
NonceStr string `xml:"nonce_str"`
|
||||||
Sign string `xml:"sign"`
|
Sign string `xml:"sign"`
|
||||||
SignType string `xml:"sign_type,omitempty"`
|
SignType string `xml:"sign_type,omitempty"`
|
||||||
TransactionId string `xml:"transaction_id"`
|
TransactionID string `xml:"transaction_id"`
|
||||||
OutRefundNo string `xml:"out_refund_no"`
|
OutRefundNo string `xml:"out_refund_no"`
|
||||||
TotalFee string `xml:"total_fee"`
|
TotalFee string `xml:"total_fee"`
|
||||||
RefundFee string `xml:"refund_fee"`
|
RefundFee string `xml:"refund_fee"`
|
||||||
@@ -33,7 +33,7 @@ type refundRequest struct {
|
|||||||
//NotifyUrl string `xml:"notify_url,omitempty"`
|
//NotifyUrl string `xml:"notify_url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//Refund Response
|
//RefundResponse 接口返回
|
||||||
type RefundResponse struct {
|
type RefundResponse struct {
|
||||||
ReturnCode string `xml:"return_code"`
|
ReturnCode string `xml:"return_code"`
|
||||||
ReturnMsg string `xml:"return_msg"`
|
ReturnMsg string `xml:"return_msg"`
|
||||||
@@ -44,10 +44,10 @@ type RefundResponse struct {
|
|||||||
ResultCode string `xml:"result_code,omitempty"`
|
ResultCode string `xml:"result_code,omitempty"`
|
||||||
ErrCode string `xml:"err_code,omitempty"`
|
ErrCode string `xml:"err_code,omitempty"`
|
||||||
ErrCodeDes string `xml:"err_code_des,omitempty"`
|
ErrCodeDes string `xml:"err_code_des,omitempty"`
|
||||||
TransactionId string `xml:"transaction_id,omitempty"`
|
TransactionID string `xml:"transaction_id,omitempty"`
|
||||||
OutTradeNo string `xml:"out_trade_no,omitempty"`
|
OutTradeNo string `xml:"out_trade_no,omitempty"`
|
||||||
OutRefundNo string `xml:"out_refund_no,omitempty"`
|
OutRefundNo string `xml:"out_refund_no,omitempty"`
|
||||||
RefundId string `xml:"refund_id,omitempty"`
|
RefundID string `xml:"refund_id,omitempty"`
|
||||||
RefundFee string `xml:"refund_fee,omitempty"`
|
RefundFee string `xml:"refund_fee,omitempty"`
|
||||||
SettlementRefundFee string `xml:"settlement_refund_fee,omitempty"`
|
SettlementRefundFee string `xml:"settlement_refund_fee,omitempty"`
|
||||||
TotalFee string `xml:"total_fee,omitempty"`
|
TotalFee string `xml:"total_fee,omitempty"`
|
||||||
@@ -57,7 +57,7 @@ type RefundResponse struct {
|
|||||||
CashFeeType string `xml:"cash_fee_type,omitempty"`
|
CashFeeType string `xml:"cash_fee_type,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//退款申请
|
//Refund 退款申请
|
||||||
func (pcf *Pay) Refund(p *RefundParams) (rsp RefundResponse, err error) {
|
func (pcf *Pay) Refund(p *RefundParams) (rsp RefundResponse, err error) {
|
||||||
nonceStr := util.RandomStr(32)
|
nonceStr := util.RandomStr(32)
|
||||||
param := make(map[string]interface{})
|
param := make(map[string]interface{})
|
||||||
@@ -69,7 +69,7 @@ func (pcf *Pay) Refund(p *RefundParams) (rsp RefundResponse, err error) {
|
|||||||
param["refund_fee"] = p.RefundFee
|
param["refund_fee"] = p.RefundFee
|
||||||
param["total_fee"] = p.TotalFee
|
param["total_fee"] = p.TotalFee
|
||||||
param["sign_type"] = "MD5"
|
param["sign_type"] = "MD5"
|
||||||
param["transaction_id"] = p.TransactionId
|
param["transaction_id"] = p.TransactionID
|
||||||
|
|
||||||
bizKey := "&key=" + pcf.PayKey
|
bizKey := "&key=" + pcf.PayKey
|
||||||
str := orderParam(param, bizKey)
|
str := orderParam(param, bizKey)
|
||||||
@@ -80,7 +80,7 @@ func (pcf *Pay) Refund(p *RefundParams) (rsp RefundResponse, err error) {
|
|||||||
NonceStr: nonceStr,
|
NonceStr: nonceStr,
|
||||||
Sign: sign,
|
Sign: sign,
|
||||||
SignType: "MD5",
|
SignType: "MD5",
|
||||||
TransactionId: p.TransactionId,
|
TransactionID: p.TransactionID,
|
||||||
OutRefundNo: p.OutRefundNo,
|
OutRefundNo: p.OutRefundNo,
|
||||||
TotalFee: p.TotalFee,
|
TotalFee: p.TotalFee,
|
||||||
RefundFee: p.RefundFee,
|
RefundFee: p.RefundFee,
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ func PostXML(uri string, obj interface{}) ([]byte, error) {
|
|||||||
return ioutil.ReadAll(response.Body)
|
return ioutil.ReadAll(response.Body)
|
||||||
}
|
}
|
||||||
|
|
||||||
//http TLS
|
//httpWithTLS CA证书
|
||||||
func httpWithTLS(rootCa, key string) (*http.Client, error) {
|
func httpWithTLS(rootCa, key string) (*http.Client, error) {
|
||||||
var client *http.Client
|
var client *http.Client
|
||||||
certData, err := ioutil.ReadFile(rootCa)
|
certData, err := ioutil.ReadFile(rootCa)
|
||||||
@@ -165,7 +165,7 @@ func httpWithTLS(rootCa, key string) (*http.Client, error) {
|
|||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//将Pkcs12转成Pem
|
//pkcs12ToPem 将Pkcs12转成Pem
|
||||||
func pkcs12ToPem(p12 []byte, password string) tls.Certificate {
|
func pkcs12ToPem(p12 []byte, password string) tls.Certificate {
|
||||||
blocks, err := pkcs12.ToPEM(p12, password)
|
blocks, err := pkcs12.ToPEM(p12, password)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -187,7 +187,7 @@ func pkcs12ToPem(p12 []byte, password string) tls.Certificate {
|
|||||||
return cert
|
return cert
|
||||||
}
|
}
|
||||||
|
|
||||||
//Post XML with TLS
|
//PostXMLWithTLS:Post XML with TLS
|
||||||
func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error) {
|
func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error) {
|
||||||
xmlData, err := xml.Marshal(obj)
|
xmlData, err := xml.Marshal(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user