Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use gateway config from plugin configuration
Jakub Draganek488d087f59fe
diff --git a/saleor/payment/gateways/braintree/plugin.py b/saleor/payment/gateways/braintree/plugin.pyindex 80d7982240..0b2bf19dc7 100644--- a/saleor/payment/gateways/braintree/plugin.py+++ b/saleor/payment/gateways/braintree/plugin.py@@ -5,10 +5,21 @@ from django.utils.translation import pgettext_lazyfrom saleor.extensions import ConfigurationTypeFieldfrom saleor.extensions.base_plugin import BasePlugin-from . import authorize, capture, list_client_sources, process_payment, refund, void+from . import (+ GatewayConfig,+ authorize,+ capture,+ list_client_sources,+ process_payment,+ refund,+ void,+)if TYPE_CHECKING:- from . import GatewayResponse, PaymentData, GatewayConfig, CustomerSource+ from . import GatewayResponse, PaymentData, CustomerSource+++GATEWAY_NAME = "braintree"class BraintreeGatewayPlugin(BasePlugin):@@ -70,8 +81,27 @@ class BraintreeGatewayPlugin(BasePlugin):defaults = Nonereturn defaults+ def _initialize_plugin_configuration(self):+ super()._initialize_plugin_configuration()++ if self._cached_config and self._cached_config.configuration:+ configuration = self._cached_config.configuration++ self.config = GatewayConfig(+ gateway_name=GATEWAY_NAME,+ auto_capture=configuration["Automatic payment capture"],+ connection_params={+ "sandbox_mode": configuration["Use sandbox"],+ "merchant_id": configuration["Merchant ID"],+ "public_key": configuration["Public API key"],+ "private_key": configuration["Secret API key"],+ },+ template_path="",+ store_customer=configuration["Store customers card"],+ )+def _get_gateway_config(self):- return GatewayConfig()+ return self.configdef authorize_payment(self, payment_information: PaymentData, previous_value