diff --git a/nhonga_api/client.py b/nhonga_api/client.py index 710d526..29a00fe 100644 --- a/nhonga_api/client.py +++ b/nhonga_api/client.py @@ -3,6 +3,7 @@ """ import requests +import hmac from typing import Optional, Callable, Union, Awaitable from .types import ( NhongaConfig, @@ -29,7 +30,7 @@ def __init__(self, config: NhongaConfig): """ self.api_key = config["api_key"] self.secret_key = config.get("secret_key") - self.base_url = config.get("base_url", "https://vendorapay.com/api") + self.base_url = config.get("base_url", "https://nhonga.net/api") self.session = requests.Session() self.session.headers.update({ @@ -149,7 +150,7 @@ def validate_webhook(self, payload: WebhookPayload, received_secret_key: str) -> """ if not self.secret_key: raise NhongaError("Secret key not configured for webhook validation") - return self.secret_key == received_secret_key + return hmac.compare_digest(self.secret_key, received_secret_key) def process_webhook( self, diff --git a/nhonga_api/examples.py b/nhonga_api/examples.py index 3999988..3bf54ae 100644 --- a/nhonga_api/examples.py +++ b/nhonga_api/examples.py @@ -228,8 +228,9 @@ def processar_pagamento(webhook_data: WebhookPayload): def exemplo_context_manager(): """Exemplo usando context manager""" + # ⚠️ IMPORTANTE: Substitua pelas suas credenciais reais ou use variáveis de ambiente with NhongaAPI({ - "api_key": "SUA_CHAVE_API", + "api_key": "SUA_CHAVE_API", # Substitua pela sua chave API real "secret_key": "SUA_CHAVE_SECRETA" }) as nhonga: diff --git a/nhonga_api/types.py b/nhonga_api/types.py index 9c4c8c3..12a2c47 100644 --- a/nhonga_api/types.py +++ b/nhonga_api/types.py @@ -45,7 +45,7 @@ class CreatePaymentRequest(TypedDict, total=False): callbackUrl: Optional[str] returnUrl: Optional[str] currency: Optional[Currency] - enviroment: Optional[Environment] + environment: Optional[Environment] class CreatePaymentResponse(TypedDict):