Jump to content
sokalsondha

payment gateway not redirect to invoice page callback

Recommended Posts

Posted (edited)

hello my friends.

how are you? i am having one major issue with my custom made payment gateway using sumup api.

payment works fine. its marking the invoice paid too which works smoothly. but only the problem is after make successfull payment its not redirect to invoice page.. here is my callback file

<?php

session_start();
/*
Gateway Module Name: Nexxus Payment Group Callback
Description: Nexxus payment gateway module for WHMCS
Version: 1.0
Author: Asif Iqbal
Author URI: https://www.webwizo.com
*/
// Require libraries needed for gateway module functions.
require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
require_once __DIR__ . '/../../../includes/invoicefunctions.php';
// Detect module name from filename.
$gatewayModuleName = basename(__FILE__, '.php');
// Fetch gateway configuration parameters.
$gatewayParams = getGatewayVariables($gatewayModuleName);
// Die if module is not active.
if (!$gatewayParams['type']) {
    die("Module Not Activated");
}

// Retrieve data returned in payment gateway callback
// Varies per payment gateway
$status = $_GET["status"];
$invoiceId = $_GET["invoice_id"];
$transactionId = $_GET["transactionId"];
$paymentAmount = $_GET["amount"];
$paymentFee = $_POST["x_fee"];

$transactionStatus = ucwords($status);

/**
 * Validate Callback Invoice ID.
 *
 * Checks invoice ID is a valid invoice number. Note it will count an
 * invoice in any status as valid.
 *
 * Performs a die upon encountering an invalid Invoice ID.
 *
 * Returns a normalised invoice ID.
 */
$invoiceId = checkCbInvoiceID($invoiceId, $gatewayParams['name']);
/**
 * Check Callback Transaction ID.
 *
 * Performs a check for any existing transactions with the same given
 * transaction number.
 *
 * Performs a die upon encountering a duplicate.
 */
checkCbTransID($transactionId);
/**
 * Log Transaction.
 *
 * Add an entry to the Gateway Log for debugging purposes.
 *
 * The debug data can be a string or an array. In the case of an
 * array it will be
 *
 * @param string $gatewayName        Display label
 * @param string|array $debugData    Data to log
 * @param string $transactionStatus  Status
 */
logTransaction($gatewayParams['name'], $_GET, $transactionStatus);
if ($status == 'SUCCESSFULL') {
    /**
     * Add Invoice Payment.
     *
     * Applies a payment transaction entry to the given invoice ID.
     *
     * @param int $invoiceId         Invoice ID
     * @param string $transactionId  Transaction ID
     * @param float $paymentAmount   Amount paid (defaults to full balance)
     * @param float $paymentFee      Payment fee (optional)
     * @param string $gatewayModule  Gateway module name
     */
    addInvoicePayment(
        $invoiceId,
        $transactionId,
        $paymentAmount,
        $paymentFee,
        $gatewayModuleName
    );
}else{
    addInvoicePayment(
        $invoiceId,
        $transactionId,
        $paymentAmount,
        $paymentFee,
        $gatewayModuleName
    );
    
   header('Location:'.$_SESSION['return_url']);
}

can someone guide me with this? how to return to invoice page with success message

thanks

Edited by WHMCS ChrisD
Added code box for PHP - Please use the code box when adding code samples it helps makes things easier to read

Share this post


Link to post
Share on other sites

What is the transaction flow here?   Does the client leave WHMCS, like with PayPal, or do they stay on the payment page?  

Also, is $_SESSION['return_url'] actually set? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

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