Pass recharge product ID to Huihui order API
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from services.huihui_org_payment import HuihuiOrgPaymentClient
|
||||
from services.huihui_payment import HuihuiPaymentClient
|
||||
|
||||
|
||||
@@ -81,3 +82,31 @@ def test_request_refund_uses_configured_huihui_endpoint_without_exposing_secret(
|
||||
"refundReason": "用户申请",
|
||||
}
|
||||
assert "accessSecret" not in post.call_args.kwargs["params"]
|
||||
|
||||
|
||||
def test_org_recharge_order_sends_package_product_id_as_string():
|
||||
env = {
|
||||
"HUIHUI_ORG_BASE_URL": "https://fat-open.example/api/huihuiorg",
|
||||
"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": {"orderNo": "261016111200090123456"}}
|
||||
|
||||
with patch.dict(os.environ, env), patch(
|
||||
"services.huihui_org_payment.httpx.request", return_value=response
|
||||
) as request:
|
||||
result = HuihuiOrgPaymentClient().create_order(
|
||||
token="user-token", user_id="user-id", name="测试用户",
|
||||
phone="", avatar="", amount="10.00", product_id="Basic",
|
||||
)
|
||||
|
||||
assert result["orderNo"] == "261016111200090123456"
|
||||
assert request.call_args.args == (
|
||||
"POST", "https://fat-open.example/api/huihuiorg/order/tokenRecharge"
|
||||
)
|
||||
body = request.call_args.kwargs["json"]
|
||||
assert body["chargeAmount"] == 10.0
|
||||
assert body["productId"] == "Basic"
|
||||
assert isinstance(body["productId"], str)
|
||||
|
||||
@@ -152,6 +152,7 @@ def test_org_recharge_only_credits_after_verified_provider_order(authorization_c
|
||||
assert created["balance"] == DEFAULT_TOKEN_GRANT
|
||||
assert created["checkoutToken"] == f"huihui-payment-{context['suffix']}"
|
||||
assert "pay_type" not in provider.create_order.call_args.kwargs
|
||||
assert provider.create_order.call_args.kwargs["product_id"] == "Basic"
|
||||
|
||||
details = {**created_data, "payStatus": 2,
|
||||
"userId": context["owner"].huihui_user_id}
|
||||
|
||||
Reference in New Issue
Block a user