优化结构

This commit is contained in:
Yvan
2026-08-27 22:33:43 +08:00
parent 5052835fcb
commit e407d3ac10
86 changed files with 3151 additions and 726 deletions
@@ -1,10 +1,15 @@
package payment
import (
"context"
"crypto/sha256"
"encoding/hex"
"net/http"
"net/http/httptest"
"strings"
"testing"
bizpayment "kra/internal/biz/payment"
)
func TestChinaumsCallbackAuthorizationVerification(t *testing.T) {
@@ -31,3 +36,23 @@ func TestChinaumsCallbackAuthorizationVerification(t *testing.T) {
t.Fatalf("mismatched Chinaums AppId error = %v", err)
}
}
func TestVendorRefundMapsBusinessFailureStatus(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"status":"FAIL","message":"rejected"}`))
}))
defer server.Close()
adapter := &vendorPaymentAdapter{provider: "vendor", profile: vendorSFT}
result, err := adapter.Refund(context.Background(), &bizpayment.PaymentRefundRequest{TradeNo: "trade-1", RefundNo: "refund-1", Amount: 100, TotalAmount: 100, Currency: "CNY"}, map[string]any{
"refund_url": server.URL,
"app_key": "secret",
})
if err != nil {
t.Fatalf("Refund() error = %v", err)
}
if result == nil || result.Status != "failed" {
t.Fatalf("Refund() result = %#v, want failed status", result)
}
}