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
893cb9c2
Commit
893cb9c2
authored
Nov 06, 2014
by
Adam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5873 from edx/release
Release
parents
fd587b97
8fee0318
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 @
893cb9c2
...
@@ -25,6 +25,7 @@ import binascii
...
@@ -25,6 +25,7 @@ import binascii
import
re
import
re
import
json
import
json
import
uuid
import
uuid
import
logging
from
textwrap
import
dedent
from
textwrap
import
dedent
from
datetime
import
datetime
from
datetime
import
datetime
from
collections
import
OrderedDict
,
defaultdict
from
collections
import
OrderedDict
,
defaultdict
...
@@ -38,6 +39,8 @@ from shoppingcart.processors.exceptions import *
...
@@ -38,6 +39,8 @@ from shoppingcart.processors.exceptions import *
from
shoppingcart.processors.helpers
import
get_processor_config
from
shoppingcart.processors.helpers
import
get_processor_config
from
microsite_configuration
import
microsite
from
microsite_configuration
import
microsite
log
=
logging
.
getLogger
(
__name__
)
def
process_postpay_callback
(
params
):
def
process_postpay_callback
(
params
):
"""
"""
...
@@ -82,6 +85,7 @@ def process_postpay_callback(params):
...
@@ -82,6 +85,7 @@ def process_postpay_callback(params):
'error_html'
:
_get_processor_decline_html
(
params
)
'error_html'
:
_get_processor_decline_html
(
params
)
}
}
except
CCProcessorException
as
error
:
except
CCProcessorException
as
error
:
log
.
exception
(
'error processing CyberSource postpay callback'
)
return
{
return
{
'success'
:
False
,
'success'
:
False
,
'order'
:
None
,
# due to exception we may not have the order
'order'
:
None
,
# due to exception we may not have the order
...
@@ -449,9 +453,9 @@ def _get_processor_exception_html(exception):
...
@@ -449,9 +453,9 @@ def _get_processor_exception_html(exception):
if
isinstance
(
exception
,
CCProcessorDataException
):
if
isinstance
(
exception
,
CCProcessorDataException
):
return
_format_error_html
(
return
_format_error_html
(
_
(
_
(
u"Sorry! Our payment processor sent us back a payment confirmation that had inconsistent data!
"
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"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"The specific error message is: {msg} "
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
(
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
...
@@ -461,8 +465,8 @@ def _get_processor_exception_html(exception):
...
@@ -461,8 +465,8 @@ def _get_processor_exception_html(exception):
elif
isinstance
(
exception
,
CCProcessorWrongAmountException
):
elif
isinstance
(
exception
,
CCProcessorWrongAmountException
):
return
_format_error_html
(
return
_format_error_html
(
_
(
_
(
u"Sorry! Due to an error your purchase was charged for a different amount than the order total!
"
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"The specific error message is: {msg}. "
u"Your credit card has probably been charged. Contact us with payment-specific questions at {email}."
u"Your credit card has probably been charged. Contact us with payment-specific questions at {email}."
)
.
format
(
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
...
@@ -476,7 +480,7 @@ def _get_processor_exception_html(exception):
...
@@ -476,7 +480,7 @@ def _get_processor_exception_html(exception):
u"unable to validate that the message actually came from the payment processor. "
u"unable to validate that the message actually came from the payment processor. "
u"The specific error message is: {msg}. "
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"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
(
)
.
format
(
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
msg
=
u'<span class="exception_msg">{msg}</span>'
.
format
(
msg
=
exception
.
message
),
email
=
payment_support_email
email
=
payment_support_email
...
@@ -495,7 +499,7 @@ def _get_processor_exception_html(exception):
...
@@ -495,7 +499,7 @@ def _get_processor_exception_html(exception):
else
:
else
:
return
_format_error_html
(
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."
u"Please contact us at {email} for assistance."
)
.
format
(
email
=
payment_support_email
)
)
.
format
(
email
=
payment_support_email
)
)
)
...
@@ -503,7 +507,7 @@ def _get_processor_exception_html(exception):
...
@@ -503,7 +507,7 @@ def _get_processor_exception_html(exception):
def
_format_error_html
(
msg
):
def
_format_error_html
(
msg
):
""" Format an HTML error message """
""" 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"
)
CARDTYPE_MAP
=
defaultdict
(
lambda
:
"UNKNOWN"
)
...
...
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
View file @
893cb9c2
...
@@ -4,6 +4,7 @@ Tests for the newer CyberSource API implementation.
...
@@ -4,6 +4,7 @@ Tests for the newer CyberSource API implementation.
"""
"""
from
mock
import
patch
from
mock
import
patch
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.conf
import
settings
import
ddt
import
ddt
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
UserFactory
...
@@ -12,7 +13,13 @@ from shoppingcart.processors.CyberSource2 import (
...
@@ -12,7 +13,13 @@ from shoppingcart.processors.CyberSource2 import (
processor_hash
,
processor_hash
,
process_postpay_callback
,
process_postpay_callback
,
render_purchase_form_html
,
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):
...
@@ -227,6 +234,19 @@ class CyberSource2Test(TestCase):
result
=
process_postpay_callback
(
params
)
result
=
process_postpay_callback
(
params
)
self
.
assertTrue
(
result
[
'success'
])
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
(
def
_signed_callback_params
(
self
,
order_id
,
order_amount
,
paid_amount
,
self
,
order_id
,
order_amount
,
paid_amount
,
accepted
=
True
,
signature
=
None
,
card_number
=
'xxxxxxxxxxxx1111'
,
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