Last active
January 4, 2016 04:29
-
-
Save antony/8568462 to your computer and use it in GitHub Desktop.
Faking out the Stripe CheckoutJS for Functional Tests. A simple drop-in replacement for https://checkout.stripe.com/checkout.js for your functional test environment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var handler, | |
StripeHandler = new Klass({ | |
initialize: function(token) { | |
this._callback = token; | |
}, | |
open: function(attrs) { | |
var _self = this, | |
button = $('<button id="dummy-stripe">').html(attrs.description), | |
overlay = $('<div>', {id: 'dummy-stripe-overlay', style: "position: absolute; width: 20%; height: 40%; background-color: #fff; top: 30%; left: 40%; border: 4px solid #000; display: block; margin: auto auto;"}).html(button); | |
$('body').append(overlay); | |
$('#dummy-stripe').click(function(e) { | |
e.preventDefault(); | |
$('#dummy-stripe-overlay').remove(); | |
_self._callback(undefined, undefined); | |
}); | |
} | |
}), | |
StripeCheckout = new Klass({}).statics({ | |
configure: function(attrs) { | |
return new StripeHandler(attrs.token); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment