diff --git a/lms/djangoapps/shoppingcart/processors/CyberSource.py b/lms/djangoapps/shoppingcart/processors/CyberSource.py index 969fcfda19..0b171ae8d1 100644 --- a/lms/djangoapps/shoppingcart/processors/CyberSource.py +++ b/lms/djangoapps/shoppingcart/processors/CyberSource.py @@ -241,22 +241,23 @@ def get_processor_decline_html(params): # see if we have an override in the microsites payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL) - msg = _( - "Sorry! Our payment processor did not accept your payment. " - "The decision they returned was {decision_text}, " - "and the reason was {reason_text}. " - "You were not charged. " - "Please try a different form of payment. " - "Contact us with payment-related questions at {email}." - ) - formatted = msg.format( - decision_text='{}'.format(params['decision']), - reason_text='{code}:{msg}'.format( - code=params['reasonCode'], msg=REASONCODE_MAP[params['reasonCode']], - ), - email=payment_support_email, - ) - return '

{}

'.format(formatted) + msg = dedent(_( + """ +

+ Sorry! Our payment processor did not accept your payment. + The decision they returned was {decision}, + and the reason was {reason_code}:{reason_msg}. + You were not charged. Please try a different form of payment. + Contact us with payment-related questions at {email}. +

+ """ + )) + + return msg.format( + decision=params['decision'], + reason_code=params['reasonCode'], + reason_msg=REASONCODE_MAP[params['reasonCode']], + email=payment_support_email) def get_processor_exception_html(exception): @@ -265,55 +266,41 @@ def get_processor_exception_html(exception): # see if we have an override in the microsites payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL) if isinstance(exception, CCProcessorDataException): - msg = _( - "Sorry! Our payment processor sent us back a payment confirmation " - "that had inconsistent data!" - "We apologize that we cannot verify whether the charge went through " - "and take further action on your order." - "The specific error message is: {error_message}. " - "Your credit card may possibly have been charged. " - "Contact us with payment-specific questions at {email}." - ) - formatted = msg.format( - error_message='{msg}'.format( - msg=exception.message, - ), - email=payment_support_email, - ) - return '

{}

'.format(formatted) + msg = dedent(_( + """ +

+ Sorry! Our payment processor sent us back a payment confirmation that had inconsistent data! + We apologize that we cannot verify whether the charge went through and take further action on your order. + The specific error message is: {msg}. + Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}. +

+ """.format(msg=exception.message, email=payment_support_email) + )) + return msg elif isinstance(exception, CCProcessorWrongAmountException): - msg = _( - "Sorry! Due to an error your purchase was charged for " - "a different amount than the order total! " - "The specific error message is: {error_message}. " - "Your credit card has probably been charged. " - "Contact us with payment-specific questions at {email}." - ) - formatted = msg.format( - error_message='{msg}'.format( - msg=exception.message, - ), - email=payment_support_email, - ) - return '

{}

'.format(formatted) + msg = dedent(_( + """ +

+ Sorry! Due to an error your purchase was charged for a different amount than the order total! + The specific error message is: {msg}. + Your credit card has probably been charged. Contact us with payment-specific questions at {email}. +

+ """.format(msg=exception.message, email=payment_support_email) + )) + return msg elif isinstance(exception, CCProcessorSignatureException): - msg = _( - "Sorry! Our payment processor sent us back a corrupted message " - "regarding your charge, so we are unable to validate that " - "the message actually came from the payment processor. " - "The specific error message is: {error_message}. " - "We apologize that we cannot verify whether the charge went through " - "and take further action on your order. " - "Your credit card may possibly have been charged. " - "Contact us with payment-specific questions at {email}." - ) - formatted = msg.format( - error_message='{msg}'.format( - msg=exception.message, - ), - email=payment_support_email, - ) - return '

{}

'.format(formatted) + msg = dedent(_( + """ +

+ Sorry! Our payment processor sent us back a corrupted message regarding your charge, so we are + unable to validate that the message actually came from the payment processor. + The specific error message is: {msg}. + We apologize that we cannot verify whether the charge went through and take further action on your order. + Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}. +

+ """.format(msg=exception.message, email=payment_support_email) + )) + return msg # fallthrough case, which basically never happens return '

EXCEPTION!

'