|
7 | 7 | from django.db import transaction
|
8 | 8 | from django.http.response import Http404
|
9 | 9 | from django.shortcuts import get_object_or_404
|
| 10 | +from django.views.generic.base import RedirectView |
10 | 11 | from ipware import get_client_ip
|
11 | 12 | from rest_framework.authentication import SessionAuthentication, TokenAuthentication
|
12 | 13 | from rest_framework.exceptions import ValidationError
|
|
44 | 45 | )
|
45 | 46 | from ecommerce.serializers import CouponSerializer
|
46 | 47 | from mail.api import MailgunClient
|
| 48 | +from ui.url_utils import DASHBOARD_URL, PAYMENT_CALL_BACK_URL |
47 | 49 |
|
48 | 50 | log = logging.getLogger(__name__)
|
49 | 51 |
|
@@ -80,7 +82,7 @@ def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
|
80 | 82 | )
|
81 | 83 | if course_run.course.program.financial_aid_availability:
|
82 | 84 | order = create_unfulfilled_order(course_id, request.user)
|
83 |
| - dashboard_url = request.build_absolute_uri('/dashboard/') |
| 85 | + payment_callback_url = request.build_absolute_uri(PAYMENT_CALL_BACK_URL) |
84 | 86 | if order.total_price_paid == 0:
|
85 | 87 | # If price is $0, don't bother going to CyberSource, just mark as fulfilled
|
86 | 88 | order.status = Order.FULFILLED
|
@@ -112,11 +114,11 @@ def post(self, request, *args, **kwargs): # pylint: disable=unused-argument
|
112 | 114 |
|
113 | 115 | # This redirects the user to our order success page
|
114 | 116 | payload = {}
|
115 |
| - url = make_dashboard_receipt_url(dashboard_url, course_id, 'receipt') |
| 117 | + url = make_dashboard_receipt_url(payment_callback_url, course_id, 'receipt') |
116 | 118 | method = 'GET'
|
117 | 119 | else:
|
118 | 120 | # This generates a signed payload which is submitted as an HTML form to CyberSource
|
119 |
| - payload = generate_cybersource_sa_payload(order, dashboard_url, user_ip) |
| 121 | + payload = generate_cybersource_sa_payload(order, payment_callback_url, user_ip) |
120 | 122 | url = settings.CYBERSOURCE_SECURE_ACCEPTANCE_URL
|
121 | 123 | method = 'POST'
|
122 | 124 | else:
|
@@ -275,3 +277,11 @@ def post(self, request, code, *args, **kwargs): # pylint: disable=unused-argume
|
275 | 277 | 'coupon': CouponSerializer(coupon).data,
|
276 | 278 | }
|
277 | 279 | )
|
| 280 | + |
| 281 | + |
| 282 | +class PaymentCallBackView(RedirectView): |
| 283 | + """ |
| 284 | + payment callback view that will redirect to dashboard url |
| 285 | + """ |
| 286 | + url = DASHBOARD_URL |
| 287 | + query_string = True |
0 commit comments