Jump to content
  • 0

WHMCS Gateway Callback Setup


technosect

Question

Hey there,

I am creating my own Payment Gateway module.

On the invoice page, I have created an input field to take a value. User putting a value on that field and clicks Pay button. And I am sending the value to the pay_process.php page in the pay_process.php page it is checking the value from the database if the value is valid or not if the value is valid then the invoice will be paid.

Now the issue is that after validating the value with database how should I use the callback file to mark the invoice as paid.

What will be the code for the callback file redirection and how the invoice will mark as paid?    

Here is the code: 

pay_process.ph

<?php
        session_start();
        $usr_name = require 'getLogin.php';
        if ($usr_name != false) {
            $_SESSION['user'] = $usr_name;
        }
        
        $username = $_SESSION['user'];
        $hostname = 'localhost';
        $db = 'db_name';
        $duser = 'db_user';
        $pass = 'db_pass';
        $table = 'dn_tokens';
        $invoice_id =$_POST['invoice_id'];
        $description = $_POST['description'];
        $amount =  $_POST['amount'];
        $currency = $_POST['currency'];
        $ress = preg_replace("/[+]/", "", $description);
        $token = $_POST['token'];
        $_SESSION['token_val'] = $token;
        
        //Database Connect
        $conn = mysqli_connect($hostname,$duser,$pass,$db);
        
        // Check connection
        if (mysqli_connect_errno()){
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
        }
        
        //Cross Verification
        if(isset($_GET['token'])){
             $_SESSION['token_val'] = $_GET['token'];
            $sql2 = "SELECT owner, extension, token, status FROM $table WHERE token = '".$_SESSION['token_val']."'";
            $res2 = mysqli_query($conn, $sql2);
            $row2 = mysqli_fetch_array($res2,MYSQLI_ASSOC);
            $owner = $row2['owner'];
            if($_SESSION['user'] != '' && $_SESSION['user']==$owner){
                $msg = '<b>Sucessfully Verified!</b';
                $msg1 = 'verified'; 
                function callback(){
                    
                }
            }
            else{
                $msg = 'Token Owner Mismatch!';
            }
        }
        else{
            //Verify Token
            $sql = "SELECT owner, extension, token, status FROM $table WHERE token = '".$_SESSION['token_val']."'"; 
            $res = mysqli_query($conn, $sql);
            
            if($res && mysqli_num_rows($res) > 0){
                $row=mysqli_fetch_array($res,MYSQLI_ASSOC);
                $owner = $row['owner'];
                if($row['status']=='active'){
                    $msg = 'This token Belongs to: '.'<b>'.$row['owner'].'</b>';
                    if($_SESSION['user'] != '' && $_SESSION['user']==$owner){
                        $msg = 'Owner Verified!';
                        $msg1 = 'verified';
                    }
                    else{
                       $msg1 = 'verify';
                       $verify = '<br/><br/><center><a href=https://steemconnect.com/oauth2/authorize?client_id=dnom.app&redirect_uri=https://dnom.io/callback.php&scope=login%2Cvote%2Ccomment%2Ccomment_options%2Ccustom_json&state=/pay_process.php?token='.$_SESSION['token_val'].'>Login to Verify Payments</a></center>';
                    }
                      
                }
                else{
                    $msg =  'Token Alreday Used!';
                }
            }
            else{
                    $msg = 'Invalid Token Number!';
            }
        }
?>

 

Someone, please help me.

Thanks in advance!

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated