Hi,
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:
- Customer choose to pay the order with my module
- A QR code will be shown in Payment Return Hook for them to pay the order
- 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) { return; } $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)); $this->context->smarty->assign([ '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> </form> </div> <div class="ml-25"> <img src="{$qr_link}"> </div> </div>