2018-11-21 10:59:07 +01:00
|
|
|
'use strict'
|
2016-03-23 18:39:41 +01:00
|
|
|
|
|
|
|
// https://github.com/gtramontina/stripe-angular
|
|
|
|
|
|
|
|
Application.Directives.directive('stripeForm', ['$window',
|
2018-11-21 10:59:07 +01:00
|
|
|
function ($window) {
|
|
|
|
var directive = { restrict: 'A' }
|
|
|
|
directive.link = function (scope, element, attributes) {
|
|
|
|
var form = angular.element(element)
|
|
|
|
form.bind('submit', function () {
|
|
|
|
var button = form.find('button')
|
|
|
|
button.prop('disabled', true)
|
|
|
|
$window.Stripe.createToken(form[0], function () {
|
|
|
|
var args = arguments
|
|
|
|
scope.$apply(function () {
|
|
|
|
scope[attributes.stripeForm].apply(scope, args)
|
|
|
|
})
|
|
|
|
// button.prop('disabled', false);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
return directive
|
|
|
|
}])
|