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
a9389747
Commit
a9389747
authored
Sep 10, 2014
by
Will Daly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5155 from edx/will/fix-cybersource-unicode-error
Fix a unicode error in CyberSource2
parents
b6474304
2388e7b8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+1
-1
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+17
-4
No files found.
lms/djangoapps/shoppingcart/processors/CyberSource2.py
View file @
a9389747
...
...
@@ -101,7 +101,7 @@ def processor_hash(value):
"""
secret_key
=
get_processor_config
()
.
get
(
'SECRET_KEY'
,
''
)
hash_obj
=
hmac
.
new
(
secret_key
,
value
,
sha256
)
hash_obj
=
hmac
.
new
(
secret_key
.
encode
(
'utf-8'
),
value
.
encode
(
'utf-8'
)
,
sha256
)
return
binascii
.
b2a_base64
(
hash_obj
.
digest
())[:
-
1
]
# last character is a '\n', which we don't want
...
...
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
View file @
a9389747
...
...
@@ -205,9 +205,21 @@ class CyberSource2Test(TestCase):
self
.
assertFalse
(
result
[
'success'
])
self
.
assertIn
(
u"did not return a required parameter"
,
result
[
'error_html'
])
@patch.object
(
OrderItem
,
'purchased_callback'
)
def
test_sign_then_verify_unicode
(
self
,
purchased_callback
):
params
=
self
.
_signed_callback_params
(
self
.
order
.
id
,
self
.
COST
,
self
.
COST
,
first_name
=
u'
\u2699
'
)
# Verify that this executes without a unicode error
result
=
process_postpay_callback
(
params
)
self
.
assertTrue
(
result
[
'success'
])
def
_signed_callback_params
(
self
,
order_id
,
order_amount
,
paid_amount
,
accepted
=
True
,
signature
=
None
,
card_number
=
'xxxxxxxxxxxx1111'
accepted
=
True
,
signature
=
None
,
card_number
=
'xxxxxxxxxxxx1111'
,
first_name
=
'John'
):
"""
Construct parameters that could be returned from CyberSource
...
...
@@ -227,6 +239,7 @@ class CyberSource2Test(TestCase):
accepted (bool): Whether the payment was accepted or rejected.
signature (string): If provided, use this value instead of calculating the signature.
card_numer (string): If provided, use this value instead of the default credit card number.
first_name (string): If provided, the first name of the user.
Returns:
dict
...
...
@@ -306,7 +319,7 @@ class CyberSource2Test(TestCase):
"req_transaction_uuid"
:
"ddd9935b82dd403f9aa4ba6ecf021b1f"
,
"auth_trans_ref_no"
:
"85080648RYI23S6I"
,
"req_bill_to_surname"
:
"Doe"
,
"req_bill_to_forename"
:
"John"
,
"req_bill_to_forename"
:
first_name
,
"req_bill_to_email"
:
"john@example.com"
,
"req_override_custom_receipt_page"
:
"http://localhost:8000/shoppingcart/postpay_callback/"
,
"req_access_key"
:
"abcd12345"
,
...
...
@@ -335,8 +348,8 @@ class CyberSource2Test(TestCase):
"""
return
processor_hash
(
","
.
join
([
"{0}={1}"
.
format
(
signed_field
,
params
[
signed_field
])
u
"{0}={1}"
.
format
(
signed_field
,
params
[
signed_field
])
for
signed_field
in
params
[
'signed_field_names'
]
.
split
(
","
)
in
params
[
'signed_field_names'
]
.
split
(
u
","
)
])
)
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