Created
April 17, 2015 16:37
-
-
Save involer/bd02cfdba89f8fd15429 to your computer and use it in GitHub Desktop.
Listening to Paddle Checkout Events
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 event_method = window.addEventListener ? "addEventListener" : "attachEvent"; | |
var my_eventer = window[event_method]; | |
var message_event = event_method == "attachEvent" ? "onmessage" : "message"; | |
// Listen to message from child window | |
my_eventer(message_event, function(event) { | |
if(event.data.action == 'complete') { | |
console.log('Checkout Complete'); | |
} else if(event.data.action == 'close') { | |
console.log('Checkout Closed'); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code helped me but not directly. seems the latest paddle.js has a bit different.
As per my findings the current paddle.js gives the event.data.action value as "event", there is another property event.data.event_name which is the actual event name and event name has format like 'checkout.closed', 'checkout.completed'
here is my modified code.