From 71ac11b6b0b6b65bbac571b99708886318fa407a Mon Sep 17 00:00:00 2001 From: julianajlk Date: Mon, 8 Apr 2024 19:19:13 -0400 Subject: [PATCH] fix: Receipt page modify payment method to display DPM --- ecommerce/extensions/checkout/tests/test_views.py | 10 ++++++++++ ecommerce/extensions/checkout/views.py | 2 ++ 2 files changed, 12 insertions(+) diff --git a/ecommerce/extensions/checkout/tests/test_views.py b/ecommerce/extensions/checkout/tests/test_views.py index 79c120eb74b..0db26078983 100644 --- a/ecommerce/extensions/checkout/tests/test_views.py +++ b/ecommerce/extensions/checkout/tests/test_views.py @@ -325,6 +325,16 @@ def test_get_payment_method_credit_card_purchase(self): payment_method = ReceiptResponseView().get_payment_method(order) self.assertEqual(payment_method, '{} {}'.format(source.card_type, source.label)) + def test_get_payment_method_stripe_dynamic_payment_methods_purchase(self): + """ + Dynamic Payment Method type (source label) should be displayed as the Payment method + when Stripe DPM was used to purchase a product. + """ + order = self.create_order() + source = factories.SourceFactory(order=order, card_type=None, label='Stripe affirm') + payment_method = ReceiptResponseView().get_payment_method(order) + self.assertEqual(payment_method, source.label) + @patch('ecommerce.extensions.checkout.views.fetch_enterprise_learner_data') @responses.activate def test_get_receipt_for_existing_order(self, mock_learner_data): diff --git a/ecommerce/extensions/checkout/views.py b/ecommerce/extensions/checkout/views.py index 376357cf8ab..7dfa9258dc5 100644 --- a/ecommerce/extensions/checkout/views.py +++ b/ecommerce/extensions/checkout/views.py @@ -243,6 +243,8 @@ def get_payment_method(self, order): type=source.get_card_type_display(), number=source.label ) + elif source.label: + return source.label return source.source_type.name return None