chore: docs and added new field for tpv domain
This commit is contained in:
+11
-8
@@ -7,7 +7,7 @@ from django.conf import settings
|
||||
from django.urls import reverse
|
||||
|
||||
from shop.exceptions import RedsysPaymentException
|
||||
from shop.models import Order
|
||||
from shop.models import Order, ShopSettings
|
||||
from shop.settings import TransactionTypes
|
||||
from shop.utils import compute_signature, decode_b64_dict
|
||||
|
||||
@@ -21,6 +21,9 @@ class RedsysClient:
|
||||
)
|
||||
REST_PROD_ENVIRONMENT_URL = "https://sis.redsys.es/sis/rest/trataPeticionREST"
|
||||
|
||||
def __init__(self):
|
||||
self.settings = ShopSettings.load()
|
||||
|
||||
def get_target_url(self):
|
||||
if settings.DEBUG:
|
||||
return self.DEBUG_ENVIRONMENT_URL
|
||||
@@ -32,31 +35,31 @@ class RedsysClient:
|
||||
return self.REST_PROD_ENVIRONMENT_URL
|
||||
|
||||
def get_merchant_code(self) -> str:
|
||||
return settings.REDSYS_MERCHANT_CODE
|
||||
return self.settings.merchant_code
|
||||
|
||||
def get_terminal(self) -> str:
|
||||
return settings.REDSYS_TERMINAL
|
||||
return self.settings.terminal
|
||||
|
||||
def get_currency_code(self) -> str:
|
||||
return settings.REDSYS_CURRENCY_CODE
|
||||
return self.settings.currency_code
|
||||
|
||||
def get_merchant_url_ok_for_order(self, order: Order) -> str:
|
||||
path = reverse("web:order", kwargs={"uuid": order.uuid})
|
||||
return f"{settings.REDSYS_TPV_DOMAIN}{path}"
|
||||
return f"{self.settings.tpv_domain}{path}"
|
||||
|
||||
def to_integer(self, value: Decimal):
|
||||
return int(value * 100)
|
||||
|
||||
def get_merchant_url_ko_for_order(self, order: Order) -> str:
|
||||
path = reverse("web:order", kwargs={"uuid": order.uuid})
|
||||
return f"{settings.REDSYS_TPV_DOMAIN}{path}"
|
||||
return f"{self.settings.tpv_domain}{path}"
|
||||
|
||||
def get_webhook_url_for_order(self, order: Order) -> str:
|
||||
path = reverse("shop:webhook", kwargs={"uuid": order.uuid})
|
||||
return f"{settings.REDSYS_TPV_DOMAIN}{path}"
|
||||
return f"{self.settings.tpv_domain}{path}"
|
||||
|
||||
def get_shared_secret(self) -> str:
|
||||
return settings.REDSYS_SHARED_SECRET
|
||||
return self.settings.shared_secret
|
||||
|
||||
def get_signature(self, hash, payload: str):
|
||||
key = self.get_shared_secret()
|
||||
|
||||
Reference in New Issue
Block a user