소스 검색

更新

master
huangjiajun 1 년 전
부모
커밋
e88d5b6c2c
2개의 변경된 파일30개의 추가작업 그리고 0개의 파일을 삭제
  1. +22
    -0
      lib/local_wechat/api.go
  2. +8
    -0
      pay/pay_by_own.go

+ 22
- 0
lib/local_wechat/api.go 파일 보기

@@ -7,6 +7,7 @@ import (
"fmt"
"github.com/iGoogle-ink/gopay"
"github.com/iGoogle-ink/gopay/pkg/util"
"github.com/iGoogle-ink/gopay/pkg/xlog"
"github.com/iGoogle-ink/gopay/wechat"
v3 "github.com/iGoogle-ink/gopay/wechat/v3"
"strconv"
@@ -44,6 +45,27 @@ func NewClient(appId, mchId, apiKey string, isProd bool) *wechat.Client {
//client.AddCertFileContent()
return client
}
func TradeAppRefund(client *wechat.Client, subject, transactionId, outRefundNo, totalFee, amount, p12Path, notifyUrl string) (*wechat.RefundResponse, gopay.BodyMap, error) {
// 初始化 BodyMap
bm := make(gopay.BodyMap)
bm.Set("transaction_id", transactionId).
Set("nonce_str", util.GetRandomString(32)).
Set("sign_type", wechat.SignType_MD5).
Set("out_refund_no", outRefundNo).
Set("total_fee", int(zhios_pay_utils.StrToFloat64(totalFee)*100)).
Set("refund_fee", int(zhios_pay_utils.StrToFloat64(amount)*100)).
Set("refund_desc", subject).
Set("notify_url", notifyUrl)
wxRsp, resBm, err := client.Refund(bm, nil, nil, p12Path)
fmt.Println(wxRsp)
fmt.Println(resBm)
if err != nil {
xlog.Error(err)
fmt.Println(err)
return wxRsp, resBm, err
}
return wxRsp, resBm, nil
}

// TradeAppPay is 微信APP支付
func TradeAppPay(client *wechat.Client, subject, orderID, amount, notifyUrl string) (map[string]string, error) {


+ 8
- 0
pay/pay_by_own.go 파일 보기

@@ -6,6 +6,8 @@ import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
zhios_pay_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/utils"
"fmt"
"github.com/iGoogle-ink/gopay"
"github.com/iGoogle-ink/gopay/wechat"
"github.com/pkg/errors"
)

@@ -133,3 +135,9 @@ func WxAppJSAPIPay(params map[string]string) (map[string]string, error) {
r, err := local_wxpay.TradeJSAPIPay(client, params["subject"], params["ord_id"], params["amount"], params["notify_url"], params["third_party_wechat_openid"])
return r, err
}

func WxAppRefund(params map[string]string) (*wechat.RefundResponse, gopay.BodyMap, error) {
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true)
r, r1, err := local_wxpay.TradeAppRefund(client, params["subject"], params["transaction_id"], params["out_refund_no"], params["total_fee"], params["amount"], params["p12_str"], params["notify_url"])
return r, r1, err
}

불러오는 중...
취소
저장