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
b1c44ac7
Commit
b1c44ac7
authored
Nov 07, 2014
by
Diana Huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Record processor response on both successful and
unsuccessful orders.
parent
831453c5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
1 deletions
+38
-1
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+23
-1
lms/djangoapps/shoppingcart/processors/exceptions.py
+1
-0
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+14
-0
No files found.
lms/djangoapps/shoppingcart/processors/CyberSource2.py
View file @
b1c44ac7
...
...
@@ -79,6 +79,7 @@ def process_postpay_callback(params):
'error_html'
:
''
}
else
:
_record_payment_info
(
params
,
result
[
'order'
])
return
{
'success'
:
False
,
'order'
:
result
[
'order'
],
...
...
@@ -86,6 +87,11 @@ def process_postpay_callback(params):
}
except
CCProcessorException
as
error
:
log
.
exception
(
'error processing CyberSource postpay callback'
)
# if we have the order and the id, log it
if
hasattr
(
error
,
'order'
):
_record_payment_info
(
params
,
error
.
order
)
else
:
log
.
info
(
json
.
dumps
(
params
))
return
{
'success'
:
False
,
'order'
:
None
,
# due to exception we may not have the order
...
...
@@ -350,7 +356,7 @@ def _payment_accepted(order_id, auth_amount, currency, decision):
'order'
:
order
}
else
:
raise
CCProcessorWrongAmountException
(
ex
=
CCProcessorWrongAmountException
(
_
(
u"The amount charged by the processor {charged_amount} {charged_amount_currency} is different "
u"than the total cost of the order {total_cost} {total_cost_currency}."
...
...
@@ -361,6 +367,8 @@ def _payment_accepted(order_id, auth_amount, currency, decision):
total_cost_currency
=
order
.
currency
)
)
ex
.
order
=
order
raise
ex
else
:
return
{
'accepted'
:
False
,
...
...
@@ -408,6 +416,20 @@ def _record_purchase(params, order):
)
def
_record_payment_info
(
params
,
order
):
"""
Record the purchase and run purchased_callbacks
Args:
params (dict): The parameters we received from CyberSource.
Returns:
None
"""
order
.
processor_reply_dump
=
json
.
dumps
(
params
)
order
.
save
()
def
_get_processor_decline_html
(
params
):
"""
Return HTML indicating that the user's payment was declined.
...
...
lms/djangoapps/shoppingcart/processors/exceptions.py
View file @
b1c44ac7
...
...
@@ -16,5 +16,6 @@ class CCProcessorDataException(CCProcessorException):
class
CCProcessorWrongAmountException
(
CCProcessorException
):
pass
class
CCProcessorUserCancelled
(
CCProcessorException
):
pass
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
View file @
b1c44ac7
...
...
@@ -49,6 +49,13 @@ class CyberSource2Test(TestCase):
line_cost
=
self
.
COST
)
def
assert_dump_recorded
(
self
,
order
):
"""
Verify that this order does have a dump of information from the
payment processor.
"""
self
.
assertNotEqual
(
order
.
processor_reply_dump
,
''
)
def
test_render_purchase_form_html
(
self
):
# Verify that the HTML form renders with the payment URL specified
# in the test settings.
...
...
@@ -131,6 +138,7 @@ class CyberSource2Test(TestCase):
# Expect that the order has been marked as purchased
self
.
assertEqual
(
result
[
'order'
]
.
status
,
'purchased'
)
self
.
assert_dump_recorded
(
result
[
'order'
])
def
test_process_payment_rejected
(
self
):
# Simulate a callback from CyberSource indicating that the payment was rejected
...
...
@@ -140,6 +148,7 @@ class CyberSource2Test(TestCase):
# Expect that we get an error message
self
.
assertFalse
(
result
[
'success'
])
self
.
assertIn
(
u"did not accept your payment"
,
result
[
'error_html'
])
self
.
assert_dump_recorded
(
result
[
'order'
])
def
test_process_payment_invalid_signature
(
self
):
# Simulate a callback from CyberSource indicating that the payment was rejected
...
...
@@ -167,6 +176,9 @@ class CyberSource2Test(TestCase):
# Expect an error
self
.
assertFalse
(
result
[
'success'
])
self
.
assertIn
(
u"different amount than the order total"
,
result
[
'error_html'
])
# refresh data for current order
order
=
Order
.
objects
.
get
(
id
=
self
.
order
.
id
)
self
.
assert_dump_recorded
(
order
)
def
test_process_amount_paid_not_decimal
(
self
):
# Change the payment amount to a non-decimal
...
...
@@ -202,6 +214,7 @@ class CyberSource2Test(TestCase):
msg
=
"Payment was not successful: {error}"
.
format
(
error
=
result
.
get
(
'error_html'
))
)
self
.
assertEqual
(
result
[
'error_html'
],
''
)
self
.
assert_dump_recorded
(
result
[
'order'
])
# Expect that the order has placeholders for the missing credit card digits
self
.
assertEqual
(
result
[
'order'
]
.
bill_to_ccnum
,
'####'
)
...
...
@@ -233,6 +246,7 @@ class CyberSource2Test(TestCase):
# Verify that this executes without a unicode error
result
=
process_postpay_callback
(
params
)
self
.
assertTrue
(
result
[
'success'
])
self
.
assert_dump_recorded
(
result
[
'order'
])
@ddt.data
(
'string'
,
u'üñîçø∂é'
)
def
test_get_processor_exception_html
(
self
,
error_string
):
...
...
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