Sha256: 5f91b27a8a12acaecc70fb6a02e668ed52861f38c8f582021a1bffc8a0aee1de

Contents?: true

Size: 868 Bytes

Versions: 4

Compression:

Stored size: 868 Bytes

Contents

/**
 * @namespace WORKAREA.afterpayRedirect
 */
WORKAREA.registerModule('afterpayRedirect', (function () {
    'use strict';

    var redirectToAfterpay = function(token, country){
            window.AfterPay.initialize({countryCode: country});
            window.AfterPay.redirect({token: token});
        },

        getAfterpay = function(token, country) {
            $.getScript(WORKAREA.config.afterpay.afterpayScript, _.partial(redirectToAfterpay, token, country));
        },


        init = function ($scope) {
            var $afterpayMethod = $('[data-afterpay-token]', $scope),
                token = $afterpayMethod.data('afterpayToken'),
                country = $afterpayMethod.data('afterpayCountry');

            if (_.isEmpty(token)) { return; }

            getAfterpay(token, country);
        };

    return {
        init: init
    };
}()));

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
workarea-afterpay-2.1.2 app/assets/javascripts/workarea/storefront/afterpay/modules/afterpay_redirect.js
workarea-afterpay-2.1.1 app/assets/javascripts/workarea/storefront/afterpay/modules/afterpay_redirect.js
workarea-afterpay-2.1.0 app/assets/javascripts/workarea/storefront/afterpay/modules/afterpay_redirect.js
workarea-afterpay-2.0.2 app/assets/javascripts/workarea/storefront/afterpay/modules/afterpay_redirect.js