150 lines
8.1 KiB
Go
150 lines
8.1 KiB
Go
package tonglianpayapi
|
||
|
||
//
|
||
//import (
|
||
// "crypto/md5"
|
||
// "fmt"
|
||
// "git.rosy.net.cn/baseapi/platformapi"
|
||
// "git.rosy.net.cn/baseapi/utils"
|
||
// "net/http"
|
||
// "strings"
|
||
//)
|
||
//
|
||
//const (
|
||
// TongLianMisPay = "https://cloudmiscash.allinpay.com/cloudMis-transaction" // 通联mis支付(基础收款用于一般无特殊支付业务需求的标准行业,如零售、餐饮类商户及场景)
|
||
// MisPayAction = "api/v2/process"
|
||
//)
|
||
//
|
||
//const (
|
||
// BusinessTypeBUSIORDERTRANS = "100000003" // 订单支付收款(不含查询流程)
|
||
// BusinessTypeBUSIORDERTRANSBANK = "100100003" // 订单支付银行卡收款(不含查询)
|
||
// BusinessTypeBUSIORDERTRANSQR = "100300003" // 订单支付扫码收款(不含查询)
|
||
// BusinessTypeBUSIORDERSALE = "100000002" // 订单支付收款(含查询流程)
|
||
// BusinessTypeBUSIORDERSALEBANK = "100100002" // 订单支付银行卡收款(含查询流程)
|
||
// BusinessTypeBUSIORDERSALEQR = "100300002" // 订单支付扫码收款(含查询流程)
|
||
//)
|
||
//
|
||
//func (a *API) signMisParam(businessID, licence string, custData *CustDataDetail) (sig string) {
|
||
// var signBuffer = new(strings.Builder)
|
||
// //signBuffer.Write([]byte(a.appID))
|
||
// signBuffer.Write([]byte("app_id_001"))
|
||
// signBuffer.Write([]byte(businessID))
|
||
// signBuffer.Write([]byte(fmt.Sprintf(`{"BUSINESS_ID":"%s","AMOUNT":"%s","ORDER_NO":"%s"}`, custData.BusinessId, custData.Amount, custData.OrderNo)))
|
||
// signBuffer.Write([]byte(licence))
|
||
// fmt.Println(signBuffer.String())
|
||
// binSig := md5.Sum([]byte(signBuffer.String()))
|
||
// sig = fmt.Sprintf("%x", binSig)
|
||
// return sig
|
||
//}
|
||
//
|
||
//func (a *API) AccessMisAPI(action string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||
// //params := make(map[string]interface{})
|
||
// //params["APP_ID"] = a.appID
|
||
// ////params["randomstr"] = utils.GetUUID()
|
||
// ////params["version"] = "12"
|
||
// //params = utils.MergeMaps(params, bizParams)
|
||
// //signStr := a.signParam(params)
|
||
// //params["SIGN_DATA"] = signStr
|
||
// fullURL := utils.GenerateGetURL(TongLianMisPay, action, nil)
|
||
// err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||
// func() *http.Request {
|
||
// request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
|
||
// request.Header.Set("charset", "UTF-8")
|
||
// request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||
// return request
|
||
// },
|
||
// a.config,
|
||
// func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||
// if jsonResult1 == nil {
|
||
// return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||
// }
|
||
// if err == nil {
|
||
// returnCode := utils.Interface2String(jsonResult1["RSP_CODE"])
|
||
// if returnCode != MisStatusSuccess {
|
||
// errLevel = platformapi.ErrLevelGeneralFail
|
||
// err = utils.NewErrorCode(utils.Interface2String(jsonResult1["errmsg"])+utils.Interface2String(jsonResult1["retmsg"]), returnCode)
|
||
// }
|
||
// retVal = jsonResult1
|
||
// }
|
||
// return errLevel, err
|
||
// })
|
||
// return retVal, err
|
||
//}
|
||
//
|
||
//// CreateMisPayOrder 创建订单(扫码枪,扫二维码支付)
|
||
//func (a *API) CreateMisPayOrder(param *OnMisPayReq, custData *CustDataDetail) (err error) {
|
||
// param.AppId = a.appID
|
||
// param.SignData = a.signMisParam(param.BusinessId, "", custData)
|
||
// params := utils.Struct2MapByJson(param)
|
||
// result, err := a.AccessMisAPI(MisPayAction, params)
|
||
// fmt.Println(result)
|
||
// return
|
||
//}
|
||
//
|
||
//type OnMisPayReq struct {
|
||
// AppId string `json:"APP_ID"` // 必填 应用分配ID
|
||
// BusinessId string `json:"BUSINESS_ID"` // 必填 业务类型
|
||
// CustData string `json:"CUST_DATA"` // 必填 具体的支付请求数据,JSON格式字符串
|
||
// CashId string `json:"CASH_ID"` // 必填 收银机款台号
|
||
// StoreId string `json:"STORE_ID"` // 必填 商户分店号
|
||
// SignData string `json:"SIGN_DATA"` // 必填 计算方法参照附录1
|
||
// AppPackageNm string `json:"APP_PACKAGE_NM"` // 非必填 指定APP包名
|
||
// AppClassNm string `json:"APP_CLASS_NM"` // 非必填 指定类名
|
||
// BusExtpara string `json:"BUS_EXTPARA"` // 非必填 业务扩展字段,用于特定功能,详见附录2
|
||
//}
|
||
//type CustDataDetail struct {
|
||
// BusinessId string `json:"BUSINESS_ID"` // 必填 业务类型
|
||
// Amount string `json:"AMOUNT"` // 必填 支付金额,十二位长度(单位:分,不足左补零)
|
||
// OrderNo string `json:"ORDER_NO"` // 必填 订单编号
|
||
// Memo string `json:"MEMO"` // 非必填 订单编号
|
||
// QrCode string `json:"QRCODE"` // 非必填 订单编号
|
||
// TramsCheck string `json:"TRANS_CHECK"` // 非必填 订单编号
|
||
// PageAppendContent string `json:"PAGE_APPEND_CONTENT"` // 非必填 订单编号
|
||
// ValidateInfo string `json:"VALIDATE_INFO"` // 非必填 订单编号
|
||
// BusInfo string `json:"BUS_INFO"` // 非必填 订单编号
|
||
//}
|
||
//
|
||
//type MisPayResp struct {
|
||
// RspCode string `json:"RSP_CODE"` // 云MIS系统服务调用返回码, 支付返回代码请参考RSP_DATA里支付结果字段
|
||
// RspData string `json:"RSP_DATA"` // 透传支付产品给云MIS的响应JSON字符串
|
||
// RspDesc string `json:"RSP_DESC"` // 交易级返回描述
|
||
// CloudMisTrxSsn string `json:"ClOUD_MIS_TRX_SSN"` // 交易成功返回,云MIS系统唯一流水号,用于查询或对账
|
||
//}
|
||
//
|
||
//type MisPayRspData struct {
|
||
// BusinessId string `json:"BUSINESS_ID"` // 必填 业务类型
|
||
// RejCode string `json:"REJCODE"` // 交易返回码
|
||
// RejCodeCn string `json:"REJCODE_CN"` // 交易返回码注释
|
||
// Cups string `json:"CUPS"` // 卡组织,银行卡为空 (ALP:支付宝 WXP:微信支付)
|
||
// MerchID string `json:"MERCH_ID"` // 商户编号
|
||
// TerID string `json:"TER_ID"` // 终端编号
|
||
// MerchName string `json:"MERCH_NAME"` // 商户名称
|
||
// BatchNo string `json:"BATCH_NO"` // 批次号
|
||
// TraceNo string `json:"TRACE_NO"` // 凭证号
|
||
// TransTicketNo string `json:"TRANS_TICKET_NO"` // 交易单号
|
||
// OrderNo string `json:"order_no"` // 订单编号
|
||
// Amount string `json:"AMOUNT"` // 支付金额,十二位长度(单位:分)
|
||
// RefNo string `json:"REF_NO"` // 系统参考号
|
||
// CarDno string `json:"CARDNO"` // 银行卡交易时返回卡号;扫码交易返回OPENID或USERID
|
||
// CardTypeIdenty string `json:"CARD_TYPE_IDENTY"` // 借贷记卡标识(银行卡) 0:借记 1:贷记
|
||
// WildCardSign string `json:"WILD_CARD_SIGN"` //内外卡标识(银行卡) 0:内卡 1:外卡
|
||
// ExpDate string `json:"EXP_DATE"` // 有效期
|
||
// Date string `json:"DATE"` // 支付日期
|
||
// Time string `json:"TIME"` // 支付时间
|
||
// PrintFlag string `json:"PRINT_FLAG"` // 是否打印小票(1:打印,0:未打印)
|
||
// CardFee string `json:"CARD_FEE"` // 手续费,十二位长度(单位:分)
|
||
// TransCheck string `json:"TRANS_CHECK"` // 交易唯一标识
|
||
// AuthNo string `json:"AUTH_NO"` // 授权码
|
||
// Sign string `json:"SIGN"` // 签名
|
||
// CardType string `json:"CARDTYPE"` // 卡类型
|
||
// TransChannel string `json:"TRANS_CHANNEL"` // 交易渠道
|
||
// IssNo string `json:"ISS_NO"` // 发卡行行号
|
||
// IssName string `json:"ISS_NAME"` // 发卡行名称
|
||
// Memo string `json:"MEMO"` // 备注信息
|
||
// PrtCommon string `json:"PRT_COMMON"` // 打印内容公共部分(仅用于简易终端版)
|
||
// PrtCardholder string `json:"PRT_CARDHOLDER"` // 打印内容持卡人联部分(仅用于简易终端版)
|
||
// PrtMerchant string `json:"PRT_MERCHANT"` // 打印内容商户联部分(仅用于简易终端版)
|
||
// DiscAmount string `json:"DISC_AMOUNT"` // 优惠金额
|
||
// ActuallyAmount string `json:"ACTUALLY_AMOUNT"` // 实付金额
|
||
//}
|