Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add template path and create_form to razorpay payment gateway plugin settings
Jakub Draganeka3d49ec37247
diff --git a/saleor/payment/gateways/razorpay/plugin.py b/saleor/payment/gateways/razorpay/plugin.pyindex 497bc3cc39..48ac1321d4 100644--- a/saleor/payment/gateways/razorpay/plugin.py+++ b/saleor/payment/gateways/razorpay/plugin.py@@ -5,12 +5,13 @@ from django.utils.translation import pgettext_lazyfrom saleor.extensions import ConfigurationTypeFieldfrom saleor.extensions.base_plugin import BasePlugin-from . import GatewayConfig, capture, process_payment, refund+from . import GatewayConfig, capture, process_payment, refund, create_formGATEWAY_NAME = "razorpay"if TYPE_CHECKING:from . import GatewayResponse, PaymentData+ from django import formsdef require_active_plugin(fn):@@ -27,6 +28,13 @@ def require_active_plugin(fn):class RazorpayGatewayPlugin(BasePlugin):PLUGIN_NAME = GATEWAY_NAMECONFIG_STRUCTURE = {+ "Template path": {+ "type": ConfigurationTypeField.STRING,+ "help_text": pgettext_lazy(+ "Plugin help text", "Location of django payment template for gateway."+ ),+ "label": pgettext_lazy("Plugin label", "Template path"),+ },"Public API key": {"type": ConfigurationTypeField.STRING,"help_text": pgettext_lazy("Plugin help text", "Provide public API key"),@@ -87,6 +95,7 @@ class RazorpayGatewayPlugin(BasePlugin):"description": "","active": False,"configuration": [+ {"name": "Template path", "value": "order/payment/razorpay.html"},{"name": "Public API key", "value": ""},{"name": "Secret API key", "value": ""},{"name": "Store customers card", "value": False},@@ -115,3 +124,17 @@ class RazorpayGatewayPlugin(BasePlugin):self, payment_information: "PaymentData", previous_value) -> "GatewayResponse":return process_payment(payment_information, self._get_gateway_config())++ @require_active_plugin+ def get_payment_template(self, previous_value) -> str:+ return self._get_gateway_config().template_path++ @require_active_plugin+ def create_form(+ self, data, payment_information: "PaymentData", previous_value+ ) -> "forms.Form":+ return create_form(+ data,+ payment_information,+ connection_params=self._get_gateway_config().connection_params,+ )