优化结构
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user