crowdstart-checkout
Version:
One Click Checkout for Crowdstart
75 lines (55 loc) • 2.41 kB
JavaScript
// Generated by CoffeeScript 1.10.0
var Events, PayPal, 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');
PayPal = (function(superClass) {
extend(PayPal, superClass);
function PayPal() {
return PayPal.__super__.constructor.apply(this, arguments);
}
PayPal.prototype.tag = 'paypal';
PayPal.prototype.title = 'Pay with PayPal';
PayPal.prototype.html = require('../../../templates/screens/paypal.jade');
PayPal.prototype.payKey = '';
PayPal.prototype.inputConfigs = [input('user.email', 'youremail@somewhere.com', 'email input required'), input('user.password', 'Password', 'password'), input('user.name', 'Full Name', 'input name required')];
PayPal.prototype.show = function() {
return analytics.track('Viewed Checkout Step', {
step: 1
});
};
PayPal.prototype._submit = function(event) {
var data;
this.screenManagerObs.trigger(Events.Confirm.Lock);
data = {
user: this.model.user,
order: this.model.order,
payment: this.model.payment
};
return this.client.payment.paypal(data).then((function(_this) {
return function(res) {
_this.payKey = res.responseText.payKey;
analytics.track('Completed Checkout Step', {
step: 1
});
if (_this.model.test.paypal) {
return window.location.href = "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + _this.payKey;
} else {
return window.location.href = "https://www.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + _this.payKey;
}
};
})(this))["catch"](function(err) {
console.log("shipping submit Error: " + err);
this.screenManagerObs.trigger(Events.Confirm.Unlock);
return this.screenManagerObs.trigger(Events.Checkout.Done);
});
};
return PayPal;
})(Screen);
PayPal.register();
module.exports = PayPal;
//# sourceMappingURL=paypal.js.map