Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
31b200cd
Commit
31b200cd
authored
Nov 05, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add logging for cybersource errors; fix minor unicode bug
parent
f938a5d9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
9 deletions
+33
-9
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+12
-8
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+21
-1
No files found.
lms/djangoapps/shoppingcart/processors/CyberSource2.py
View file @
31b200cd
...
...
@@ -25,6 +25,7 @@ import binascii
import
re
import
json
import
uuid
import
logging
from
textwrap
import
dedent
from
datetime
import
datetime
from
collections
import
OrderedDict
,
defaultdict
...
...
@@ -38,6 +39,8 @@ from shoppingcart.processors.exceptions import *
from
shoppingcart.processors.helpers
import
get_processor_config
from
microsite_configuration
import
microsite
log
=
logging
.
getLogger
(
__name__
)
def
process_postpay_callback
(
params
):
"""
...
...
@@ -82,6 +85,7 @@ def process_postpay_callback(params):
'error_html'
:
_get_processor_decline_html
(
params
)
}
except
CCProcessorException
as
error
:
log
.
exception
(
'error processing CyberSource postpay callback'
)
return
{
'success'
:
False
,
'order'
:
None
,
# due to exception we may not have the order
...
...
@@ -449,9 +453,9 @@ def _get_processor_exception_html(exception):
if
isinstance
(
exception
,
CCProcessorDataException
):
return
_format_error_html
(
_
(
u"Sorry! Our payment processor sent us back a payment confirmation that had inconsistent data!
"
u"We apologize that we cannot verify whether the charge went through and take further action on your order.
"
u"The specific error message is: {msg}
"
u"Sorry! Our payment processor sent us back a payment confirmation that had inconsistent data! "
u"We apologize that we cannot verify whether the charge went through and take further action on your order. "
u"The specific error message is: {msg} "
u"Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}."
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
...
...
@@ -461,8 +465,8 @@ def _get_processor_exception_html(exception):
elif
isinstance
(
exception
,
CCProcessorWrongAmountException
):
return
_format_error_html
(
_
(
u"Sorry! Due to an error your purchase was charged for a different amount than the order total!
"
u"The specific error message is: {msg}.
"
u"Sorry! Due to an error your purchase was charged for a different amount than the order total! "
u"The specific error message is: {msg}. "
u"Your credit card has probably been charged. Contact us with payment-specific questions at {email}."
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
...
...
@@ -476,7 +480,7 @@ def _get_processor_exception_html(exception):
u"unable to validate that the message actually came from the payment processor. "
u"The specific error message is: {msg}. "
u"We apologize that we cannot verify whether the charge went through and take further action on your order. "
u"Your credit card may possibly have been charged.
Contact us with payment-specific questions at {email}."
u"Your credit card may possibly have been charged. Contact us with payment-specific questions at {email}."
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
email
=
payment_support_email
...
...
@@ -495,7 +499,7 @@ def _get_processor_exception_html(exception):
else
:
return
_format_error_html
(
_
(
u"Sorry!
Your payment could not be processed because an unexpected exception occurred.
"
u"Sorry!
Your payment could not be processed because an unexpected exception occurred.
"
u"Please contact us at {email} for assistance."
)
.
format
(
email
=
payment_support_email
)
)
...
...
@@ -503,7 +507,7 @@ def _get_processor_exception_html(exception):
def
_format_error_html
(
msg
):
""" Format an HTML error message """
return
'<p class="error_msg">{msg}</p>'
.
format
(
msg
=
msg
)
return
u
'<p class="error_msg">{msg}</p>'
.
format
(
msg
=
msg
)
CARDTYPE_MAP
=
defaultdict
(
lambda
:
"UNKNOWN"
)
...
...
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
View file @
31b200cd
...
...
@@ -4,6 +4,7 @@ Tests for the newer CyberSource API implementation.
"""
from
mock
import
patch
from
django.test
import
TestCase
from
django.conf
import
settings
import
ddt
from
student.tests.factories
import
UserFactory
...
...
@@ -12,7 +13,13 @@ from shoppingcart.processors.CyberSource2 import (
processor_hash
,
process_postpay_callback
,
render_purchase_form_html
,
get_signed_purchase_params
get_signed_purchase_params
,
_get_processor_exception_html
)
from
shoppingcart.processors.exceptions
import
(
CCProcessorSignatureException
,
CCProcessorDataException
,
CCProcessorWrongAmountException
)
...
...
@@ -227,6 +234,19 @@ class CyberSource2Test(TestCase):
result
=
process_postpay_callback
(
params
)
self
.
assertTrue
(
result
[
'success'
])
@ddt.data
(
'string'
,
u'üñîçø∂é'
)
def
test_get_processor_exception_html
(
self
,
error_string
):
"""
Tests the processor exception html message
"""
for
exception_type
in
[
CCProcessorSignatureException
,
CCProcessorWrongAmountException
,
CCProcessorDataException
]:
error_msg
=
error_string
exception
=
exception_type
(
error_msg
)
html
=
_get_processor_exception_html
(
exception
)
self
.
assertIn
(
settings
.
PAYMENT_SUPPORT_EMAIL
,
html
)
self
.
assertIn
(
'Sorry!'
,
html
)
self
.
assertIn
(
error_msg
,
html
)
def
_signed_callback_params
(
self
,
order_id
,
order_amount
,
paid_amount
,
accepted
=
True
,
signature
=
None
,
card_number
=
'xxxxxxxxxxxx1111'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment