ersiranjeevi Posted September 12, 2017 Share Posted September 12, 2017 (edited) am using Prestashop version 1.6.1.17 Not sure this is how we need to set up return_urls ? it gives the below error Not Found The requested URL /presta/order-confirmation.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.4.27 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 Server at vj2017.com Port 80My orders are not saving , but my shop hits the payment gateway and payment is made successfully while returning to shop it gives the above error and I couldn't find the order in admin under orders tab. can someone help ?? $smarty->assign(array( 'address' => $address, 'country' => new Country(intval($address->id_country)), 'customer' => $customer, 'merchantAccount' => $merchantAccount, 'sci_name' => $sci_name, 'currency' => $currency, 'stpayUrl' => "https://solidtrustpay.com/handle.php", // products + discounts - shipping cost 'amount' => number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 4), $currency), 2, '.', ''), // shipping cost + wrapping 'shipping' => number_format(Tools::convertPrice(($params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING)), $currency), 2, '.', ''), 'discounts' => $params['cart']->getDiscounts(), 'products' => $products, // products + discounts + shipping cost 'total' => number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 3), $currency), 2, '.', ''), 'id_cart' => intval($params['cart']->id), 'item_id' => intval($params['cart']->id), 'return_url' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.intval($params['cart']->id).'&id_module='.intval($this->id), 'notify_url' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/stpay/ipn-handler.php', 'cancel_url' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'index.php', 'user1' => intval($params['cart']->id), 'this_path' => $this->_path )); Edited September 12, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted September 13, 2017 Share Posted September 13, 2017 it's /order-confirmation without .php actually, on 1.6, given that you use friendly urls. If not it's index.php?controller=order-confirmation Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 13, 2017 Author Share Posted September 13, 2017 (edited) Thanks Global ModeratorsI have updated it as per your advice It gives output like this http://vj2017.com/presta/index.php?controller=order-confirmation&id_cart=&id_module=&id_order=&key=aa19549389d245693e491640f3871353 And its taking me to the order history page http://vj2017.com/presta/index.php?controller=history But I couldn't find my orders there. its just not saving my orders... You suggested to use friendly urls- I dont get it. Edited September 13, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted September 13, 2017 Share Posted September 13, 2017 this module looks like it was developed for PS v1.4/1.5. Are you sure this module was designed to work on PS v1.6? Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 13, 2017 Author Share Posted September 13, 2017 Yes it is, Its working on my test site http://vj2017.com/presta/index.php Payments are getting completed successfully with the STPAY gateway am working with. But Its just not saving the orders Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 13, 2017 Author Share Posted September 13, 2017 (edited) Also, am receiving this error while debugging I changed the code false to true in defines.inc.php to if (!defined('_PS_MODE_DEV_')) {define('_PS_MODE_DEV_', true);} Strict Standards: Declaration of StPay::validateOrder() should be compatible with PaymentModuleCore::validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = NULL, $extra_vars = Array, $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = NULL) in /home/vj2017/public_html/presta/modules/stpay/stpay.php on line 239 Should I have to update the $payment_method = 'Unknown', to stpay ???? I tried that but still getting the same error ? Not sure what fix needed to be done in order to save the order Edited September 13, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 13, 2017 Author Share Posted September 13, 2017 (edited) Here is the complete code-- <?php class StPay extends PaymentModule { private $_html = ''; private $_postErrors = array(); public function __construct() { global $cookie,$order; $this->name = 'stpay'; $this->tab = 'payments_gateways'; $this->version = '1.2'; $this->author = 'STPAY'; $this->currencies = true; $this->currencies_mode = 'radio'; parent::__construct(); /* The parent construct is required for translations */ $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('STPAY'); $this->description = $this->l('Accepts STPAY e-currency payments'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?'); } public function install() { if (!parent::install() OR !Configuration::updateValue('STPAY_MERCHANT_ACCOUNT', 'your-solidtrustpay username') OR !Configuration::updateValue('STPAY_SCI_NAME', 'your-solidtrustpay sci_name') OR !Configuration::updateValue('STPAY_SCI_PASSWORD', 'your-solidtrustpay sci_password') OR !Configuration::updateValue('STPAY_CURRENCY', 'customer') OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn')) return false; return true; } public function uninstall() { if (!Configuration::deleteByName('STPAY_MERCHANT_ACCOUNT') //OR !Configuration::deleteByName('STPAY_MERCHANT_ACCOUNT') OR !Configuration::deleteByName('STPAY_SCI_NAME') OR !Configuration::deleteByName('STPAY_SCI_PASSWORD') OR !Configuration::deleteByName('STPAY_CURRENCY') OR !parent::uninstall()) return false; return true; } public function getContent() { if (isset($_POST['submitStPay'])){ //Configuration::updateValue('STPAY_RECEIVER', $_POST['receiver']); Configuration::updateValue('STPAY_MERCHANT_ACCOUNT', $_POST['merchantAccount']); Configuration::updateValue('STPAY_SCI_NAME', $_POST['sci_name']); Configuration::updateValue('STPAY_SCI_PASSWORD', $_POST['sci_password']); Configuration::updateValue('STPAY_CURRENCY', $_POST['currency']); $this->displayConf(); } $this->displayStPay(); $this->displayFormSettings(); return $this->_html; } private function displayConf() { $this->_html .= ' <div class="conf confirm"> <img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" /> '.$this->l('Settings updated').' </div>'; } private function displayStPay() { $this->_html .= ' <img src="../modules/stpay/stpay.jpg" style="float:left; margin-right:15px;" /> <b>'.$this->l('This module allows you to accept STPAY e-currency.').'</b><br /><br /> '.$this->l('Its Fun Fast & Free !!!').'<br /> <div style="clear:both;"> </div>'; } private function displayFormSettings() { $conf = Configuration::getMultiple(array('STPAY_MERCHANT_ACCOUNT', 'STPAY_SCI_NAME', 'STPAY_SCI_PASSWORD', 'STPAY_CURRENCY')); //$receiver = array_key_exists('receiver', $_POST) ? $_POST['receiver'] : (array_key_exists('STPAY_RECEIVER', $conf) ? $conf['STPAY_RECEIVER'] : ''); $merchantAccount = array_key_exists('merchantAccount', $_POST) ? $_POST['merchantAccount'] : (array_key_exists('STPAY_MERCHANT_ACCOUNT', $conf) ? $conf['STPAY_MERCHANT_ACCOUNT'] : ''); $sci_name = array_key_exists('sci_name', $_POST) ? $_POST['sci_name'] : (array_key_exists('STPAY_SCI_NAME', $conf) ? $conf['STPAY_SCI_NAME'] : ''); $sci_password = array_key_exists('sci_password', $_POST) ? $_POST['sci_password'] : (array_key_exists('STPAY_SCI_PASSWORD', $conf) ? $conf['STPAY_SCI_PASSWORD'] : ''); $currency = array_key_exists('currency', $_POST) ? $_POST['currency'] : (array_key_exists('STPAY_CURRENCY', $conf) ? $conf['STPAY_CURRENCY'] : 'prestashop'); $this->_html .= ' <form action="'.$_SERVER['REQUEST_URI'].'" method="post"> <fieldset> <legend><img src="../img/admin/contact.gif" />'.$this->l('Settings').'</legend> <label>'.$this->l('merchantAccount').'</label> <div class="margin-form"><input type="text" size="33" name="merchantAccount" id="merchantAccount" value="'.htmlentities($merchantAccount, ENT_COMPAT, 'UTF-8').'" /> Your solidtrust pay account username.</div> <label>'.$this->l('sci_name').'</label> <div class="margin-form"><input type="text" size="33" name="sci_name" id="sci_name" value="'.htmlentities($sci_name, ENT_COMPAT, 'UTF-8').'" /> Your solidtrust pay account sci_name.</div> <label>'.$this->l('sci_password').'</label> <div class="margin-form"><input type="text" size="33" name="sci_password" id="sci_password" value="'.htmlentities($sci_password, ENT_COMPAT, 'UTF-8').'" /> Your solidtrust pay account sci_password.</div> <label>'.$this->l('Currency').'</label> <div class="margin-form"> <input type="radio" name="currency" value="prestashop" '.($currency == 'prestashop' ? 'checked="checked"' : '').' /> '.$this->l('Use PrestaShop currency').' <br /><input type="radio" name="currency" value="customer" '.($currency == 'customer' ? 'checked="checked"' : '').' /> '.$this->l('Use customer currency').' </div> <br /><center><input type="submit" name="submitStPay" value="'.$this->l('Update settings').'" class="button" /></center> </fieldset> </form>'; } public function hookPayment($params) { if (!$this->active) return ; global $smarty; $address = new Address(intval($params['cart']->id_address_invoice)); $customer = new Customer(intval($params['cart']->id_customer)); //$receiver = Configuration::get('STPAY_RECEIVER'); $merchantAccount = Configuration::get('STPAY_MERCHANT_ACCOUNT'); $sci_name = Configuration::get('STPAY_SCI_NAME'); $sci_password = Configuration::get('STPAY_SCI_PASSWORD'); $currency = $this->getCurrency(); //if (empty($receiver)) //return $this->l('StPay error: (undefined receiver)'); if (!Validate::isLoadedObject($address) OR !Validate::isLoadedObject($customer) OR !Validate::isLoadedObject($currency)) return $this->l('StPay error: (invalid address or customer)'); $products = $params['cart']->getProducts(); foreach ($products as $key => $product) { $products[$key]['name'] = str_replace('"', '\'', $product['name']).'!'.$key.'!'; if (isset($product['attributes'])) $products[$key]['attributes'] = str_replace('"', '\'', $product['attributes']); $products[$key]['name'] = htmlentities(utf8_decode($product['name'])); $products[$key]['stpayAmount'] = number_format(Tools::convertPrice($product['price_wt'], $currency), 2, '.', ''); } $smarty->assign(array( 'address' => $address, 'country' => new Country(intval($address->id_country)), 'customer' => $customer, 'merchantAccount' => $merchantAccount, 'sci_name' => $sci_name, 'currency' => $currency, 'stpayUrl' => "https://pilot.solidtrustpay.com/handle.php", // products + discounts - shipping cost 'amount' => number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 4), $currency), 2, '.', ''), // shipping cost + wrapping 'shipping' => number_format(Tools::convertPrice(($params['cart']->getOrderTotal(true, Cart::ONLY_SHIPPING)), $currency), 2, '.', ''), 'discounts' => $params['cart']->getDiscounts(), 'products' => $products, // products + discounts + shipping cost 'total' => number_format(Tools::convertPrice($params['cart']->getOrderTotal(true, 3), $currency), 2, '.', ''), 'id_cart' => intval($params['cart']->id), 'item_id' => intval($params['cart']->id), 'return_url' => 'https://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$order->id.'&key='.$customer->secure_key, //'goBackUrl' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__,//.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.intval($params['cart']->id).'&id_module='.intval($this->id), //'return_url' => 'http://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__,//.'order-confirmation.php?key='.$customer->secure_key.'&id_cart='.intval($params['cart']->id).'&id_module='.intval($this->id), 'notify_url' => 'https://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/stpay/ipn-handler.php', 'cancel_url' => 'https://'.htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'index.php', 'user1' => intval($params['cart']->id), 'this_path' => $this->_path )); return $this->display(__FILE__, 'stpay.tpl'); } public function hookPaymentReturn($params) { if (!$this->active) return ; return $this->display(__FILE__, 'confirmation.tpl'); } public function getL($key) { $translations = array( 'to_stpay' => $this->l('Customer redirected to STPAY to complete payment.'), 'status' => $this->l('STPAY key \'status\' not specified, can\'t control payment validity'), 'payment' => $this->l('Payment: '), 'tr_id' => $this->l('STPAY key \'tr_id\' not specified, transaction unknown'), 'cart' => $this->l('Cart not found'), 'order' => $this->l('Order has already been placed'), 'verified' => $this->l('The STPAY transaction could not be VERIFIED.') ); return $translations[$key]; } function validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false) { if (!$this->active) return ; $currency = $this->getCurrency(); $cart = new Cart(intval($id_cart)); $cart->id_currency = $currency->id; $cart->save(); parent::validateOrder($id_cart, $id_order_state, $amountPaid, $paymentMethod, $message, $extraVars, $currency_special, true); } } ?> Edited September 13, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted September 14, 2017 Share Posted September 14, 2017 As I stated already, this module is not compatible with PS v1.6 Strict Standards: Declaration of StPay::validateOrder() should be compatible with PaymentModuleCore::validateOrder($id_cart, $id_order_state, $amount_paid, $payment_method = 'Unknown', $message = NULL, $extra_vars = Array, $currency_special = NULL, $dont_touch_amount = false, $secure_key = false, Shop $shop = NULL) in /home/vj2017/public_html/presta/modules/stpay/stpay.php on line 239 The validateOrder function defined in this module needs to be updated so it matches the validateOrder function in the Core PaymentModule class of Prestashop. Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 14, 2017 Author Share Posted September 14, 2017 Ok thanks PrestaShop Superstar, can you suggest me any 1.6 version free modules ??? Link to comment Share on other sites More sharing options...
bellini13 Posted September 14, 2017 Share Posted September 14, 2017 Ok thanks PrestaShop Superstar, can you suggest me any 1.6 version free modules ??? No And you don't need a new module, you just need to update your existing module so that it functions properly under PS v1.6. Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 15, 2017 Author Share Posted September 15, 2017 (edited) Sorry not sure how to update existing modules ??? Edited September 15, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
ersiranjeevi Posted September 21, 2017 Author Share Posted September 21, 2017 (edited) Suddenly am receiving this error Fatal error: Class 'ModuleFrontController' not found in /home/vj2017/public_html/presta/modules/stpay/controllers/front/validation.php on line 4 Here is the file , what am I doing wrong here ? again version issue ? Here is the mail file <?php if (!defined('_PS_VERSION_')) exit; class stpay extends PaymentModule { public function __construct() { $this->name = 'stpay'; $this->tab = 'payments_gateways'; $this->version = '1.0'; $this->author = 'stpay'; $this->bootstrap = true; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => '1.6'); parent::__construct(); $this->displayName = $this->l('stpay'); $this->description = $this->l('stpay payment module'); $this->confirmUninstall = $this->l('Are you sure you want to uninstall?'); } public function install() { if (!parent::install() || !$this->registerHook('displayPayment') || !$this->registerHook('displayPaymentReturn') || !$this->registerHook('actionPaymentConfirmation')) return false; return true; } public function uninstall() { return parent::uninstall() && Configuration::deleteByName('stpay'); } public function getHookController($hook_name) { require_once( dirname(__FILE__). '/controllers/hooks/'.$hook_name.'.php'); $controller_name = $hook_name.'Controller'; $controller = new $controller_name($this, dirname(__FILE__), $this->_path); return $controller; } public function hookDisplayPayment($params) { $controller = $this->getHookController('displayPayment'); return $controller->run($params); } public function hookDisplayPaymentReturn($params) { $controller = $this->getHookController('displayPaymentReturn'); return $controller->run($params); } public function getContent() { $controller = $this->getHookController('getContent'); return $controller->run(); } } ?> Here is the validation.php file <?php class stpayValidationModuleFrontController extends ModuleFrontController { public function postProcess() { define("TOKEN_IDENTIFIER", "token="); if (Configuration::get('STPAY_TEST_MODE_TEST') == 1) { define("IPN_V2_HANDLER", "https://*****"); } else { define("IPN_V2_HANDLER", "https://*****"); } // get the token from Stpay $token = urlencode($_POST['token']); //preappend the identifier string "token=" $token = TOKEN_IDENTIFIER.$token; $response = ''; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, IPN_V2_HANDLER); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $token); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 60); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($ch); curl_close($ch); if(strlen($response) > 0) { if(urldecode($response) == "INVALID TOKEN") { return "Invalid stpay token "; } else { $response = urldecode($response); $aps = explode("&", $response); $info = array(); foreach ($aps as $ap){ //put the IPN information into an associative array $info $ele = explode("=", $ap); $info[$ele[0]] = $ele[1]; } $transactionStatus = $info['ap_status']; $totalAmountReceived = $info['ap_totalamount']; $cart_id = intval($info['ap_cartid']); $cart = new Cart($cart_id); if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) $this->returnError('Invalid cart'); $customer = new Customer($cart->id_customer); if (!Validate::isLoadedObject($customer)) $this->returnError('Invalid customer'); $currency = new Currency((int)$cart->id_currency); if($transactionStatus == 'Success') { $this->module->validateOrder($cart->id, Configuration::get('PS_OS_PAYMENT'), $totalAmountReceived, $this->module->displayName, NULL, $info, (int)$currency->id, false, $customer->secure_key); } } } } public function returnError($result) { echo json_encode(array('error' => $result)); exit; } public function returnSuccess($result) { echo json_encode(array('return_link' => $result)); exit; } } Edited September 21, 2017 by ersiranjeevi (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted September 22, 2017 Share Posted September 22, 2017 Check that the class is still present in the classes folder Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now