Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions nhonga_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import requests
import hmac
from typing import Optional, Callable, Union, Awaitable
from .types import (
NhongaConfig,
Expand All @@ -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({
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion nhonga_api/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion nhonga_api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down