Skip to content

Instantly share code, notes, and snippets.

@eojthebrave
Created July 3, 2013 15:09
Show Gist options
  • Save eojthebrave/5919084 to your computer and use it in GitHub Desktop.
Save eojthebrave/5919084 to your computer and use it in GitHub Desktop.
dotjs script for send recurly push notifications from the log on the recurly site to your callback url.
/*
Works in conjunction with dojs (https://github.com/defunkt/dotjs) to allow
passing request logged in the Recurly push notification window to a local host
without setting up port forwarding or the like.
Useful for testing push notifications on a localhost.
In order for this to work you need to add the following to the .htaccess file
of your local site otherwise you will get Cross Origin Request (CORS) errors.
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, x-csrf-token, content-type"
Header add Access-Control-Allow-Methods "POST"
</IfModule>
With this enabled you'll see a new "Post it Locally" link added under the body
of each push notification when displaying them on the Recurly site.
*/
(function($) {
// Set this to the Recurly API callback endpoint on your localhost.
local_url = 'http://localhost/recurly/listener/biI4N2mx';
if ($('body').hasClass('nav_push_notifications') && $('body').hasClass('show')) {
$code = $('pre');
$code.after('<a href="javascript:void(0);" style=" display: block; background: red; color: white; padding: 5px 20px;" class="localpost">Post It Locally</a>');
$('a.localpost').click(function() {
$.post(local_url, $('pre').text());
alert('Sent');
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment