优化结构
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"kra/internal/biz/system"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -18,8 +19,6 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"kra/internal/biz"
|
||||
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/allinpay"
|
||||
)
|
||||
@@ -121,8 +120,8 @@ func TestAllinPayTrxIDCreateRejectsResponseWithoutTransactionID(t *testing.T) {
|
||||
_, _ = w.Write(response)
|
||||
}))
|
||||
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &biz.PaymentRequest{
|
||||
Provider: biz.PaymentAllinPay, TradeNo: "MERCHANT-TRXID-MISSING", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-TRXID-MISSING", Subject: "subject",
|
||||
Amount: 100, Currency: "CNY",
|
||||
}, allinPayTestConfig(privateKey, publicKey, allinpay.OrderTypeTrxId))
|
||||
if err == nil || !strings.Contains(strings.ToLower(err.Error()), "trxid") {
|
||||
@@ -132,8 +131,8 @@ func TestAllinPayTrxIDCreateRejectsResponseWithoutTransactionID(t *testing.T) {
|
||||
|
||||
func TestAllinPayNativeCreateRejectsTrxIDLookupMode(t *testing.T) {
|
||||
_, privateKey, publicKey := allinPayTestKeys(t)
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &biz.PaymentRequest{
|
||||
Provider: biz.PaymentAllinPay, TradeNo: "MERCHANT-NATIVE-TRXID", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-NATIVE-TRXID", Subject: "subject",
|
||||
Amount: 100, Currency: "CNY", Extra: map[string]any{"method": "native", "expiretime": "20261231235959"},
|
||||
}, allinPayTestConfig(privateKey, publicKey, allinpay.OrderTypeTrxId))
|
||||
if err == nil || !strings.Contains(strings.ToLower(err.Error()), "native") || !strings.Contains(strings.ToLower(err.Error()), "trxid") {
|
||||
@@ -142,8 +141,8 @@ func TestAllinPayNativeCreateRejectsTrxIDLookupMode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllinPayCreateRejectsUnknownMethodBeforeClient(t *testing.T) {
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &biz.PaymentRequest{
|
||||
Provider: biz.PaymentAllinPay, TradeNo: "MERCHANT-UNKNOWN-METHOD", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-UNKNOWN-METHOD", Subject: "subject",
|
||||
Amount: 100, Currency: "CNY", Extra: map[string]any{"method": "unsupported"},
|
||||
}, nil)
|
||||
if err == nil || !strings.Contains(err.Error(), "不支持的下单方式") {
|
||||
@@ -249,8 +248,8 @@ func TestAllinPayRefundUsesConfiguredLookupIdentity(t *testing.T) {
|
||||
_, _ = w.Write(response)
|
||||
}))
|
||||
|
||||
result, err := (&allinpayAdapter{}).Refund(context.Background(), &biz.PaymentRefundRequest{
|
||||
Provider: biz.PaymentAllinPay, TradeNo: tc.tradeNo, QueryID: tc.queryID,
|
||||
result, err := (&allinpayAdapter{}).Refund(context.Background(), &system.PaymentRefundRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: tc.tradeNo, QueryID: tc.queryID,
|
||||
RefundNo: "REFUND-1", Amount: 40, TotalAmount: 100, Currency: "CNY",
|
||||
}, allinPayTestConfig(privateKey, publicKey, tc.orderType))
|
||||
if err != nil {
|
||||
@@ -264,7 +263,7 @@ func TestAllinPayRefundUsesConfiguredLookupIdentity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllinPayRefundResultBindsRefundIdentity(t *testing.T) {
|
||||
req := &biz.PaymentRefundRequest{TradeNo: "LOCAL-1", RefundNo: "REFUND-1", Amount: 40, Currency: "CNY"}
|
||||
req := &system.PaymentRefundRequest{TradeNo: "LOCAL-1", RefundNo: "REFUND-1", Amount: 40, Currency: "CNY"}
|
||||
base := func() *allinpay.RefundRsp {
|
||||
return &allinpay.RefundRsp{Reqsn: "REFUND-1", Trxid: "ALLIN-REFUND-1", TrxStatus: "SUCCESS", Fee: "40"}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user