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
68cdf3a5
Commit
68cdf3a5
authored
Sep 11, 2014
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pass along an extra parameter to CyberSource to sepcify a callback URL if the user clicks cancel
typo
parent
789193ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletions
+32
-1
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+17
-0
lms/djangoapps/shoppingcart/processors/exceptions.py
+3
-0
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+12
-1
No files found.
lms/djangoapps/shoppingcart/processors/CyberSource2.py
View file @
68cdf3a5
...
@@ -126,6 +126,12 @@ def verify_signatures(params):
...
@@ -126,6 +126,12 @@ def verify_signatures(params):
(missing keys, wrong types)
(missing keys, wrong types)
"""
"""
# First see if the user cancelled the transaction
# if so, then not all parameters will be passed back so we can't yet verify signatures
if
params
.
get
(
'decision'
)
==
u'CANCEL'
:
raise
CCProcessorUserCancelled
()
# Validate the signature to ensure that the message is from CyberSource
# Validate the signature to ensure that the message is from CyberSource
# and has not been tampered with.
# and has not been tampered with.
signed_fields
=
params
.
get
(
'signed_field_names'
,
''
)
.
split
(
','
)
signed_fields
=
params
.
get
(
'signed_field_names'
,
''
)
.
split
(
','
)
...
@@ -272,6 +278,7 @@ def get_purchase_params(cart, callback_url=None):
...
@@ -272,6 +278,7 @@ def get_purchase_params(cart, callback_url=None):
if
callback_url
is
not
None
:
if
callback_url
is
not
None
:
params
[
'override_custom_receipt_page'
]
=
callback_url
params
[
'override_custom_receipt_page'
]
=
callback_url
params
[
'override_custom_cancel_page'
]
=
callback_url
return
params
return
params
...
@@ -461,6 +468,16 @@ def _get_processor_exception_html(exception):
...
@@ -461,6 +468,16 @@ def _get_processor_exception_html(exception):
email
=
payment_support_email
email
=
payment_support_email
)
)
)
)
elif
isinstance
(
exception
,
CCProcessorUserCancelled
):
return
_format_error_html
(
_
(
u"Sorry! Our payment processor sent us back a message saying that you have cancelled this transaction. "
u"The items in your shopping cart will exist for future purchase. "
u"If you feel that this is in error, please contact us with payment-specific questions at {email}."
)
.
format
(
email
=
payment_support_email
)
)
else
:
else
:
return
_format_error_html
(
return
_format_error_html
(
_
(
_
(
...
...
lms/djangoapps/shoppingcart/processors/exceptions.py
View file @
68cdf3a5
...
@@ -15,3 +15,6 @@ class CCProcessorDataException(CCProcessorException):
...
@@ -15,3 +15,6 @@ class CCProcessorDataException(CCProcessorException):
class
CCProcessorWrongAmountException
(
CCProcessorException
):
class
CCProcessorWrongAmountException
(
CCProcessorException
):
pass
pass
class
CCProcessorUserCancelled
(
CCProcessorException
):
pass
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
View file @
68cdf3a5
...
@@ -94,7 +94,8 @@ class CyberSource2Test(TestCase):
...
@@ -94,7 +94,8 @@ class CyberSource2Test(TestCase):
'unsigned_field_names'
,
'unsigned_field_names'
,
'transaction_uuid'
,
'transaction_uuid'
,
'payment_method'
,
'payment_method'
,
'override_custom_receipt_page'
'override_custom_receipt_page'
,
'override_custom_cancel_page'
,
])
])
)
)
self
.
assertEqual
(
params
[
'unsigned_field_names'
],
''
)
self
.
assertEqual
(
params
[
'unsigned_field_names'
],
''
)
...
@@ -169,6 +170,16 @@ class CyberSource2Test(TestCase):
...
@@ -169,6 +170,16 @@ class CyberSource2Test(TestCase):
self
.
assertFalse
(
result
[
'success'
])
self
.
assertFalse
(
result
[
'success'
])
self
.
assertIn
(
u"badly-typed value"
,
result
[
'error_html'
])
self
.
assertIn
(
u"badly-typed value"
,
result
[
'error_html'
])
def
test_process_user_cancelled
(
self
):
# Change the payment amount to a non-decimal
params
=
self
.
_signed_callback_params
(
self
.
order
.
id
,
self
.
COST
,
"abcd"
)
params
[
'decision'
]
=
u'CANCEL'
result
=
process_postpay_callback
(
params
)
# Expect an error
self
.
assertFalse
(
result
[
'success'
])
self
.
assertIn
(
u"you have cancelled this transaction"
,
result
[
'error_html'
])
@patch.object
(
OrderItem
,
'purchased_callback'
)
@patch.object
(
OrderItem
,
'purchased_callback'
)
def
test_process_no_credit_card_digits
(
self
,
callback
):
def
test_process_no_credit_card_digits
(
self
,
callback
):
# Use a credit card number with no digits provided
# Use a credit card number with no digits provided
...
...
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