Commit 98a327b3 by Michael Frey

Strip out quotes from course title as they cause a Cybersource error.

parent ea0c0d8a
......@@ -171,7 +171,7 @@ class Cybersource(BasePaymentProcessor):
parameters['item_{}_discount_amount '.format(index)] = str(line.discount_value)
# Note (CCB): This indicates that the total_amount field below includes tax.
parameters['item_{}_gross_net_indicator'.format(index)] = 'Y'
parameters['item_{}_name'.format(index)] = line.product.title
parameters['item_{}_name'.format(index)] = line.product.title.replace('"', '')
parameters['item_{}_quantity'.format(index)] = line.quantity
parameters['item_{}_sku'.format(index)] = line.stockrecord.partner_sku
parameters['item_{}_tax_amount'.format(index)] = str(line.line_tax)
......
......@@ -12,7 +12,9 @@ from django.conf import settings
from django.test import override_settings
from freezegun import freeze_time
from oscar.apps.payment.exceptions import UserCancelled, TransactionDeclined, GatewayError
from oscar.test import factories
from ecommerce.courses.tests.factories import CourseFactory
from ecommerce.extensions.payment.exceptions import (
InvalidSignatureError, InvalidCybersourceDecision, PartialAuthorizationError, PCIViolation,
ProcessorMisconfiguredError
......@@ -79,6 +81,20 @@ class CybersourceTests(CybersourceMixin, PaymentProcessorTestCaseMixin, TestCase
extra_parameters = {'payment_method': 'card'}
self.assert_correct_transaction_parameters(extra_parameters=extra_parameters)
def test_get_transaction_parameters_with_quoted_product_title(self):
""" Verify quotes are removed from item name """
course = CourseFactory(id='a/b/c/d', name='Course with "quotes"')
product = course.create_or_update_seat(self.CERTIFICATE_TYPE, False, 20, self.partner)
basket = factories.create_basket(empty=True)
basket.add_product(product)
basket.owner = factories.UserFactory()
basket.site = self.site
basket.save()
response = self.processor.get_transaction_parameters(basket)
self.assertEqual(response['item_0_name'], 'Seat in Course with quotes with test-certificate-type certificate')
@ddt.data('card_type', 'card_number', 'card_expiry_date', 'card_cvn')
def test_get_transaction_parameters_with_unpermitted_parameters(self, field):
""" Verify the method raises an error if un-permitted parameters are passed to the method. """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment