refund_sale
Refund a sale by providing the transaction code. Requires APPROVED or COMPLETE status and falls within the 7-30 day refund window.
Instructions
Sales Refund
Realiza o reembolso de uma venda. A venda deve estar com status APPROVED ou COMPLETE. Não disponível para trial, BACS ou SEPA. Janela de reembolso de 7 a 30 dias (máximo 60).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| transaction_code | Yes | Código da transação |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/hotmart_mcp/tools/sales.py:304-315 (handler)The main handler/implementation of the refund_sale tool. It accepts a 'transaction_code' parameter, sends a PUT request to '/payments/api/v1/sales/{transaction_code}/refund', and returns the JSON response.
async def refund_sale( transaction_code: str, ) -> str: """Sales Refund Realiza o reembolso de uma venda. A venda deve estar com status APPROVED ou COMPLETE. Não disponível para trial, BACS ou SEPA. Janela de reembolso de 7 a 30 dias (máximo 60). Args: transaction_code: Código da transação""" endpoint = f"/payments/api/v1/sales/{transaction_code}/refund" result = await get_client().put(endpoint) return json.dumps(result, indent=2) - src/hotmart_mcp/server.py:21-37 (registration)Automatic tool registration in _discover_and_register_tools(). It imports all modules under hotmart_mcp.tools and registers every public async function as an MCP tool via mcp.tool()(obj). The refund_sale function (from sales.py) gets registered here automatically.
def _discover_and_register_tools() -> int: """Import all modules under hotmart_mcp.tools and register async functions.""" registered = 0 for module_info in pkgutil.iter_modules(tools_pkg.__path__, prefix=f"{tools_pkg.__name__}."): if module_info.name.endswith("__init__"): continue module = importlib.import_module(module_info.name) for name, obj in inspect.getmembers(module, iscoroutinefunction): if name.startswith("_"): continue mcp.tool()(obj) registered += 1 return registered - src/hotmart_mcp/_shared.py:10-14 (helper)Helper function 'get_client()' used by refund_sale to obtain the HotmartClient singleton for making the API call.
def get_client() -> HotmartClient: global _client if _client is None: _client = HotmartClient() return _client