Skip to content
/ unionpay Public

Implementation of china unionpay backend for app transaction 中国银联手机支付控件后端实现

License

Notifications You must be signed in to change notification settings

imzjy/unionpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

unionpay

中国银联手机控件支付后端实现

Implemenation of China unionpay backend for mobile app transaction with golang

usage

//初始化
cfg := &unionpay.UnionpayConfig{
	SignKeyPath:    "sign key file path",
	SignCertPath:   "sign cert file path",
	VerifyCertPath: "verify cert file path",

	CallbackUrl: "服务端回调URL",
	MerId:       "商户号",
	AppTransUrl: "移动应用交易URL",
}
appTrans = unionpay.NewAppTrans(cfg)

//获取tn,手机端得到tn后就可以使用这个tn发起支付调用
tn, err := appTrans.Submit(orderId, orderAmount, orderDescription)
if err != nil {
	log(err)
	return
}

//回调接口校验
respVal, err := unionpay.ParseResponseMsg(respBody)
if err != nil {
	log(err)
	return
}

for rk, rv := range respVal {
	decVal, err := unionpay.UrlDecode(rv)
	if err == nil {
		respVal[rk] = decVal
	}
}

err = appTrans.Validate(respVal)
if err != nil {
	log(err)
}

documentation

Please refer to gowalker

About

Implementation of china unionpay backend for app transaction 中国银联手机支付控件后端实现

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages