云闪付插件
This commit is contained in:
parent
38d27f53bb
commit
7ad047acd6
|
@ -85,9 +85,9 @@ func orderResp(request *proto.OrderRequest, resp po.OrderResp) *proto.OrderRespo
|
||||||
|
|
||||||
func (c *Config) queryReq(in *proto.QueryRequest, chNlId string) (*po.QueryReq, error) {
|
func (c *Config) queryReq(in *proto.QueryRequest, chNlId string) (*po.QueryReq, error) {
|
||||||
type OrderExtra struct {
|
type OrderExtra struct {
|
||||||
TransSeq string `json:"transSeq"` // 当前交易号
|
TransSeq string `json:"transSeq"` // 当前交易号
|
||||||
TransDtTm string `json:"transDtTm"` // 交易日期时间
|
TransDtTm string `json:"transDtTm"` // 交易日期时间
|
||||||
OrigTransSeq string `json:"origTransSeq"` // 原交易日期时间
|
OrigTransDtTm string `json:"origTransDtTm"` // 原交易日期时间
|
||||||
}
|
}
|
||||||
var e OrderExtra
|
var e OrderExtra
|
||||||
err := json.Unmarshal(in.Order.Extra, &e)
|
err := json.Unmarshal(in.Order.Extra, &e)
|
||||||
|
@ -102,8 +102,8 @@ func (c *Config) queryReq(in *proto.QueryRequest, chNlId string) (*po.QueryReq,
|
||||||
ChNlId: chNlId,
|
ChNlId: chNlId,
|
||||||
TransSeq: e.TransSeq, // 当前交易号
|
TransSeq: e.TransSeq, // 当前交易号
|
||||||
TransDtTm: e.TransDtTm, // 交易日期时间
|
TransDtTm: e.TransDtTm, // 交易日期时间
|
||||||
OrigTransDtTm: in.Order.OrderNo, // 原交易流水号
|
OrigTransDtTm: e.OrigTransDtTm, // 原交易流水号
|
||||||
OrigTransSeq: e.OrigTransSeq, // 原交易日期时间
|
OrigTransSeq: in.Order.OrderNo, // 原交易流水号
|
||||||
AcctEntityTp: vo.AcctEntityTp,
|
AcctEntityTp: vo.AcctEntityTp,
|
||||||
Mobile: mobile,
|
Mobile: mobile,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func config() []byte {
|
func config() []byte {
|
||||||
|
@ -36,14 +37,30 @@ func TestConfig(t *testing.T) {
|
||||||
var server = &UnionPayCpnService{}
|
var server = &UnionPayCpnService{}
|
||||||
|
|
||||||
func TestOrder(t *testing.T) {
|
func TestOrder(t *testing.T) {
|
||||||
|
type UnionPayOrderExtra struct {
|
||||||
|
TransDtTm string `json:"transDtTm"` // 交易日期时间 YYYYMMddHHmmss
|
||||||
|
ValidEndDtTm string `json:"validEndDtTm"` // 有效截止时间 yyyymmddhhmmss-按条件必填
|
||||||
|
TransDigest string `json:"transDigest"` // 交易摘要,最大200位,赠送积分说明,用于在云闪付APP内向用户展示获取说明-必填
|
||||||
|
}
|
||||||
|
now := time.Now()
|
||||||
|
a := now.Add(time.Hour * 24)
|
||||||
|
orderExtra := UnionPayOrderExtra{
|
||||||
|
TransDtTm: now.Format("20060102150405"),
|
||||||
|
ValidEndDtTm: a.Format("20060102150405"),
|
||||||
|
TransDigest: "测试红包",
|
||||||
|
}
|
||||||
|
orderExtraBytes, err := json.Marshal(orderExtra)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("orderExtra json marshal failed: %+v", err)
|
||||||
|
}
|
||||||
request := &proto.OrderRequest{
|
request := &proto.OrderRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Order: &proto.OrderRequest_Order{
|
Order: &proto.OrderRequest_Order{
|
||||||
OrderNo: "202409141047181834200102",
|
OrderNo: "202409141047181834200108",
|
||||||
Account: "18512869479",
|
Account: "18666173766",
|
||||||
Quantity: 1,
|
Quantity: 1,
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
Extra: []byte(`{"transDtTm":"20240914151102","validEndDtTm":"20241031235959","transDigest":"测试红包"}`),
|
Extra: orderExtraBytes,
|
||||||
},
|
},
|
||||||
Product: &proto.OrderRequest_Product{
|
Product: &proto.OrderRequest_Product{
|
||||||
ProductNo: "",
|
ProductNo: "",
|
||||||
|
@ -57,19 +74,35 @@ func TestOrder(t *testing.T) {
|
||||||
t.Errorf("Order() error = %v", err)
|
t.Errorf("Order() error = %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("%+v", got)
|
fmt.Printf("request order:%+v \n", request.Order)
|
||||||
|
fmt.Printf("request product:%+v \n", request.Product)
|
||||||
|
fmt.Printf("got:%+v \n", got)
|
||||||
assert.Equal(t, int(proto.Status_ING), int(got.Result.Status))
|
assert.Equal(t, int(proto.Status_ING), int(got.Result.Status))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQuery(t *testing.T) {
|
func TestQuery(t *testing.T) {
|
||||||
|
type UnionPayQueryExtra struct {
|
||||||
|
TransSeq string `json:"transSeq"` // 当前交易号
|
||||||
|
TransDtTm string `json:"transDtTm"` // 交易日期时间-YYYYMMddHHmmss
|
||||||
|
OrigTransDtTm string `json:"origTransDtTm"` // 原交易日期时间
|
||||||
|
}
|
||||||
|
extra := UnionPayQueryExtra{
|
||||||
|
TransSeq: fmt.Sprintf("%d", time.Now().UnixNano()),
|
||||||
|
TransDtTm: time.Now().Format("20060102150405"),
|
||||||
|
OrigTransDtTm: "20240918102040",
|
||||||
|
}
|
||||||
|
extraBytes, err := json.Marshal(extra)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("orderExtra json marshal failed: %+v", err)
|
||||||
|
}
|
||||||
request := &proto.QueryRequest{
|
request := &proto.QueryRequest{
|
||||||
Config: config(),
|
Config: config(),
|
||||||
Order: &proto.QueryRequest_Order{
|
Order: &proto.QueryRequest_Order{
|
||||||
OrderNo: "24082210051220960113", // 原交易号
|
OrderNo: "202409141047181834200108", // 原交易号
|
||||||
TradeNo: "",
|
TradeNo: "",
|
||||||
Account: "13975287758",
|
Account: "18666173766",
|
||||||
Extra: []byte(`{"transSeq":"v3-1","transDtTm":"20230710165534","origTransSeq":"20240822"}`),
|
Extra: extraBytes,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
t.Run("TestQuery", func(t *testing.T) {
|
t.Run("TestQuery", func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue