pay_and_verify.js 4.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/**
 * Entry point for the payment/verification flow.
 * This loads the base view, which in turn loads
 * subviews for each step in the flow.
 *
 * We pass some information to the base view
 * using "data-" attributes on the parent div.
 * See "pay_and_verify.html" for the exact attribute names.
 *
 */
var edx = edx || {};

13
(function( $, _ ) {
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    'use strict';
    var errorView,
        el = $('#pay-and-verify-container');

    edx.verify_student = edx.verify_student || {};

    // Initialize an error view for displaying top-level error messages.
    errorView = new edx.verify_student.ErrorView({
        el: $('#error-container')
    });

    // Initialize the base view, passing in information
    // from the data attributes on the parent div.
    //
    // The data attributes capture information that only
    // the server knows about, such as the course and course mode info,
    // full URL paths to static underscore templates,
    // and some messaging.
    //
    return new edx.verify_student.PayAndVerifyView({
        errorModel: errorView.model,
        displaySteps: el.data('display-steps'),
        currentStep: el.data('current-step'),
37 38
        courseKey: el.data('course-key'),
        checkpointLocation: el.data('checkpoint-location'),
39 40
        stepInfo: {
            'intro-step': {
41 42
                courseName: el.data('course-name'),
                hasPaid: el.data('msg-key') === 'verify-now' || el.data('msg-key') === 'verify-later',
43 44
                isActive: el.data('is-active'),
                platformName: el.data('platform-name'),
45 46 47
                requirements: el.data('requirements')
            },
            'make-payment-step': {
48
                isActive: el.data('is-active'),
49
                requirements: el.data('requirements'),
50
                courseKey: el.data('course-key'),
51
                courseName: el.data('course-name'),
52 53 54 55 56
                hasVisibleReqs: _.some(
                    el.data('requirements'),
                    function( isVisible ) { return isVisible; }
                ),
                upgrade: el.data('msg-key') === 'upgrade',
57
                minPrice: el.data('course-mode-min-price'),
58
                sku: el.data('course-mode-sku'),
59
                contributionAmount: el.data('contribution-amount'),
60
                suggestedPrices: _.filter(
Will Daly committed
61
                    (el.data('course-mode-suggested-prices').toString()).split(","),
62 63
                    function( price ) { return Boolean( price ); }
                ),
64
                currency: el.data('course-mode-currency'),
jsa committed
65
                processors: el.data('processors'),
66 67 68
                verificationDeadline: el.data('verification-deadline'),
                courseModeSlug: el.data('course-mode-slug'),
                alreadyVerified: el.data('already-verified'),
69 70
                verificationGoodUntil: el.data('verification-good-until'),
                isABTesting:  el.data('is-ab-testing')
71 72
            },
            'payment-confirmation-step': {
73
                courseKey: el.data('course-key'),
74 75
                courseName: el.data('course-name'),
                courseStartDate: el.data('course-start-date'),
76 77 78
                coursewareUrl: el.data('courseware-url'),
                platformName: el.data('platform-name'),
                requirements: el.data('requirements')
79
            },
80
            'face-photo-step': {
81 82
                platformName: el.data('platform-name'),
                captureSoundPath: el.data('capture-sound')
83 84
            },
            'id-photo-step': {
85 86
                platformName: el.data('platform-name'),
                captureSoundPath: el.data('capture-sound')
87
            },
88 89 90
            'review-photos-step': {
                fullName: el.data('full-name'),
                platformName: el.data('platform-name')
91 92 93 94
            },
            'enrollment-confirmation-step': {
                courseName: el.data('course-name'),
                courseStartDate: el.data('course-start-date'),
95 96
                coursewareUrl: el.data('courseware-url'),
                platformName: el.data('platform-name')
97 98 99
            }
        }
    }).render();
100
})( jQuery, _ );