通联宝支付其他支付接口新增
This commit is contained in:
@@ -13,12 +13,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
prodURL = "https://vsp.allinpay.com/apiweb"
|
prodURL = "https://vsp.allinpay.com/apiweb"
|
||||||
sepcAction = "unitorder/pay"
|
prodURL2 = "https://syb.allinpay.com/apiweb"
|
||||||
|
sepcAction = "unitorder/pay"
|
||||||
|
sepcAction2 = "h5unionpay/unionorder"
|
||||||
|
|
||||||
sigKey = "sign"
|
sigKey = "sign"
|
||||||
PayTypeWxXcx = "W06"
|
PayTypeWxXcx = "W06"
|
||||||
PayTypeZfbApp = "A03"
|
PayTypeZfbApp = "A03"
|
||||||
|
PayTypeZfbJS = "A02"
|
||||||
|
|
||||||
ResponseCodeSuccess = "SUCCESS"
|
ResponseCodeSuccess = "SUCCESS"
|
||||||
ResponseCodeFail = "FAIL"
|
ResponseCodeFail = "FAIL"
|
||||||
@@ -97,6 +100,15 @@ type PayRefundResult struct {
|
|||||||
TrxCode string `json:"trxCode"`
|
TrxCode string `json:"trxCode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CreateH5UnitorderOrderParam struct {
|
||||||
|
Trxamt int `json:"trxamt"` //交易金额 单位为分
|
||||||
|
Reqsn string `json:"reqsn"` //商户交易单号
|
||||||
|
NotifyUrl string `json:"notifyUrl"` //接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
|
||||||
|
Charset string `json:"charset"`
|
||||||
|
Returl string `json:"returl"`
|
||||||
|
Body string `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
func New(appID, appKey, cusID, subAppid string, config ...*platformapi.APIConfig) *API {
|
func New(appID, appKey, cusID, subAppid string, config ...*platformapi.APIConfig) *API {
|
||||||
curConfig := platformapi.DefAPIConfig
|
curConfig := platformapi.DefAPIConfig
|
||||||
if len(config) > 0 {
|
if len(config) > 0 {
|
||||||
@@ -138,12 +150,18 @@ func (a *API) AccessAPI(action string, bizParams map[string]interface{}) (retVal
|
|||||||
params = utils.MergeMaps(params, bizParams)
|
params = utils.MergeMaps(params, bizParams)
|
||||||
if action == sepcAction {
|
if action == sepcAction {
|
||||||
// params["paytype"] = payType
|
// params["paytype"] = payType
|
||||||
params["sub_appid"] = a.subAppid
|
if bizParams["paytype"] == PayTypeWxXcx {
|
||||||
|
params["sub_appid"] = a.subAppid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
signStr := a.signParam(params)
|
signStr := a.signParam(params)
|
||||||
params["sign"] = signStr
|
params["sign"] = signStr
|
||||||
fullURL := utils.GenerateGetURL(prodURL, action, nil)
|
var fullURL string
|
||||||
|
if action == sepcAction2 {
|
||||||
|
fullURL = utils.GenerateGetURL(prodURL2, action, nil)
|
||||||
|
} else {
|
||||||
|
fullURL = utils.GenerateGetURL(prodURL, action, nil)
|
||||||
|
}
|
||||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||||
func() *http.Request {
|
func() *http.Request {
|
||||||
request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||||
@@ -197,3 +215,13 @@ func (a *API) PayRefund(param *PayRefundParam) (result *PayRefundResult, err err
|
|||||||
}
|
}
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) CreateH5UnitorderOrder(param *CreateH5UnitorderOrderParam) (err error) {
|
||||||
|
params := make(map[string]interface{})
|
||||||
|
params["trxamt"] = param.Trxamt
|
||||||
|
params["reqsn"] = param.Reqsn
|
||||||
|
params["charset"] = param.Charset
|
||||||
|
params["body"] = param.Body
|
||||||
|
_, err = a.AccessAPI(sepcAction2, params)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,13 +23,24 @@ func init() {
|
|||||||
|
|
||||||
func TestCreateUnitorderOrder(t *testing.T) {
|
func TestCreateUnitorderOrder(t *testing.T) {
|
||||||
result, err := api.CreateUnitorderOrder(&CreateUnitorderOrderParam{
|
result, err := api.CreateUnitorderOrder(&CreateUnitorderOrderParam{
|
||||||
Reqsn: "88320316370927",
|
Reqsn: "88320943177180",
|
||||||
Trxamt: 10,
|
Trxamt: 10,
|
||||||
NotifyUrl: "http://callback.test.jxc4.com/tlpay/msg/",
|
NotifyUrl: "http://callback.test.jxc4.com/tlpay/msg/",
|
||||||
Acct: "ojWb10M_8kV8NT0aZJa6A5umG1c8",
|
Acct: "ojWb10M_8kV8NT0aZJa6A5umG1c8",
|
||||||
|
PayType: PayTypeZfbJS,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCreateH5UnitorderOrder(t *testing.T) {
|
||||||
|
api.CreateH5UnitorderOrder(&CreateH5UnitorderOrderParam{
|
||||||
|
Reqsn: "88320943177180",
|
||||||
|
Trxamt: 1,
|
||||||
|
NotifyUrl: "http://callback.test.jxc4.com/tlpay/msg/",
|
||||||
|
Charset: "UTF-8",
|
||||||
|
Body: "test",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user