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..fa9701bd941 100644 --- a/ecommerce/extensions/checkout/views.py +++ b/ecommerce/extensions/checkout/views.py @@ -238,11 +238,13 @@ def get_object(self): def get_payment_method(self, order): source = order.sources.first() if source: - if source.card_type: + if source.card_type and source.label: return '{type} {number}'.format( type=source.get_card_type_display(), number=source.label ) + elif source.label: + return source.label return source.source_type.name return None