优化结构
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"io"
|
||||
"kra/internal/biz/system"
|
||||
bizpayment "kra/internal/biz/payment"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -135,8 +135,8 @@ func TestAlipayV3CreateRESTMethodsUseGoPay(t *testing.T) {
|
||||
if tc.method != "" {
|
||||
extra["method"] = tc.method
|
||||
}
|
||||
result, err := (&alipayV3Adapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAlipayV3, TradeNo: tradeNo, Subject: "subject", Amount: 1000,
|
||||
result, err := (&alipayV3Adapter{}).Create(context.Background(), &bizpayment.PaymentRequest{
|
||||
Provider: bizpayment.PaymentAlipayV3, TradeNo: tradeNo, Subject: "subject", Amount: 1000,
|
||||
Currency: "CNY", NotifyURL: "https://merchant.example/alipay-v3/notify", Extra: extra,
|
||||
}, config)
|
||||
if err != nil {
|
||||
@@ -145,7 +145,7 @@ func TestAlipayV3CreateRESTMethodsUseGoPay(t *testing.T) {
|
||||
if requestBody == nil || requestBody["out_trade_no"] != tradeNo || requestBody["notify_url"] == "" {
|
||||
t.Fatalf("request body = %#v", requestBody)
|
||||
}
|
||||
if result.Provider != system.PaymentAlipayV3 || result.Status != tc.wantStatus || result.TradeNo != tradeNo || result.ProviderTradeNo != tc.wantTrade {
|
||||
if result.Provider != bizpayment.PaymentAlipayV3 || result.Status != tc.wantStatus || result.TradeNo != tradeNo || result.ProviderTradeNo != tc.wantTrade {
|
||||
t.Fatalf("result = %+v", result)
|
||||
}
|
||||
if tc.method == "barcode" {
|
||||
@@ -168,8 +168,8 @@ func TestAlipayV3GeneratedPaymentMethodsUseGoPay(t *testing.T) {
|
||||
config["gateway_url"] = "https://merchant-gateway.example/gateway.do"
|
||||
for _, method := range []string{"app", "page", "wap"} {
|
||||
t.Run(method, func(t *testing.T) {
|
||||
result, err := (&alipayV3Adapter{}).Create(context.Background(), &system.PaymentRequest{
|
||||
Provider: system.PaymentAlipayV3, TradeNo: "T-V3-" + strings.ToUpper(method), Subject: "subject",
|
||||
result, err := (&alipayV3Adapter{}).Create(context.Background(), &bizpayment.PaymentRequest{
|
||||
Provider: bizpayment.PaymentAlipayV3, TradeNo: "T-V3-" + strings.ToUpper(method), Subject: "subject",
|
||||
Amount: 1000, Currency: "CNY", NotifyURL: "https://merchant.example/alipay-v3/notify",
|
||||
ReturnURL: "https://merchant.example/alipay-v3/return", Extra: map[string]any{"method": method},
|
||||
}, config)
|
||||
@@ -272,8 +272,8 @@ func TestAlipayV3RefundValidatesResponse(t *testing.T) {
|
||||
defer server.Close()
|
||||
config := cloneAlipayV3Config(baseConfig)
|
||||
config["api_base_url"] = server.URL
|
||||
result, err := (&alipayV3Adapter{}).Refund(context.Background(), &system.PaymentRefundRequest{
|
||||
Provider: system.PaymentAlipayV3, TradeNo: "T-V3-REFUND", ProviderTradeNo: "P-V3-REFUND",
|
||||
result, err := (&alipayV3Adapter{}).Refund(context.Background(), &bizpayment.PaymentRefundRequest{
|
||||
Provider: bizpayment.PaymentAlipayV3, TradeNo: "T-V3-REFUND", ProviderTradeNo: "P-V3-REFUND",
|
||||
RefundNo: "R-V3-REFUND", Amount: 123, Currency: "CNY",
|
||||
}, config)
|
||||
if tc.wantError {
|
||||
@@ -315,14 +315,14 @@ func TestAlipayV3CallbackUsesGoPayCertificateVerification(t *testing.T) {
|
||||
for key, value := range fields {
|
||||
values.Set(key, value)
|
||||
}
|
||||
callback := &system.PaymentCallback{
|
||||
callback := &bizpayment.PaymentCallback{
|
||||
Body: []byte(values.Encode()), Headers: map[string]string{"Content-Type": "application/x-www-form-urlencoded"},
|
||||
}
|
||||
result, err := (&alipayV3Adapter{}).Callback(context.Background(), callback, config)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.Provider != system.PaymentAlipayV3 || result.Status != "success" || result.TradeNo != "T-V3-CALLBACK" || result.ProviderTradeNo != "P-V3-CALLBACK" {
|
||||
if result.Provider != bizpayment.PaymentAlipayV3 || result.Status != "success" || result.TradeNo != "T-V3-CALLBACK" || result.ProviderTradeNo != "P-V3-CALLBACK" {
|
||||
t.Fatalf("callback result = %+v", result)
|
||||
}
|
||||
callback.Body = []byte(strings.ReplaceAll(values.Encode(), "P-V3-CALLBACK", "P-V3-TAMPERED"))
|
||||
|
||||
Reference in New Issue
Block a user