How to parse value from php script to Opencart Module?

Raze

New Member
I've implemented payment module in Opencart based on BankTransfer module. Algorithm:[*]I get values orderId, merchantID, amount, currency. I encrypt them. [*]I send those values to payment gateway with "GET" response.[*]Payment gateway then encrypts the values, processes the payment, and encrypts transaction status with its own signature, and sends that to me. [*]My system using php script decrypt the message, and find the transaction status. QUESTION: How can i parse the values from php script to Opencart module (banktransfer.php)? Specifically, to \[code\]public function confirm()\[/code\]?Approach: I've naively thought that http://example.com/opencart/index.php?route=checkout/success is the success link. I thought if i redirect to this page from php script, order would be confirmed, it's not. Explanation of files:
  • banktransfer.php is file opencart gets information from system suchorder id, amount of the order and etc. OpenCart module.
  • testkzm.php is a simple php script that decrypts the message, and "tries" to send get paramaters to confirm function in opencart module in banktransfer.
banktransfer.php in controller/payment \[code\] class ControllerPaymentBankTransfer extends Controller { protected function index() { $this->language->load('payment/bank_transfer'); $this->data['text_instruction'] = $this->language->get('text_instruction'); $this->data['text_description'] = $this->language->get('text_description'); $this->data['text_payment'] = $this->language->get('text_payment'); //Modified things for KZM $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']); $this->data['orderIdKZM'] = $this->session->data['order_id']; $this->data['amountKZM'] = $order_info['total']; $this->data['merchantIdKZM'] = $this->language->get('merchantIdKZM'); $this->data['currencyKZM'] = $this->language->get('currencyKZM'); $this->data['titleKZM'] = $this->language->get('titleKZM'); $this->data['successuUlKZM'] = $this->language->get('successUrlKZM'); $this->data['errorUrlKZM'] = $this->language->get('errorUrlKZM'); $this->data['dateKZM'] = $this->language->get('dateKZM'); $this->data['signstrKZM'] = $this->language->get('signstrKZM'); $this->data['verKZM'] = $this->language->get('verKZM'); //KZM $this->data['button_confirm'] = $this->language->get('button_confirm'); $this->data['bank'] = nl2br($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id'))); $this->data['continue'] = $this->url->link('checkout/success'); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/bank_transfer.tpl')) { $this->template = $this->config->get('config_template') . '/template/payment/bank_transfer.tpl'; } else { $this->template = 'default/template/payment/bank_transfer.tpl'; } $this->render(); } public function confirm() { $this->language->load('payment/bank_transfer'); $this->load->model('checkout/order'); $comment = $this->language->get('text_instruction') . "\n\n"; $comment .= $this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')) . "\n\n"; $comment .= $this->language->get('text_payment'); $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true); } }\[/code\]testkzm.php \[code\]$message <?php echo $_GET["message"]; ?><br>$transactionStatus= decrypt($message);<h2><?php echo $transactionStatus; ?></h2><div class="buttons"> <div class="right"> <form action="http://www.example.com/index.php?route=payment/bank_transfer/confirm" method="get"> <input type="hidden" name="transactionStatus" value="http://stackoverflow.com/questions/15872109/<?php echo $transactionStatus; ?>"> <input type="submit" value="http://stackoverflow.com/questions/15872109/<?php echo $button_confirm; ?>" id="button-confirm" class="button" /> </form> </div></div>\[/code\]Example of how Opencart confirms order, but it is inside the module.banktransfer.tpl\[code\] <h2><?php echo $text_instruction; ?></h2><div class="content"> <p><?php echo $text_description; ?></p> <p><?php echo $bank_transfer; ?></p> <p><?php echo $text_payment; ?></p></div><div class="buttons"> <div class="right"> <input type="button" value="http://stackoverflow.com/questions/15872109/<?php echo $button_confirm; ?>" id="button-confirm" class="button" /> </div></div><script type="text/javascript"><!--$('#button-confirm').bind('click', function() { $.ajax({ type: 'get', url: 'index.php?route=payment/bank_transfer/confirm', success: function() { location = '<?php echo $continue; ?>'; } });});//--></script> \[/code\]
 
Top