本文整理匯總了Golang中github.com/chanxuehong/wechat/v2/mch/core.Client類的典型用法代碼示例。如果您正苦於以下問題:Golang Client類的具體用法?Golang Client怎麽用?Golang Client使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Client類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetTransferInfo
// 查詢企業付款.
// NOTE: 請求需要雙向證書
func GetTransferInfo(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo", req)
}
示例2: Refund
// 申請退款.
// NOTE: 請求需要雙向證書.
func Refund(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/secapi/pay/refund", req)
}
示例3: Refund2
func Refund2(clt *core.Client, req *RefundRequest) (resp *RefundResponse, err error) {
m1 := make(map[string]string, 16)
m1["appid"] = clt.AppId()
m1["mch_id"] = clt.MchId()
if req.DeviceInfo != "" {
m1["device_info"] = req.DeviceInfo
}
if req.NonceStr != "" {
m1["nonce_str"] = req.NonceStr
} else {
m1["nonce_str"] = string(rand.NewHex())
}
if req.TransactionId != "" {
m1["transaction_id"] = req.TransactionId
}
if req.OutTradeNo != "" {
m1["out_trade_no"] = req.OutTradeNo
}
m1["out_refund_no"] = req.OutRefundNo
m1["total_fee"] = strconv.FormatInt(req.TotalFee, 10)
m1["refund_fee"] = strconv.FormatInt(req.RefundFee, 10)
if req.RefundFeeType != "" {
m1["refund_fee_type"] = req.RefundFeeType
}
if req.OperUserId != "" {
m1["op_user_id"] = req.OperUserId
} else {
m1["op_user_id"] = clt.MchId()
}
m1["sign"] = core.Sign(m1, clt.ApiKey(), md5.New)
m2, err := Refund(clt, m1)
if err != nil {
return
}
// 判斷業務狀態
resultCode, ok := m2["result_code"]
if !ok {
err = core.ErrNotFoundResultCode
return
}
if resultCode != core.ResultCodeSuccess {
err = &core.BizError{
ResultCode: resultCode,
ErrCode: m2["err_code"],
ErrCodeDesc: m2["err_code_des"],
}
return
}
resp = &RefundResponse{
AppId: m2["appid"],
MchId: m2["mch_id"],
TransactionId: m2["transaction_id"],
OutTradeNo: m2["out_trade_no"],
OutRefundNo: m2["out_refund_no"],
RefundId: m2["refund_id"],
DeviceInfo: m2["device_info"],
RefundChannel: m2["refund_channel"],
FeeType: m2["fee_type"],
}
var (
n int64
str string
)
if n, err = strconv.ParseInt(m2["refund_fee"], 10, 64); err != nil {
err = fmt.Errorf("parse refund_fee:%q to int64 failed: %s", m2["refund_fee"], err.Error())
return
} else {
resp.RefundFee = n
}
if n, err = strconv.ParseInt(m2["total_fee"], 10, 64); err != nil {
err = fmt.Errorf("parse total_fee:%q to int64 failed: %s", m2["total_fee"], err.Error())
return
} else {
resp.TotalFee = n
}
if n, err = strconv.ParseInt(m2["cash_fee"], 10, 64); err != nil {
err = fmt.Errorf("parse cash_fee:%q to int64 failed: %s", m2["cash_fee"], err.Error())
return
} else {
resp.CashFee = n
}
if str = m2["settlement_refund_fee"]; str != "" {
if n, err = strconv.ParseInt(str, 10, 64); err != nil {
err = fmt.Errorf("parse settlement_refund_fee:%q to int64 failed: %s", str, err.Error())
return
} else {
resp.SettlementRefundFee = util.Int64(n)
}
}
if str = m2["settlement_total_fee"]; str != "" {
if n, err = strconv.ParseInt(str, 10, 64); err != nil {
err = fmt.Errorf("parse settlement_total_fee:%q to int64 failed: %s", str, err.Error())
return
} else {
//.........這裏部分代碼省略.........
示例4: OrderQuery
// 查詢訂單.
func OrderQuery(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/pay/orderquery", req)
}
示例5: OrderQuery2
func OrderQuery2(clt *core.Client, req *OrderQueryRequest) (resp *OrderQueryResponse, err error) {
m1 := make(map[string]string, 8)
m1["appid"] = clt.AppId()
m1["mch_id"] = clt.MchId()
if req.TransactionId != "" {
m1["transaction_id"] = req.TransactionId
}
if req.OutTradeNo != "" {
m1["out_trade_no"] = req.OutTradeNo
}
if req.NonceStr != "" {
m1["nonce_str"] = req.NonceStr
} else {
m1["nonce_str"] = string(rand.NewHex())
}
m1["sign"] = core.Sign(m1, clt.ApiKey(), md5.New)
m2, err := OrderQuery(clt, m1)
if err != nil {
return
}
// 判斷業務狀態
resultCode, ok := m2["result_code"]
if !ok {
err = core.ErrNotFoundResultCode
return
}
if resultCode != core.ResultCodeSuccess {
err = &core.BizError{
ResultCode: resultCode,
ErrCode: m2["err_code"],
ErrCodeDesc: m2["err_code_des"],
}
return
}
resp = &OrderQueryResponse{
AppId: m2["appid"],
MchId: m2["mch_id"],
OpenId: m2["openid"],
TradeType: m2["trade_type"],
TradeState: m2["trade_state"],
BankType: m2["bank_type"],
TransactionId: m2["transaction_id"],
OutTradeNo: m2["out_trade_no"],
TimeEnd: m2["time_end"],
TradeStateDesc: m2["trade_state_desc"],
}
var (
n int64
id int
str string
)
if n, err = strconv.ParseInt(m2["total_fee"], 10, 64); err != nil {
err = fmt.Errorf("parse total_fee:%q to int64 failed: %s", m2["total_fee"], err.Error())
return
} else {
resp.TotalFee = n
}
if n, err = strconv.ParseInt(m2["cash_fee"], 10, 64); err != nil {
err = fmt.Errorf("parse cash_fee:%q to int64 failed: %s", m2["cash_fee"], err.Error())
return
} else {
resp.CashFee = n
}
resp.DeviceInfo = m2["device_info"]
if str = m2["is_subscribe"]; str != "" {
if str == "Y" || str == "y" {
resp.IsSubscribe = util.Bool(true)
} else {
resp.IsSubscribe = util.Bool(false)
}
}
if str = m2["settlement_total_fee"]; str != "" {
if n, err = strconv.ParseInt(str, 10, 64); err != nil {
err = fmt.Errorf("parse settlement_total_fee:%q to int64 failed: %s", str, err.Error())
return
} else {
resp.SettlementTotalFee = util.Int64(n)
}
}
resp.FeeType = m2["fee_type"]
resp.CashFeeType = m2["cash_fee_type"]
if str = m2["coupon_fee"]; str != "" {
if n, err = strconv.ParseInt(str, 10, 64); err != nil {
err = fmt.Errorf("parse coupon_fee:%q to int64 failed: %s", str, err.Error())
return
} else {
resp.CouponFee = util.Int64(n)
}
}
if str = m2["coupon_count"]; str != "" {
if n, err = strconv.ParseInt(str, 10, 32); err != nil {
err = fmt.Errorf("parse coupon_count:%q to int failed: %s", str, err.Error())
return
} else {
//.........這裏部分代碼省略.........
示例6: UnifiedOrder
// 統一下單.
func UnifiedOrder(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.core.weixin.qq.com/pay/unifiedorder", req)
}
示例7: MicroPay
// 提交刷卡支付.
func MicroPay(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/pay/micropay", req)
}
示例8: AuthCodeToOpenId
// 授權碼查詢OPENID接口.
func AuthCodeToOpenId(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/tools/authcodetoopenid", req)
}
示例9: QueryCoupon
// 查詢代金券信息.
func QueryCoupon(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.core.weixin.qq.com/promotion/query_coupon", req)
}
示例10: SendRedPack
// 紅包發放.
// NOTE: 請求需要雙向證書
func SendRedPack(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack", req)
}
示例11: QueryCouponStock
// 查詢代金券批次信息.
func QueryCouponStock(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/query_coupon_stock", req)
}
示例12: CloseOrder
// 關閉訂單.
func CloseOrder(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/pay/closeorder", req)
}
示例13: Report
// 測速上報.
func Report(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/payitil/report", req)
}
示例14: RefundQuery
// 查詢退款.
func RefundQuery(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.core.weixin.qq.com/pay/refundquery", req)
}
示例15: ShortURL
// 轉換短鏈接.
func ShortURL(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
return clt.PostXML("https://api.mch.weixin.qq.com/tools/shorturl", req)
}