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
3ecdb671
Commit
3ecdb671
authored
Aug 20, 2013
by
Jason Bau
Committed by
Diana Huang
Aug 21, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change method sig of process_postpay_callback
parent
64c8a744
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
lms/djangoapps/shoppingcart/models.py
+7
-7
lms/djangoapps/shoppingcart/processors/CyberSource.py
+7
-6
lms/djangoapps/shoppingcart/views.py
+2
-1
No files found.
lms/djangoapps/shoppingcart/models.py
View file @
3ecdb671
...
@@ -158,8 +158,7 @@ class PaidCourseRegistration(OrderItem):
...
@@ -158,8 +158,7 @@ class PaidCourseRegistration(OrderItem):
Is the course defined by course_id in the order?
Is the course defined by course_id in the order?
"""
"""
return
course_id
in
[
item
.
paidcourseregistration
.
course_id
return
course_id
in
[
item
.
paidcourseregistration
.
course_id
for
item
in
order
.
orderitem_set
.
all
()
for
item
in
order
.
orderitem_set
.
all
()
.
select_subclasses
(
"paidcourseregistration"
)]
if
item
.
is_of_subtype
(
PaidCourseRegistration
)]
@classmethod
@classmethod
def
add_to_order
(
cls
,
order
,
course_id
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
cost
=
None
,
currency
=
None
):
def
add_to_order
(
cls
,
order
,
course_id
,
mode_slug
=
CourseMode
.
DEFAULT_MODE_SLUG
,
cost
=
None
,
currency
=
None
):
...
@@ -169,15 +168,11 @@ class PaidCourseRegistration(OrderItem):
...
@@ -169,15 +168,11 @@ class PaidCourseRegistration(OrderItem):
Returns the order item
Returns the order item
"""
"""
super
(
PaidCourseRegistration
,
cls
)
.
add_to_order
(
order
,
course_id
,
cost
,
currency
=
currency
)
# TODO: Possibly add checking for whether student is already enrolled in course
# TODO: Possibly add checking for whether student is already enrolled in course
course
=
course_from_id
(
course_id
)
# actually fetch the course to make sure it exists, use this to
course
=
course_from_id
(
course_id
)
# actually fetch the course to make sure it exists, use this to
# throw errors if it doesn't
# throw errors if it doesn't
item
,
created
=
cls
.
objects
.
get_or_create
(
order
=
order
,
user
=
order
.
user
,
course_id
=
course_id
)
item
.
status
=
order
.
status
###
Get this course_mode
###
handle default arguments for mode_slug, cost, currency
course_mode
=
CourseMode
.
mode_for_course
(
course_id
,
mode_slug
)
course_mode
=
CourseMode
.
mode_for_course
(
course_id
,
mode_slug
)
if
not
course_mode
:
if
not
course_mode
:
# user could have specified a mode that's not set, in that case return the DEFAULT_MODE
# user could have specified a mode that's not set, in that case return the DEFAULT_MODE
...
@@ -187,6 +182,11 @@ class PaidCourseRegistration(OrderItem):
...
@@ -187,6 +182,11 @@ class PaidCourseRegistration(OrderItem):
if
not
currency
:
if
not
currency
:
currency
=
course_mode
.
currency
currency
=
course_mode
.
currency
super
(
PaidCourseRegistration
,
cls
)
.
add_to_order
(
order
,
course_id
,
cost
,
currency
=
currency
)
item
,
created
=
cls
.
objects
.
get_or_create
(
order
=
order
,
user
=
order
.
user
,
course_id
=
course_id
)
item
.
status
=
order
.
status
item
.
mode
=
course_mode
.
slug
item
.
mode
=
course_mode
.
slug
item
.
qty
=
1
item
.
qty
=
1
item
.
unit_cost
=
cost
item
.
unit_cost
=
cost
...
...
lms/djangoapps/shoppingcart/processors/CyberSource.py
View file @
3ecdb671
...
@@ -24,7 +24,7 @@ orderPage_version = settings.CC_PROCESSOR['CyberSource'].get('ORDERPAGE_VERSION'
...
@@ -24,7 +24,7 @@ orderPage_version = settings.CC_PROCESSOR['CyberSource'].get('ORDERPAGE_VERSION'
purchase_endpoint
=
settings
.
CC_PROCESSOR
[
'CyberSource'
]
.
get
(
'PURCHASE_ENDPOINT'
,
''
)
purchase_endpoint
=
settings
.
CC_PROCESSOR
[
'CyberSource'
]
.
get
(
'PURCHASE_ENDPOINT'
,
''
)
payment_support_email
=
settings
.
PAYMENT_SUPPORT_EMAIL
payment_support_email
=
settings
.
PAYMENT_SUPPORT_EMAIL
def
process_postpay_callback
(
request
):
def
process_postpay_callback
(
params
):
"""
"""
The top level call to this module, basically
The top level call to this module, basically
This function is handed the callback request after the customer has entered the CC info and clicked "buy"
This function is handed the callback request after the customer has entered the CC info and clicked "buy"
...
@@ -36,7 +36,6 @@ def process_postpay_callback(request):
...
@@ -36,7 +36,6 @@ def process_postpay_callback(request):
If unsuccessful this function should not have those side effects but should try to figure out why and
If unsuccessful this function should not have those side effects but should try to figure out why and
return a helpful-enough error message in error_html.
return a helpful-enough error message in error_html.
"""
"""
params
=
request
.
POST
.
dict
()
try
:
try
:
verify_signatures
(
params
)
verify_signatures
(
params
)
result
=
payment_accepted
(
params
)
result
=
payment_accepted
(
params
)
...
@@ -164,17 +163,18 @@ def payment_accepted(params):
...
@@ -164,17 +163,18 @@ def payment_accepted(params):
if
valid_params
[
'decision'
]
==
'ACCEPT'
:
if
valid_params
[
'decision'
]
==
'ACCEPT'
:
try
:
try
:
# Moved reading of charged_amount from the valid_params loop above because
# Moved reading of charged_amount
here
from the valid_params loop above because
# only 'ACCEPT' messages have a 'ccAuthReply_amount' parameter
# only 'ACCEPT' messages have a 'ccAuthReply_amount' parameter
charged_amt
=
Decimal
(
params
[
'ccAuthReply_amount'
])
charged_amt
=
Decimal
(
params
[
'ccAuthReply_amount'
])
except
InvalidOperation
:
except
InvalidOperation
:
raise
CCProcessorDataException
(
raise
CCProcessorDataException
(
_
(
"The payment processor returned a badly-typed value {0} for param {1}."
.
format
(
params
[
key
],
key
))
_
(
"The payment processor returned a badly-typed value {0} for param {1}."
.
format
(
params
[
'ccAuthReply_amount'
],
'ccAuthReply_amount'
))
)
)
if
charged_amt
==
order
.
total_cost
and
valid_params
[
'orderCurrency'
]
==
order
.
currency
:
if
charged_amt
==
order
.
total_cost
and
valid_params
[
'orderCurrency'
]
==
order
.
currency
:
return
{
'accepted'
:
True
,
return
{
'accepted'
:
True
,
'amt_charged'
:
valid_params
[
'ccAuthReply_amount'
]
,
'amt_charged'
:
charged_amt
,
'currency'
:
valid_params
[
'orderCurrency'
],
'currency'
:
valid_params
[
'orderCurrency'
],
'order'
:
order
}
'order'
:
order
}
else
:
else
:
...
@@ -275,7 +275,8 @@ def get_processor_exception_html(params, exception):
...
@@ -275,7 +275,8 @@ def get_processor_exception_html(params, exception):
return
'<p class="error_msg">EXCEPTION!</p>'
return
'<p class="error_msg">EXCEPTION!</p>'
CARDTYPE_MAP
=
defaultdict
(
lambda
:
"UNKNOWN"
)
.
update
(
CARDTYPE_MAP
=
defaultdict
(
lambda
:
"UNKNOWN"
)
CARDTYPE_MAP
.
update
(
{
{
'001'
:
'Visa'
,
'001'
:
'Visa'
,
'002'
:
'MasterCard'
,
'002'
:
'MasterCard'
,
...
...
lms/djangoapps/shoppingcart/views.py
View file @
3ecdb671
...
@@ -82,7 +82,8 @@ def postpay_callback(request):
...
@@ -82,7 +82,8 @@ def postpay_callback(request):
If unsuccessful the order will be left untouched and HTML messages giving more detailed error info will be
If unsuccessful the order will be left untouched and HTML messages giving more detailed error info will be
returned.
returned.
"""
"""
result
=
process_postpay_callback
(
request
)
params
=
request
.
POST
.
dict
()
result
=
process_postpay_callback
(
params
)
if
result
[
'success'
]:
if
result
[
'success'
]:
return
HttpResponseRedirect
(
reverse
(
'shoppingcart.views.show_receipt'
,
args
=
[
result
[
'order'
]
.
id
]))
return
HttpResponseRedirect
(
reverse
(
'shoppingcart.views.show_receipt'
,
args
=
[
result
[
'order'
]
.
id
]))
else
:
else
:
...
...
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