Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add payment_method_info to gateway response in adyen process_payment and capture_payment
IKarbowiak4aaea64628b3
diff --git a/saleor/payment/gateways/adyen/plugin.py b/saleor/payment/gateways/adyen/plugin.pyindex 2e9eee08e6..e972964e58 100644--- a/saleor/payment/gateways/adyen/plugin.py+++ b/saleor/payment/gateways/adyen/plugin.py@@ -22,6 +22,7 @@ from .utils import (PENDING_STATUSES,api_call,call_capture,+ get_payment_method_info,request_data_for_gateway_config,request_data_for_payment,request_for_payment_cancel,@@ -289,6 +290,9 @@ class AdyenGatewayPlugin(BasePlugin):token=result.message.get("pspReference"),adyen_client=self.adyen,)++ payment_method_info = get_payment_method_info(payment_information, result)+return GatewayResponse(is_success=is_success,action_required="action" in result.message,@@ -299,6 +303,7 @@ class AdyenGatewayPlugin(BasePlugin):error=error_message,raw_response=result.message,action_required_data=action,+ payment_method_info=payment_method_info,)@classmethod@@ -469,6 +474,9 @@ class AdyenGatewayPlugin(BasePlugin):token=transaction.token,adyen_client=self.adyen,)++ payment_method_info = get_payment_method_info(payment_information, result)+return GatewayResponse(is_success=True,action_required=False,@@ -478,6 +486,7 @@ class AdyenGatewayPlugin(BasePlugin):transaction_id=result.message.get("pspReference", ""),error="",raw_response=result.message,+ payment_method_info=payment_method_info,)@require_active_plugindiff --git a/saleor/payment/gateways/adyen/tests/cassettes/test_capture_payment.yaml b/saleor/payment/gateways/adyen/tests/cassettes/test_capture_payment.yamlindex 20f1032bd0..1fa16ebc15 100644--- a/saleor/payment/gateways/adyen/tests/cassettes/test_capture_payment.yaml+++ b/saleor/payment/gateways/adyen/tests/cassettes/test_capture_payment.yaml@@ -23,7 +23,8 @@ interactions:uri: https://pal-test.adyen.com/pal/servlet/Payment/v49/captureresponse:body:- string: '{"pspReference":"852595499936560C","response":"[capture-received]"}'+ string: '{"pspReference":"852595499936560C","response":"[capture-received]",+ "additionalData":{"paymentMethod": "visa"}}'headers:Connection:- Keep-Alivediff --git a/saleor/payment/gateways/adyen/tests/cassettes/test_process_payment.yaml b/saleor/payment/gateways/adyen/tests/cassettes/test_process_payment.yamlindex fcead20271..c91f481a69 100644--- a/saleor/payment/gateways/adyen/tests/cassettes/test_process_payment.yaml+++ b/saleor/payment/gateways/adyen/tests/cassettes/test_process_payment.yaml@@ -23,7 +23,8 @@ interactions:uri: https://checkout-test.adyen.com/v49/paymentsresponse:body:- string: '{"pspReference":"882595494831959A","resultCode":"Authorised","merchantReference":"UGF5bWVudDoz"}'+ string: '{"pspReference":"882595494831959A","resultCode":"Authorised","merchantReference":"UGF5bWVudDoz",+ "additionalData":{"paymentMethod": "visa"}}'headers:Connection:- Keep-Alivediff --git a/saleor/payment/gateways/adyen/tests/test_plugin.py b/saleor/payment/gateways/adyen/tests/test_plugin.pyindex 1b86909952..63259040d2 100644--- a/saleor/payment/gateways/adyen/tests/test_plugin.py+++ b/saleor/payment/gateways/adyen/tests/test_plugin.py@@ -5,7 +5,7 @@ from unittest import mockimport pytestfrom .... import PaymentError, TransactionKind-from ....interface import GatewayResponse+from ....interface import GatewayResponse, PaymentMethodInfofrom ....models import Paymentfrom ....utils import create_payment_information, create_transaction@@ -37,7 +37,7 @@ def test_get_payment_gateway_for_checkout(def test_process_payment(payment_adyen_for_checkout, checkout_with_items, adyen_plugin):payment_info = create_payment_information(payment_adyen_for_checkout,- additional_data={"paymentMethod": {"paymentdata": ""}},+ additional_data={"paymentMethod": {"paymentdata": "", "type": "test"}},)adyen_plugin = adyen_plugin()response = adyen_plugin.process_payment(payment_info, None)@@ -49,6 +49,7 @@ def test_process_payment(payment_adyen_for_checkout, checkout_with_items, adyen_assert response.transaction_id == "882595494831959A" # ID returned by Adyenassert response.error is Noneassert response.action_required_data is None+ assert response.payment_method_info == PaymentMethodInfo(brand="visa", type="test")@pytest.mark.vcr@@ -378,7 +379,7 @@ def test_void_payment(payment_adyen_for_order, order_with_lines, adyen_plugin):def test_capture_payment(payment_adyen_for_order, order_with_lines, adyen_plugin):payment_info = create_payment_information(payment_adyen_for_order,- # additional_data=...+ additional_data={"paymentMethod": {"paymentdata": "", "type": "test"}},)gateway_response = GatewayResponse(kind=TransactionKind.AUTH,@@ -404,3 +405,4 @@ def test_capture_payment(payment_adyen_for_order, order_with_lines, adyen_pluginassert response.amount == Decimal("1234")assert response.currency == order_with_lines.currencyassert response.transaction_id == "852595499936560C" # ID returned by Adyen+ assert response.payment_method_info == PaymentMethodInfo(brand="visa", type="test")