Grabbing the basic order information we need to sent to CyberSource.
This commit is contained in:
@@ -102,6 +102,15 @@ def render_purchase_form_html(cart):
|
||||
"""
|
||||
Renders the HTML of the hidden POST form that must be used to initiate a purchase with CyberSource
|
||||
"""
|
||||
return render_to_string('shoppingcart/cybersource_form.html', {
|
||||
'action': purchase_endpoint,
|
||||
'params': get_signed_purchase_params(params),
|
||||
})
|
||||
|
||||
def get_signed_purchase_params(cart):
|
||||
return sign(get_purchase_params(cart))
|
||||
|
||||
def get_purchase_params(cart):
|
||||
purchase_endpoint = settings.CC_PROCESSOR['CyberSource'].get('PURCHASE_ENDPOINT', '')
|
||||
|
||||
total_cost = cart.total_cost
|
||||
@@ -112,12 +121,8 @@ def render_purchase_form_html(cart):
|
||||
params['currency'] = cart.currency
|
||||
params['orderPage_transactionType'] = 'sale'
|
||||
params['orderNumber'] = "{0:d}".format(cart.id)
|
||||
signed_param_dict = sign(params)
|
||||
|
||||
return render_to_string('shoppingcart/cybersource_form.html', {
|
||||
'action': purchase_endpoint,
|
||||
'params': signed_param_dict,
|
||||
})
|
||||
return params
|
||||
|
||||
|
||||
def payment_accepted(params):
|
||||
|
||||
@@ -38,6 +38,12 @@ urlpatterns = patterns(
|
||||
r'^verify',
|
||||
views.VerifyView.as_view(),
|
||||
name="verify_student_verify"
|
||||
),
|
||||
|
||||
url(
|
||||
r'^create_order',
|
||||
views.create_order,
|
||||
name="verify_student_create_order"
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
|
||||
"""
|
||||
import json
|
||||
|
||||
from mitxmako.shortcuts import render_to_response
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import redirect
|
||||
from django.views.generic.base import View
|
||||
|
||||
from course_modes.models import CourseMode
|
||||
from student.models import CourseEnrollment
|
||||
from student.views import course_from_id
|
||||
from shoppingcart.models import Order, CertificateItem
|
||||
from shoppingcart.processors.CyberSource import get_signed_purchase_params
|
||||
from verify_student.models import SoftwareSecurePhotoVerification
|
||||
|
||||
class VerifyView(View):
|
||||
@@ -29,21 +35,32 @@ class VerifyView(View):
|
||||
# bookkeeping-wise just to start over.
|
||||
progress_state = "start"
|
||||
|
||||
course_id = request.GET['course_id']
|
||||
context = {
|
||||
"progress_state" : progress_state,
|
||||
"user_full_name" : request.user.profile.name,
|
||||
"course_name" : course_from_id(request.GET['course_id']).display_name
|
||||
"course_id" : course_id,
|
||||
"course_name" : course_from_id(course_id).display_name
|
||||
}
|
||||
|
||||
return render_to_response('verify_student/photo_verification.html', context)
|
||||
|
||||
|
||||
def post(request):
|
||||
attempt = SoftwareSecurePhotoVerification(user=request.user)
|
||||
attempt.status = "pending"
|
||||
attempt.save()
|
||||
def create_order(request):
|
||||
attempt = SoftwareSecurePhotoVerification(user=request.user)
|
||||
attempt.status = "pending"
|
||||
attempt.save()
|
||||
|
||||
course_id = request.POST['course_id']
|
||||
|
||||
# I know, we should check this is valid. All kinds of stuff missing here
|
||||
# enrollment = CourseEnrollment.create_enrollment(request.user, course_id)
|
||||
cart = Order.get_cart_for_user(request.user)
|
||||
CertificateItem.add_to_order(cart, course_id, 30, 'verified')
|
||||
|
||||
params = get_signed_purchase_params(cart)
|
||||
|
||||
return HttpResponse(json.dumps(params), content_type="text/json")
|
||||
|
||||
|
||||
def show_requirements(request):
|
||||
|
||||
@@ -264,9 +264,10 @@
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li class="action action-next">
|
||||
<form method="post">
|
||||
<form method="post" action="create_order">
|
||||
<!-- <a href="#">Go to Step 4: Secure Payment</a> -->
|
||||
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value="${ csrf_token }">
|
||||
<input type="hidden" name="course_id" value="${course_id | h}" />
|
||||
<input type="submit" value="Go to Step 4" name="payment">
|
||||
</form>
|
||||
<p class="tips">Once you verify your details match the requirements, you can move on to step 4, payment on our secure server.</p>
|
||||
|
||||
Reference in New Issue
Block a user