|
|
@@ -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) { |
|
|
|