UNPKG

crowdstart-checkout

Version:

One Click Checkout for Crowdstart

109 lines (81 loc) 3.24 kB
// Generated by CoffeeScript 1.10.0 var Events, Payment, Screen, analytics, crowdcontrol, input, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; crowdcontrol = require('crowdcontrol'); Events = crowdcontrol.Events; Screen = require('./screen'); analytics = require('../../utils/analytics'); input = require('../../utils/input'); require('card/lib/js/card'); Payment = (function(superClass) { var obj; extend(Payment, superClass); function Payment() { return Payment.__super__.constructor.apply(this, arguments); } Payment.prototype.tag = 'payment'; Payment.prototype.html = require('../../../templates/screens/payment.jade'); Payment.prototype.title = 'Payment Info'; Payment.prototype.card = null; Payment.prototype.inputConfigs = [input('user.email', 'youremail@somewhere.com', 'email input required'), input('user.password', 'Password', 'password'), input('user.name', 'Full Name', 'input name required'), input('payment.account.number', 'XXXX XXXX XXXX XXXX', 'cardnumber requiredstripe'), input('payment.account.expiry', 'MM / YY', 'input requiredstripe expiration'), input('payment.account.cvc', 'CVC', 'input requiredstripe cvc')]; Payment.prototype.events = ( obj = {}, obj["" + Events.Screen.Payment.ChooseStripe] = function() { return this.setSelected('stripe'); }, obj["" + Events.Screen.Payment.ChoosePaypal] = function() { return this.setSelected('paypal'); }, obj ); Payment.prototype.hasProcessors = function() { return this.hasPaypal() && this.hasStripe(); }; Payment.prototype.hasPaypal = function() { return this.model.config.processors.paypal; }; Payment.prototype.hasStripe = function() { return this.model.config.processors.stripe; }; Payment.prototype.setSelected = function(selected) { this.model.order.type = selected; this.model.payment.account._type = selected; this.fullyValidated = false; return riot.update(); }; Payment.prototype.show = function() { return analytics.track('Viewed Checkout Step', { step: 1 }); }; Payment.prototype._submit = function() { Payment.__super__._submit.call(this); return analytics.track('Completed Checkout Step', { step: 1 }); }; Payment.prototype.js = function() { Payment.__super__.js.apply(this, arguments); this.model.payment.account._type = this.model.order.type; return this.on('updated', (function(_this) { return function() { var $card; if (_this.card == null) { $card = $(_this.root).find('.crowdstart-card'); if ($card[0] != null) { return _this.card = new window.Card({ form: 'form#payment', container: '.crowdstart-card', width: 180 }); } } }; })(this)); }; return Payment; })(Screen); Payment.register(); module.exports = Payment; //# sourceMappingURL=payment.js.map