Sha256: f867bf3f37071e8d867a05c7eab0cd28a723d5111601535cc2e4f7e9878f47f0

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

WORKAREA.registerModule('affirmPaymentTriggers', (function () {
    'use strict';

    var setup = function (index, trigger) {
            var $trigger = $(trigger),
                $form = $trigger.closest('form'),
                $payments = $('[name="' + trigger.name + '"]', $form);

            if (typeof affirm === 'undefined') { return; }

            $form.on('submit.affirm', _.partialRight(handleSubmit, $payments));
        },

        handleSubmit = function (event, $payments) {
            if ($payments.filter(':checked').val() === 'affirm') {
                event.preventDefault();
                affirm.checkout.post();
            }
        },

        init = function ($scope) {
            $('[data-affirm-payment-trigger]', $scope)
            .each(setup);
        };

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-affirm-1.0.0 app/assets/javascripts/workarea/storefront/affirm/modules/affirm_payment_triggers.js