Omnipay redirect after payment

Hi,

I am running this code in using omnipay and worldpay. For some reason, worldpay does not redirect me to my site after the payment is completed. Any ideas why that would be? The payment is properly recorded in the database. the only feedback from worlpay I get is

This was not a live transaction. No money has changed hands.
Thank you, your payment was successful.

My code is

$payment = Payment::create()->init(‘WorldPay’, 1.5, ‘GBP’);
$payment->SampleRequestID = $request->ID;
$url = Director::protocolAndHost();
$response = PurchaseService::create($payment)
->setReturnUrl($url . $this->Link(’?sent=1’))
->setCancelUrl($url . $this->Link(’?cancelled=1’))
->purchase(array());

$response->redirect();

thanks for the help

I’m guessing you need to use $this->AbsoluteLink instead of $this->Link

Oh I missed that you were prefixing that with $url. AbsoluteLink might be more reliable / easier. Maybe your concatenation is producing a result with a missing slash like ‘mysite.commypage’?

My redirect function is triggered and seems to work (minor the redirect)

class ExtendedPaymentGatewayController extends PaymentGatewayController {

public function redirect($link, $code = 302) {

	$myfile = fopen("newfile1.txt", "w") or die("Unable to open file!");
	$txt = $link;
	fwrite($myfile, $txt);
	fclose($myfile);

	
	$myfile = fopen("newfile2.txt", "w") or die("Unable to open file!");
	$txt = file_get_contents($link);
	fwrite($myfile, $txt);
	fclose($myfile);
			
	echo file_get_contents($link);
            exit();
	
}

}

The 2 files are created on the server showing where the URL of the redirect and the second displays the html of the page the user should see.

But no redirect is happening. Is there something to configure at the worldpay level?

Would there be a way to debug this?