Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Extend GatewayConfig with gateway name and use in braintree
Jakub Draganek98f0ee4d7106
diff --git a/saleor/payment/__init__.py b/saleor/payment/__init__.pyindex f6b4a743a2..15fb6fbcc0 100644--- a/saleor/payment/__init__.py+++ b/saleor/payment/__init__.py@@ -126,6 +126,7 @@ def get_payment_gateway(gateway_name):gateway_config = settings.PAYMENT_GATEWAYS[gateway_name]["config"]config = GatewayConfig(+ gateway_name=gateway_name,auto_capture=gateway_config["auto_capture"],template_path=gateway_config["template_path"],connection_params=gateway_config["connection_params"],diff --git a/saleor/payment/gateways/braintree/__init__.py b/saleor/payment/gateways/braintree/__init__.pyindex 8de833ecc2..a031ea1c54 100644--- a/saleor/payment/gateways/braintree/__init__.py+++ b/saleor/payment/gateways/braintree/__init__.py@@ -285,10 +285,12 @@ def list_client_sources(customer = gateway.customer.find(customer_id)if not customer:return []- return [extract_credit_card_data(card) for card in customer.credit_cards]+ return [+ extract_credit_card_data(card, "braintree") for card in customer.credit_cards+ ]-def extract_credit_card_data(card):+def extract_credit_card_data(card, gateway_name):credit_card = CreditCardInfo(exp_year=int(card.expiration_year),exp_month=int(card.expiration_month),@@ -297,6 +299,6 @@ def extract_credit_card_data(card):)return CustomerSource(id=card.unique_number_identifier,- gateway="braintree",+ gateway=gateway_name,credit_card_info=credit_card,)diff --git a/saleor/payment/interface.py b/saleor/payment/interface.pyindex 1389d3c7d8..6ea6699174 100644--- a/saleor/payment/interface.py+++ b/saleor/payment/interface.py@@ -65,6 +65,7 @@ class GatewayConfig:representation of config data. It is required to communicate betweenSaleor and given payment gateway."""+ gateway_name: strauto_capture: booltemplate_path: str# Each gateway has different connection data so we are not able to creatediff --git a/tests/gateway/test_braintree.py b/tests/gateway/test_braintree.pyindex 6055174fc0..d22c020b9b 100644--- a/tests/gateway/test_braintree.py+++ b/tests/gateway/test_braintree.py@@ -85,6 +85,7 @@ def braintree_error_response(braintree_error):@pytest.fixturedef gateway_config():return GatewayConfig(+ gateway_name="braintree",template_path="template.html",auto_capture=False,store_customer=False,diff --git a/tests/gateway/test_razorpay.py b/tests/gateway/test_razorpay.pyindex 5c0a61a671..e16ca7c06f 100644--- a/tests/gateway/test_razorpay.py+++ b/tests/gateway/test_razorpay.py@@ -30,6 +30,7 @@ TRANSACTION_AMOUNT = Decimal("61.33")@pytest.fixturedef gateway_config():return GatewayConfig(+ gateway_name="razorpay",auto_capture=False,template_path="template.html",connection_params={diff --git a/tests/gateway/test_stripe.py b/tests/gateway/test_stripe.pyindex 6f9d72a6cd..574aa96bb3 100644--- a/tests/gateway/test_stripe.py+++ b/tests/gateway/test_stripe.py@@ -46,6 +46,7 @@ ERROR_MESSAGE = "error-message"@pytest.fixture()def gateway_config():return GatewayConfig(+ gateway_name="stripe",auto_capture=False,template_path="template.html",connection_params={diff --git a/tests/test_payment.py b/tests/test_payment.pyindex 262e1fd03d..6d2779b74c 100644--- a/tests/test_payment.py+++ b/tests/test_payment.py@@ -71,6 +71,7 @@ def transaction_data(payment_dummy, gateway_response):@pytest.fixturedef gateway_config():return GatewayConfig(+ gateway_name="dummy",auto_capture=True,template_path="template.html",connection_params={"secret-key": "nobodylikesspanishinqusition"},