feat: add avatar payments and finance management

This commit is contained in:
stefanfeng
2026-09-08 18:47:29 +08:00
parent 62eb9578fd
commit 8585d101d5
36 changed files with 10228 additions and 43 deletions
@@ -1,3 +1,4 @@
import os
from unittest.mock import Mock, patch
from services.huihui_payment import HuihuiPaymentClient
@@ -48,3 +49,35 @@ def test_create_payment_uses_huihui_payment_v3_contract():
assert body["payWay"] == "APP"
assert body["masterOrderAmt"] == "10.00"
assert body["payAmt"] == 10.0
def test_request_refund_uses_configured_huihui_endpoint_without_exposing_secret():
client = HuihuiPaymentClient({
"HUIHUI_PAYMENT_BASE_URL": "https://open.example/api/payment-v3",
"HUIHUI_APP_ID": "app-id",
"HUIHUI_ACCESS_ID": "access-id",
"HUIHUI_ACCESS_SECRET": "access-secret",
})
response = Mock(status_code=200)
response.json.return_value = {"code": 200, "data": {"status": "PROCESSING", "refundNo": "provider-rf"}}
with patch.dict(os.environ, {"HUIHUI_PAYMENT_REFUND_PATH": "/payment/refund"}), patch(
"services.huihui_payment.httpx.post", return_value=response
) as post:
result = client.request_refund(
huihui_token="user-token",
huihui_user_id="user-id",
order_no="AV1",
refund_no="RF1",
amount="10.00",
reason="用户申请",
)
assert result["refundNo"] == "provider-rf"
assert post.call_args.args[0] == "https://open.example/api/payment-v3/payment/refund"
assert post.call_args.kwargs["json"] == {
"appId": "app-id",
"masterOrderNo": "AV1",
"refundOrderNo": "RF1",
"refundAmt": 10.0,
"refundReason": "用户申请",
}
assert "accessSecret" not in post.call_args.kwargs["params"]