elin-r
10/23/2016 - 5:58 PM

Tulo Payway API Callback

Tulo Payway API Callback

<?php 
$redirect = $_GET['state'];

if(empty($redirect))
{
    $redirect = '/';
}
?>
<!DOCTYPE html>
<html>
<head>
    <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
    
    <script src="https://backend.worldoftulo.com/javascript/tulo_js_api.js"></script>
</head>
<body>
    <script type="text/javascript">
    (function ($) {
        if (Tulo) {
            Tulo.init(
                '<?php echo get_option('tulo_client_id') ?>',
                '<?php echo get_option('tulo_redirect_uri') ?>',
                '<?php echo get_option('tulo_organisation_id') ?>',
                {
                    env:'<?php echo get_option('tulo_environment') ?>',
                    fields: 'alias,contact_email,organisation,products,customer_number,first_name,last_name,mobile_number'
                });

            Tulo.session(function (data) {
                if (data.active) {
                    window.parent.location = '<?php echo $redirect ?>';
                }
            });
            Tulo.register_event_listener('session_status_changed', function (data) {
                window.parent.location = '<?php echo $redirect ?>';
            });
        }
    })(jQuery);
    </script>
</body>
</html>