Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Move template path to the settings of payment gateway

Maciej Korycinskic43025a10ccb
diff --git a/saleor/order/views.py b/saleor/order/views.py
index 6306ff5c90..f23121b89e 100644
--- a/saleor/order/views.py
+++ b/saleor/order/views.py
@@ -138,7 +138,7 @@ def start_payment(request, order, gateway):
"client_token": client_token,
"order": order,
}
- return TemplateResponse(request, payment_gateway.TEMPLATE_PATH, ctx)
+ return TemplateResponse(request, gateway_config.template_path, ctx)
@check_order_status
diff --git a/saleor/payment/__init__.py b/saleor/payment/__init__.py
index 4664e61782..7551727a68 100644
--- a/saleor/payment/__init__.py
+++ b/saleor/payment/__init__.py
@@ -123,6 +123,7 @@ def get_payment_gateway(gateway_name):
gateway_config = settings.PAYMENT_GATEWAYS[gateway_name]["config"]
config = ConfigData(
auto_capture=gateway_config["auto_capture"],
+ template_path=gateway_config["template_path"],
connection_params=gateway_config["connection_params"],
)
diff --git a/saleor/payment/interface.py b/saleor/payment/interface.py
index 58191fcd3e..286c4b2915 100644
--- a/saleor/payment/interface.py
+++ b/saleor/payment/interface.py
@@ -56,7 +56,7 @@ class ConfigData:
Saleor and given payment gateway."""
auto_capture: bool
-
+ template_path: str
# Each gateway has different connection data so we are not able to create
# a unified structure
connection_params: Dict[str, Any]
diff --git a/saleor/settings.py b/saleor/settings.py
index 5599df1491..53371eeef8 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -578,12 +578,17 @@ CHECKOUT_PAYMENT_GATEWAYS = {
PAYMENT_GATEWAYS = {
DUMMY: {
"module": "saleor.payment.gateways.dummy",
- "config": {"auto_capture": True, "connection_params": {}},
+ "config": {
+ "auto_capture": True,
+ "connection_params": {},
+ "template_path": "order/payment/dummy.html",
+ },
},
BRAINTREE: {
"module": "saleor.payment.gateways.braintree",
"config": {
"auto_capture": True,
+ "template_path": "order/payment/braintree.html",
"connection_params": {
"sandbox_mode": get_bool_from_env("BRAINTREE_SANDBOX_MODE", True),
"merchant_id": os.environ.get("BRAINTREE_MERCHANT_ID"),
@@ -595,7 +600,8 @@ PAYMENT_GATEWAYS = {
RAZORPAY: {
"module": "saleor.payment.gateways.razorpay",
"config": {
- "auto_capture": True,
+ "auto_capture": None,
+ "template_path": "order/payment/razorpay.html",
"connection_params": {
"public_key": os.environ.get("RAZORPAY_PUBLIC_KEY"),
"secret_key": os.environ.get("RAZORPAY_SECRET_KEY"),
@@ -609,6 +615,7 @@ PAYMENT_GATEWAYS = {
"module": "saleor.payment.gateways.stripe",
"config": {
"auto_capture": True,
+ "template_path": "order/payment/stripe.html",
"connection_params": {
"public_key": os.environ.get("STRIPE_PUBLIC_KEY"),
"secret_key": os.environ.get("STRIPE_SECRET_KEY"),
diff --git a/tests/gateway/test_braintree.py b/tests/gateway/test_braintree.py
index 5a5e3cd980..7b047b26d3 100644
--- a/tests/gateway/test_braintree.py
+++ b/tests/gateway/test_braintree.py
@@ -90,6 +90,7 @@ def braintree_not_found_error():
@pytest.fixture
def gateway_config():
return ConfigData(
+ template_path="template.html",
auto_capture=False,
connection_params={
"sandbox_mode": False,
diff --git a/tests/gateway/test_razorpay.py b/tests/gateway/test_razorpay.py
index 67565cea04..7f5d003ce3 100644
--- a/tests/gateway/test_razorpay.py
+++ b/tests/gateway/test_razorpay.py
@@ -31,6 +31,7 @@ TRANSACTION_AMOUNT = Decimal("61.33")
def gateway_config():
return ConfigData(
auto_capture=False,
+ template_path="template.html",
connection_params={
"public_key": "public",
"secret_key": "secret",
diff --git a/tests/gateway/test_stripe.py b/tests/gateway/test_stripe.py
index ad0d1227a4..59ecdc43d8 100644
--- a/tests/gateway/test_stripe.py
+++ b/tests/gateway/test_stripe.py
@@ -47,6 +47,7 @@ ERROR_MESSAGE = "error-message"
def gateway_config():
return ConfigData(
auto_capture=False,
+ template_path="template.html",
connection_params={
"public_key": "public",
"secret_key": "secret",
diff --git a/tests/test_payment.py b/tests/test_payment.py
index c7672d3c4e..da6c9c29f1 100644
--- a/tests/test_payment.py
+++ b/tests/test_payment.py
@@ -75,6 +75,7 @@ def transaction_data(payment_dummy, gateway_response):
def gateway_config():
return ConfigData(
auto_capture=True,
+ template_path="template.html",
connection_params={"secret-key": "nobodylikesspanishinqusition"},
)