Skip to content

Instantly share code, notes, and snippets.

@antony
Last active January 4, 2016 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antony/8568462 to your computer and use it in GitHub Desktop.
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.
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