优化结构
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"kra/internal/biz/system"
|
||||
bizpayment "kra/internal/biz/payment"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -120,8 +120,8 @@ func TestAllinPayTrxIDCreateRejectsResponseWithoutTransactionID(t *testing.T) {
|
||||
_, _ = w.Write(response)
|
||||
}))
|
||||
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-TRXID-MISSING", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &bizpayment.PaymentRequest{
|
||||
Provider: bizpayment.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") {
|
||||
@@ -131,8 +131,8 @@ func TestAllinPayTrxIDCreateRejectsResponseWithoutTransactionID(t *testing.T) {
|
||||
|
||||
func TestAllinPayNativeCreateRejectsTrxIDLookupMode(t *testing.T) {
|
||||
_, privateKey, publicKey := allinPayTestKeys(t)
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-NATIVE-TRXID", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &bizpayment.PaymentRequest{
|
||||
Provider: bizpayment.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") {
|
||||
@@ -141,8 +141,8 @@ func TestAllinPayNativeCreateRejectsTrxIDLookupMode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllinPayCreateRejectsUnknownMethodBeforeClient(t *testing.T) {
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: "MERCHANT-UNKNOWN-METHOD", Subject: "subject",
|
||||
_, err := (&allinpayAdapter{}).Create(context.Background(), &bizpayment.PaymentRequest{
|
||||
Provider: bizpayment.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(), "不支持的下单方式") {
|
||||
@@ -248,8 +248,8 @@ func TestAllinPayRefundUsesConfiguredLookupIdentity(t *testing.T) {
|
||||
_, _ = w.Write(response)
|
||||
}))
|
||||
|
||||
result, err := (&allinpayAdapter{}).Refund(context.Background(), &system.PaymentRefundRequest{
|
||||
Provider: system.PaymentAllinPay, TradeNo: tc.tradeNo, QueryID: tc.queryID,
|
||||
result, err := (&allinpayAdapter{}).Refund(context.Background(), &bizpayment.PaymentRefundRequest{
|
||||
Provider: bizpayment.PaymentAllinPay, TradeNo: tc.tradeNo, QueryID: tc.queryID,
|
||||
RefundNo: "REFUND-1", Amount: 40, TotalAmount: 100, Currency: "CNY",
|
||||
}, allinPayTestConfig(privateKey, publicKey, tc.orderType))
|
||||
if err != nil {
|
||||
@@ -263,7 +263,7 @@ func TestAllinPayRefundUsesConfiguredLookupIdentity(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAllinPayRefundResultBindsRefundIdentity(t *testing.T) {
|
||||
req := &system.PaymentRefundRequest{TradeNo: "LOCAL-1", RefundNo: "REFUND-1", Amount: 40, Currency: "CNY"}
|
||||
req := &bizpayment.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