Jump to content

How can I put a form in hookPaymentReturn?

Recommended Posts


I am still new to module creation and I am now developing a payment module which I would need to put a form in Payment Return Hook so to collect some transaction data from the customers.

The ideal steps would be:

  1. Customer choose to pay the order with my module
  2. A QR code will be shown in Payment Return Hook for them to pay the order
  3. After they pay it, they should input the reference number of the payment and it will be stored to Transaction ID

And actually I have created the form and display it well already, but I don't know how should I get the data back. Can anyone give me some idea please?


I have my hookPaymentReturn Code as below

public function hookPaymentReturn($params)
	 * Verify if this module is enabled
	if (!$this->active) {

	$amount = substr($params['order']->total_paid,0,5);

	$result = Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'hongkong_fps` WHERE id_hongkong_fps = 1');

	$fps_info = [
		'acc_type' => $result['account_type'],
		'bank_code' => $result['bank_code'],
		'acc_info' => $result['account_info'],
		'amount' => $amount

	$qr = str_replace("+","%2B",getContentTxt($fps_info));

		'amount' => $amount,
		'qr' => $qr,
		'qr_link' => __PS_BASE_URI__ . 'modules/hongkong_fps/src/qrGen.php?code=' . $qr,

	$this->context->controller->addCSS( __PS_BASE_URI__.'modules/hongkong_fps/assets/css/payment_return.css'); 

	return $this->fetch('module:hongkong_fps/views/templates/hook/payment_return.tpl');

And my payment return tpl on below

<div class="d-flex justify-content-between">
	<div class="w-100 bootstrap">
		<p class="fps_msg">{l s='Please use the QR code on the right and pay by FPS' mod='hongkong_fps'}</p>
		<p class="fps_msg">{l s='Then provide the refernce number on below' mod='hongkong_fps'}</p>
		<p class="saved_ref d-none"><i class="material-icons done"></i>{l s='Ref. No.: ' mod='hongkong_fps'}</p>

		<form id="get_ref">
			<input type="text" name="ref_num" id="ref_num" placeholder="Reference Number">
			<button type="submit" name="submit_ref" id="submit_ref" class="btn btn-secondary mt-15">Submit</button>
	<div class="ml-25">
		<img src="{$qr_link}">


Edited by Oliver Mak (see edit history)

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

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More