How to do this with Javascript?

Hello there;

I have two questions and I would appreciate it if you help friends who are experiencing javascript.

Starting a payment step using the Run JavaScript action of the Toolbox plugin. This code allows me to execute the authorizaton process and send the data to the sandbox environment.

My first question, as you can see in the .gif, does not start the process with a single click. You need to click 2-3 times, how can I fix this?

3%20click

My second question is that I still have to use a button when I get the payment result.

When page is loaded Run Javascript doesn’t work, I can access the payment result with a button (and again with 2-3 clicks). How can I handle this?

result

I need to be able to show my payment result to my users without clicking on anything.

Is there someone who can help?

Thanks a lot
Eren

I know you’re here somewhere :slightly_smiling_face:, could you take a look, please?

@lottemint.md @sudsy

Hey @eren,

Can you invite me to your editor, please?

My email:
sergey@mintflow.io

I have a couple of thoughts. Perhaps, the best way is to have a private plugin for your app.

Cheers!

Thanks, I sent the invitation.

Without taking a look at your editor, its a shot in the dark, but it looks like you may be having issues because the DOM has not rendered before executing your javascript.

You can use jquery in an html element on your page instead of using the ‘when page is loaded’ bubble workflow action. If you apply $( document ).ready() , the javascript contained within that function will only run once the page DOM is ready for JavaScript code to execute.

$( document ).ready(function() {
    //insert any functions, variables, etc. here
    console.log( "ready to load custom javascript!" );
});

Alternatively, you can also use $( window ).on( "load", function() { ... }) instead if you need the entire page (images, iframes, etc) to load first, in addition to the DOM

1 Like

@supernaturally is possibly correct about this. But you don’t need to throw more custom code into your page via HTML elements to accommodate page loading.

Just don’t fire your workflow(s) that use Run JavaScript until Page is Loaded. (So your workflows have conditions on them. Similarly, elements on the page like your button should remain unclickable until the page is fully loaded (use the conditions tab to style them).

Another useful thing is to explore the Expression element instead of Run JavaScript to execute your custom code. Since that’s an element, you can just put a placeholder in the expression code field (like // the code we execute is over in the conditions tab) and then, in the conditions tab for the Expression element, you have a condition like “When Page is Loaded” and you’ll find that expression code is one of the things you can change on that condition.

1 Like

I have a lot of questions to ask, but @lottemint.md helping me now.:heart_eyes:

Thanks a lot @supernaturally @keith