Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
0dbd3cd2
Commit
0dbd3cd2
authored
10 years ago
by
Don Mitchell
Browse files
Options
Downloads
Plain Diff
Merge pull request #5157 from edx/will/fix-cc-unicode-error-rc
Fix a unicode error in CyberSource2
parents
6d914e2b
5759a3fd
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+1
-1
1 addition, 1 deletion
lms/djangoapps/shoppingcart/processors/CyberSource2.py
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+17
-4
17 additions, 4 deletions
...goapps/shoppingcart/processors/tests/test_CyberSource2.py
with
18 additions
and
5 deletions
lms/djangoapps/shoppingcart/processors/CyberSource2.py
+
1
−
1
View file @
0dbd3cd2
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
lms/djangoapps/shoppingcart/processors/tests/test_CyberSource2.py
+
17
−
4
View file @
0dbd3cd2
...
...
@@ -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
"
,
"
)
])
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment