Search code examples
javascriptif-statementpayment

How to declare a console log in a javascript if condition function


i am using a pop payment gate of paylike so i redirect the user to a new page to make payment where the pop up will be display.

in the paylike docs it says that if the popup is close the value is "closed"

I want to try and use that close value in a if condition statement to redirect the user back to previous request.

here is the action function code

function( err, res ){
            if (err)
                return console.log(err);

        console.log(res.transaction.id);

        var txn = res.transaction.id;

        var action = consolde.log(err);

        // if console log is Closed redirect back to preview
        if(action = 'closed') {

            //Redirect to preview page
        }

Please help me out.

if the pop up is close the console.log(err) return "closed" in the inspected element.


Solution

  • Try some changes:

    var action= err; 
    if(action == 'closed'){
    
    } 
    

    Also, I think you have to return err and not console.log(err) or check it before enter in this function:

    if (err)
        return err;