Better i18n for credit card charge failures
This commit is contained in:
@@ -241,23 +241,22 @@ def get_processor_decline_html(params):
|
|||||||
# see if we have an override in the microsites
|
# see if we have an override in the microsites
|
||||||
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
|
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
|
||||||
|
|
||||||
msg = dedent(_(
|
msg = _(
|
||||||
"""
|
"Sorry! Our payment processor did not accept your payment. "
|
||||||
<p class="error_msg">
|
"The decision they returned was {decision_text}, "
|
||||||
Sorry! Our payment processor did not accept your payment.
|
"and the reason was {reason_text}. "
|
||||||
The decision they returned was <span class="decision">{decision}</span>,
|
"You were not charged. "
|
||||||
and the reason was <span class="reason">{reason_code}:{reason_msg}</span>.
|
"Please try a different form of payment. "
|
||||||
You were not charged. Please try a different form of payment.
|
"Contact us with payment-related questions at {email}."
|
||||||
Contact us with payment-related questions at {email}.
|
)
|
||||||
</p>
|
formatted = msg.format(
|
||||||
"""
|
decision_text='<span class="decision">{}</span>'.format(params['decision']),
|
||||||
))
|
reason_text='<span class="reason">{code}:{msg}</span>'.format(
|
||||||
|
code=params['reasonCode'], msg=REASONCODE_MAP[params['reasonCode']],
|
||||||
return msg.format(
|
),
|
||||||
decision=params['decision'],
|
email=payment_support_email,
|
||||||
reason_code=params['reasonCode'],
|
)
|
||||||
reason_msg=REASONCODE_MAP[params['reasonCode']],
|
return '<p class="error_msg">{}</p>'.format(formatted)
|
||||||
email=payment_support_email)
|
|
||||||
|
|
||||||
|
|
||||||
def get_processor_exception_html(exception):
|
def get_processor_exception_html(exception):
|
||||||
@@ -266,41 +265,55 @@ def get_processor_exception_html(exception):
|
|||||||
# see if we have an override in the microsites
|
# see if we have an override in the microsites
|
||||||
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
|
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
|
||||||
if isinstance(exception, CCProcessorDataException):
|
if isinstance(exception, CCProcessorDataException):
|
||||||
msg = dedent(_(
|
msg = _(
|
||||||
"""
|
"Sorry! Our payment processor sent us back a payment confirmation "
|
||||||
<p class="error_msg">
|
"that had inconsistent data!"
|
||||||
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 "
|
||||||
We apologize that we cannot verify whether the charge went through and take further action on your order.
|
"and take further action on your order."
|
||||||
The specific error message is: <span class="exception_msg">{msg}</span>.
|
"The specific error message is: {error_message}. "
|
||||||
Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}.
|
"Your credit card may possibly have been charged. "
|
||||||
</p>
|
"Contact us with payment-specific questions at {email}."
|
||||||
""".format(msg=exception.message, email=payment_support_email)
|
)
|
||||||
))
|
formatted = msg.format(
|
||||||
return msg
|
error_message='<span class="exception_msg">{msg}</span>'.format(
|
||||||
|
msg=exception.message,
|
||||||
|
),
|
||||||
|
email=payment_support_email,
|
||||||
|
)
|
||||||
|
return '<p class="error_msg">{}</p>'.format(formatted)
|
||||||
elif isinstance(exception, CCProcessorWrongAmountException):
|
elif isinstance(exception, CCProcessorWrongAmountException):
|
||||||
msg = dedent(_(
|
msg = _(
|
||||||
"""
|
"Sorry! Due to an error your purchase was charged for "
|
||||||
<p class="error_msg">
|
"a different amount than the order total! "
|
||||||
Sorry! Due to an error your purchase was charged for a different amount than the order total!
|
"The specific error message is: {error_message}. "
|
||||||
The specific error message is: <span class="exception_msg">{msg}</span>.
|
"Your credit card has probably been charged. "
|
||||||
Your credit card has probably been charged. Contact us with payment-specific questions at {email}.
|
"Contact us with payment-specific questions at {email}."
|
||||||
</p>
|
)
|
||||||
""".format(msg=exception.message, email=payment_support_email)
|
formatted = msg.format(
|
||||||
))
|
error_message='<span class="exception_msg">{msg}</span>'.format(
|
||||||
return msg
|
msg=exception.message,
|
||||||
|
),
|
||||||
|
email=payment_support_email,
|
||||||
|
)
|
||||||
|
return '<p class="error_msg">{}</p>'.format(formatted)
|
||||||
elif isinstance(exception, CCProcessorSignatureException):
|
elif isinstance(exception, CCProcessorSignatureException):
|
||||||
msg = dedent(_(
|
msg = _(
|
||||||
"""
|
"Sorry! Our payment processor sent us back a corrupted message "
|
||||||
<p class="error_msg">
|
"regarding your charge, so we are unable to validate that "
|
||||||
Sorry! Our payment processor sent us back a corrupted message regarding your charge, so we are
|
"the message actually came from the payment processor. "
|
||||||
unable to validate that the message actually came from the payment processor.
|
"The specific error message is: {error_message}. "
|
||||||
The specific error message is: <span class="exception_msg">{msg}</span>.
|
"We apologize that we cannot verify whether the charge went through "
|
||||||
We apologize that we cannot verify whether the charge went through and take further action on your order.
|
"and take further action on your order. "
|
||||||
Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}.
|
"Your credit card may possibly have been charged. "
|
||||||
</p>
|
"Contact us with payment-specific questions at {email}."
|
||||||
""".format(msg=exception.message, email=payment_support_email)
|
)
|
||||||
))
|
formatted = msg.format(
|
||||||
return msg
|
error_message='<span class="exception_msg">{msg}</span>'.format(
|
||||||
|
msg=exception.message,
|
||||||
|
),
|
||||||
|
email=payment_support_email,
|
||||||
|
)
|
||||||
|
return '<p class="error_msg">{}</p>'.format(formatted)
|
||||||
|
|
||||||
# fallthrough case, which basically never happens
|
# fallthrough case, which basically never happens
|
||||||
return '<p class="error_msg">EXCEPTION!</p>'
|
return '<p class="error_msg">EXCEPTION!</p>'
|
||||||
|
|||||||
Reference in New Issue
Block a user