Jump to content

Custom gateway not redirecting after successful payment


Recommended Posts

I am coding a custom gateway which uses a third party merchant gateway. After successful payment the code is returning to the callback page and the invoice marked as paid, but then remaining on the same page. It is not redirecting to an invoice page.

 

What could be the reason for the same?

Link to comment
Share on other sites

  • 2 years later...

Hi,

I used the following code

<?php

# Required File Includes
require_once __DIR__ . '/../../../init.php';
require_once __DIR__ . '/../../../includes/functions.php';
require_once __DIR__ . '/../../../includes/gatewayfunctions.php';
require_once __DIR__ . '/../../../includes/invoicefunctions.php';


$gatewaymodule = "<your module name>"; # Enter your gateway module name here replacing template

$GATEWAY = getGatewayVariables($gatewaymodule);
if (!$GATEWAY["type"]) die("Module Not Activated"); # Checks gateway module is active before accepting callback

# System Variables
$companyname = $params['companyname'];
$systemurl = $params['systemurl'];

# Get Returned Variables - Adjust for Post Variable Names from your Gateway's Documentation

$invoiceid = checkCbInvoiceID($invoiceid,$GATEWAY["name"]); # Checks invoice ID is a valid invoice number or ends processing

checkCbTransID($refid); # Checks transaction number isn't already in the database and ends processing if it does


if (<payment success>) {
  # Successful
  addInvoicePayment($invoiceid, $refid, $amount, $fee, $gatewaymodule); # Apply Payment to Invoice: invoiceid, transactionid, amount paid, fees, modulename
  logTransaction($GATEWAY["name"],$_POST,"Successful"); # Save to Gateway Log: name, data array, status
} else {
  # Unsuccessful
  logTransaction($GATEWAY["name"],$_POST,"Unsuccessful"); # Save to Gateway Log: name, data array, status
  $enqurl =  $systemurl."/modules/gateways/callback/<some url>.php?TxId=".$invoiceid;
  $enqmsg = "Invoice ID: ".$invoiceid."<some message> "; 
  logTransaction($GATEWAY["name"], $enqmsg, "<tag>");		# Save to Gateway Log:
}

$filename = $siteurl . '/viewinvoice.php?id=' . $invoiceid;
HEADER("location:$filename");
?>

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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