Created
July 3, 2013 15:09
-
-
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.
This file contains hidden or 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
/* | |
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