Sha256: 0fb3c78df1b40093ef790d06cbf5bcd421e55ccc00866c77dc94b2da3f28507c

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

function snapTokenGeneratorOnClickFor(elementQualifier) {
    $(document).on("click", elementQualifier, function(event) {
        var element = jQuery(this);
        var chatId = element.data("chat-id");
        var token = element.data("token");

        if (token == "" || token == undefined) {
            $.ajax({
                url: '/chats/' + chatId + '/generate_checkout_token',
                data: {},
                success: function(data) {
                    var token = data.token;
                    element.data('token', token);
                    showSnapDialog(element);
                }
            });
        } else { showSnapDialog(element); }
    });
}

function showSnapDialog(element) {
    var token = element.data("token");
    console.log(token);
    snap.pay(token, {
        onSuccess: function(res) {
        
        },
        onPending: function(res) {
        
        },
        onError: function(res) {
        
        }
    });
}

jQuery(document).ready(function() {
    snapTokenGeneratorOnClickFor('.buy-chat-items');
})

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
veritrans-2.3.0 example/rails/cable/app/assets/javascripts/chats.js
veritrans-2.2.0 example/rails/cable/app/assets/javascripts/chats.js