Hi All,
I am creating one custom payment module for a payment gateway. I have created a hidden form with all required parameter to submit to payment gateway. Form is submitting properly, user is doing payment with there card, after payment gateway return to url that i need to pass as SUCCESSURL and i am setting this as checkout/success as URL. In this url gateway add TRANASCTIONID and REFERENCEID that i need to save and if no TRANASCTIONID found then i need to make order fail of retirn to payment page.
My problem is how order is being created in admin with incomplete status. So how i make it in processing status sot that user can see there order in account. Also how i save TRANASCTIONID and REFERENCEID
My controller code is as follow :
class ControllerResponsesExtensionCustomHpp extends AController {
public function main() {
$fields = array();
$this->load->model('checkout/order');
$this->loadLanguage('custom_hpp/custom_hpp');
$cancel_url = $this->request->get['rt'] != 'checkout/guest_step_3' ? $this->html->getSecureURL('checkout/payment') : $this->html->getSecureURL('checkout/guest_step_2');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$products = '';
foreach ($this->cart->getProducts() as $product) {
$products .= $product['quantity'] . ' x ' . $product['name'] . ', ';
}
$this->load->library('encryption');
$encryption = new AEncryption($this->config->get('encryption_key'));
$hpp_url = $this->config->get('custom_hpp_paymentURL');
$fields = array(
'auth' => $this->config->get('custom_hpp_authID'),
'acid' => $this->config->get('custom_hpp_accountID'),
'successurl' => $this->html->getSecureURL('checkout/success').'&',
'product' => $products,
'amount' => $this->currency->format($order_info['total'], $order_info['currency'], $order_info['value'], FALSE),
'currency' => 'USD',//$order_info['currency'],
'Reference' => $this->session->data['order_id'],
'FirstName' => $order_info['payment_firstname'],
'LastName' => $order_info['payment_lastname'],
'Address' => $order_info['payment_address_1'].''.$order_info['payment_address_2'],
'City' => $order_info['email'],
'State' => $order_info['payment_zone'],
'Country' => $order_info['payment_iso_code_2'],
'PostCode' => substr($order_info['payment_postcode'], 0, 9),
'Phone' => $order_info['telephone'],
'Email' => $order_info['email'],
);
$form = new AForm();
$form->setForm(array('form_name' => 'checkout'));
$data['form']['form_open'] = $form->getFieldHtml(array('type' => 'form',
'name' => 'checkout',
'action' => $hpp_url));
foreach ($fields as $key => $value) {
$data['form'][$key] = $form->getFieldHtml(array('type' => 'hidden',
'name' => $key,
'value' => $value
));
}
if ($this->request->get['rt'] == 'checkout/guest_step_3'){
$back = $this->html->getSecureURL('checkout/guest_step_2', '&mode=edit', true);
} else{
$back = $this->html->getSecureURL('checkout/payment', '&mode=edit', true);
}
$data['form']['back'] = $form->getFieldHtml(array('type' => 'button',
'name' => 'back',
'text' => $this->language->get('button_back'),
'style' => 'button',
'href' => $back));
$data['form']['submit'] = $form->getFieldHtml(array('type' => 'submit',
'name' => $this->language->get('button_confirm')
));
$this->view->batchAssign($data);
$this->processTemplate('responses/custom_hpp.tpl');
}
}