DEPR-43 - Remove JS that refers to shoppingcart receipt page. (#24890)
https://openedx.atlassian.net/browse/DEPR-43 Co-authored-by: Jeremy Bowman <jbowman@edx.org>
This commit is contained in:
@@ -10,7 +10,6 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
|
||||
'id_photo_step',
|
||||
'intro_step',
|
||||
'make_payment_step',
|
||||
'payment_confirmation_step',
|
||||
'review_photos_step',
|
||||
'webcam_photo',
|
||||
'image_input'
|
||||
@@ -25,10 +24,6 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
|
||||
{
|
||||
name: 'make-payment-step',
|
||||
title: 'Make Payment'
|
||||
},
|
||||
{
|
||||
name: 'payment-confirmation-step',
|
||||
title: 'Payment Confirmation'
|
||||
}
|
||||
];
|
||||
|
||||
@@ -86,9 +81,6 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
|
||||
expectStepRendered('make-payment-step');
|
||||
|
||||
// Iterate through the steps, ensuring that each is rendered
|
||||
view.nextStep();
|
||||
expectStepRendered('payment-confirmation-step');
|
||||
|
||||
view.nextStep();
|
||||
expectStepRendered('face-photo-step');
|
||||
|
||||
@@ -129,21 +121,6 @@ define(['jquery', 'common/js/spec_helpers/template_helpers', 'js/verify_student/
|
||||
expectStepRendered('enrollment-confirmation-step');
|
||||
});
|
||||
|
||||
it('starts from a later step', function() {
|
||||
// Start from the payment confirmation step
|
||||
var view = createView(
|
||||
DISPLAY_STEPS_FOR_PAYMENT.concat(DISPLAY_STEPS_FOR_VERIFICATION),
|
||||
'payment-confirmation-step'
|
||||
);
|
||||
|
||||
// Verify that we start on the right step
|
||||
expectStepRendered('payment-confirmation-step');
|
||||
|
||||
// Try moving to the next step
|
||||
view.nextStep();
|
||||
expectStepRendered('face-photo-step');
|
||||
});
|
||||
|
||||
it('jumps to a particular step', function() {
|
||||
// Start on the review photos step
|
||||
var view = createView(
|
||||
|
||||
@@ -72,13 +72,6 @@ var edx = edx || {};
|
||||
verificationGoodUntil: $el.data('verification-good-until'),
|
||||
isABTesting: $el.data('is-ab-testing')
|
||||
},
|
||||
'payment-confirmation-step': {
|
||||
courseKey: $el.data('course-key'),
|
||||
courseName: $el.data('course-name'),
|
||||
coursewareUrl: $el.data('courseware-url'),
|
||||
platformName: $el.data('platform-name'),
|
||||
requirements: $el.data('requirements')
|
||||
},
|
||||
'face-photo-step': {
|
||||
platformName: $el.data('platform-name'),
|
||||
captureSoundPath: $el.data('capture-sound')
|
||||
|
||||
@@ -53,7 +53,6 @@ var edx = edx || {};
|
||||
subviewConstructors = {
|
||||
'intro-step': edx.verify_student.IntroStepView,
|
||||
'make-payment-step': edx.verify_student.MakePaymentStepView,
|
||||
'payment-confirmation-step': edx.verify_student.PaymentConfirmationStepView,
|
||||
'face-photo-step': edx.verify_student.FacePhotoStepView,
|
||||
'id-photo-step': edx.verify_student.IDPhotoStepView,
|
||||
'review-photos-step': edx.verify_student.ReviewPhotosStepView,
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/**
|
||||
* View for the "payment confirmation" step of the payment/verification flow.
|
||||
*/
|
||||
var edx = edx || {};
|
||||
|
||||
(function($, _, gettext) {
|
||||
'use strict';
|
||||
|
||||
edx.verify_student = edx.verify_student || {};
|
||||
|
||||
edx.verify_student.PaymentConfirmationStepView = edx.verify_student.StepView.extend({
|
||||
|
||||
templateName: 'payment_confirmation_step',
|
||||
|
||||
defaultContext: function() {
|
||||
return {
|
||||
courseKey: '',
|
||||
courseName: '',
|
||||
coursewareUrl: '',
|
||||
platformName: '',
|
||||
requirements: []
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve receipt information from the shopping cart.
|
||||
*
|
||||
* We make this request from JavaScript to encapsulate
|
||||
* the verification Django app from the shopping cart app.
|
||||
*
|
||||
* This method checks the query string param
|
||||
* ?payment-order-num, which can be set by the shopping cart
|
||||
* before redirecting to the payment confirmation page.
|
||||
* This step then reads the param and requests receipt information
|
||||
* from the shopping cart. At no point does the "verify student"
|
||||
* Django app interact directly with the shopping cart.
|
||||
*
|
||||
* @param {object} templateContext The original template context.
|
||||
* @return {object} A JQuery promise that resolves with the modified
|
||||
* template context.
|
||||
*/
|
||||
updateContext: function(templateContext) {
|
||||
var view = this;
|
||||
return $.Deferred(
|
||||
function(defer) {
|
||||
var paymentOrderNum = $.url('?payment-order-num');
|
||||
if (paymentOrderNum) {
|
||||
// If there is a payment order number, try to retrieve
|
||||
// the receipt information from the shopping cart.
|
||||
view.getReceiptData(paymentOrderNum).done(
|
||||
function(data) {
|
||||
// Add the receipt info to the template context
|
||||
_.extend(templateContext, {receipt: this.receiptContext(data)});
|
||||
defer.resolveWith(view, [templateContext]);
|
||||
}
|
||||
).fail(function() {
|
||||
// Display an error
|
||||
// This can occur if the user does not have access to the receipt
|
||||
// or the order number is invalid.
|
||||
defer.rejectWith(
|
||||
this,
|
||||
[
|
||||
gettext('Error'),
|
||||
gettext('Could not retrieve payment information')
|
||||
]
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// If no payment order is provided, return the original context
|
||||
// The template is responsible for displaying a default state.
|
||||
_.extend(templateContext, {receipt: null});
|
||||
defer.resolveWith(view, [templateContext]);
|
||||
}
|
||||
}
|
||||
).promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* The "Verify Later" button goes directly to the dashboard,
|
||||
* The "Verify Now" button sends the user to the verification flow.
|
||||
* For this reason, we don't need any custom click handlers here, except for
|
||||
* those used to track business intelligence events.
|
||||
*/
|
||||
postRender: function() {
|
||||
var $verifyNowButton = $('#verify_now_button'),
|
||||
$verifyLaterButton = $('#verify_later_button');
|
||||
|
||||
// Track a virtual pageview, for easy funnel reconstruction.
|
||||
window.analytics.page('payment', this.templateName);
|
||||
|
||||
// Track the user's decision to verify immediately
|
||||
window.analytics.trackLink($verifyNowButton, 'edx.bi.user.verification.immediate', {
|
||||
category: 'verification'
|
||||
});
|
||||
|
||||
// Track the user's decision to defer their verification
|
||||
window.analytics.trackLink($verifyLaterButton, 'edx.bi.user.verification.deferred', {
|
||||
category: 'verification'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve receipt data from the shoppingcart.
|
||||
* @param {int} paymentOrderNum The order number of the payment.
|
||||
* @return {object} JQuery Promise.
|
||||
*/
|
||||
getReceiptData: function(paymentOrderNum) {
|
||||
return $.ajax({
|
||||
url: _.sprintf('/shoppingcart/receipt/%s/', paymentOrderNum),
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
context: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Construct the template context from data received
|
||||
* from the shopping cart receipt.
|
||||
*
|
||||
* @param {object} data Receipt data received from the server
|
||||
* @return {object} Receipt template context.
|
||||
*/
|
||||
receiptContext: function(data) {
|
||||
var view = this,
|
||||
receiptContext;
|
||||
|
||||
receiptContext = {
|
||||
orderNum: data.orderNum,
|
||||
currency: data.currency,
|
||||
purchasedDatetime: data.purchase_datetime,
|
||||
totalCost: view.formatMoney(data.total_cost),
|
||||
isRefunded: data.status === 'refunded',
|
||||
billedTo: {
|
||||
firstName: data.billed_to.first_name,
|
||||
lastName: data.billed_to.last_name,
|
||||
city: data.billed_to.city,
|
||||
state: data.billed_to.state,
|
||||
postalCode: data.billed_to.postal_code,
|
||||
country: data.billed_to.country
|
||||
},
|
||||
items: []
|
||||
};
|
||||
|
||||
receiptContext.items = _.map(
|
||||
data.items,
|
||||
function(item) {
|
||||
return {
|
||||
lineDescription: item.line_desc,
|
||||
cost: view.formatMoney(item.line_cost)
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
return receiptContext;
|
||||
},
|
||||
|
||||
formatMoney: function(moneyStr) {
|
||||
return Number(moneyStr).toFixed(2);
|
||||
}
|
||||
});
|
||||
}(jQuery, _, gettext));
|
||||
@@ -428,15 +428,6 @@
|
||||
'js/verify_student/views/step_view'
|
||||
]
|
||||
},
|
||||
'js/verify_student/views/payment_confirmation_step_view': {
|
||||
exports: 'edx.verify_student.PaymentConfirmationStepView',
|
||||
deps: [
|
||||
'jquery',
|
||||
'underscore',
|
||||
'gettext',
|
||||
'js/verify_student/views/step_view'
|
||||
]
|
||||
},
|
||||
'js/verify_student/views/face_photo_step_view': {
|
||||
exports: 'edx.verify_student.FacePhotoStepView',
|
||||
deps: [
|
||||
@@ -491,7 +482,6 @@
|
||||
'js/verify_student/models/verification_model',
|
||||
'js/verify_student/views/intro_step_view',
|
||||
'js/verify_student/views/make_payment_step_view',
|
||||
'js/verify_student/views/payment_confirmation_step_view',
|
||||
'js/verify_student/views/face_photo_step_view',
|
||||
'js/verify_student/views/id_photo_step_view',
|
||||
'js/verify_student/views/review_photos_step_view',
|
||||
|
||||
Reference in New Issue
Block a user