Jump to content

I need help hacking/adapting the Bankwire module


USB83

Recommended Posts

Hello,

 

I'm learning how to use prestashop by building a website for a non-profit organization that want to allow visitors to support them through paypal, bankwire and Western Union.

 

I noticed that the bankwire module has the exact same behaviour and steps needed for a western union payment method

 

I have no idea how prestashop module development goes but i thought it may be possible to have a western union payment module based on the bankwire module by duplicating the folder and editing some files.

I did that.

 

It works fairly well until the 'confirm order' button is clicked.

A 500 Server error happens at that step.

 

I activated the dev mod throught config/defines.inc.php, and here's the detail of the error :

 

Any help/indications provided on how to fix this error is highly appreciated !

 

 

[PrestaShopException]

 

Can't load Order status

at line 190 in file classes/PaymentModule.php

185.         }
186. 
187.         $order_status = new OrderState((int)$id_order_state, (int)$this->context->language->id);
188.         if (!Validate::isLoadedObject($order_status)) {
189.             PrestaShopLogger::addLog('PaymentModule::validateOrder - Order Status cannot be loaded', 3, null, 'Cart', (int)$id_cart, true);
190.             throw new PrestaShopException('Can\'t load Order status');
191.         }
192. 
193.         if (!$this->active) {
194.             PrestaShopLogger::addLog('PaymentModule::validateOrder - Module is not active', 3, null, 'Cart', (int)$id_cart, true);
195.             die(Tools::displayError());
PaymentModuleCore->validateOrder - [line 64 - modules/westernunion/controllers/front/validation.php] - [9 Arguments]

 

 

 

59. 			'{westernunion_owner}' => Configuration::get('WESTERN_UNION_OWNER'),
60. 			'{westernunion_details}' => nl2br(Configuration::get('WESTERN_UNION_DETAILS')),
61. 			'{westernunion_address}' => nl2br(Configuration::get('WESTERN_UNION_ADDRESS'))
62. 		);
63. 
64. 		$this->module->validateOrder($cart->id, Configuration::get('PS_OS_WESTERNUNION'), $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
65. 		Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
66. 	}
67. }
WesternunionValidationModuleFrontController->postProcess - [line 178 - classes/controller/Controller.php]

 

 

 

173.             if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) {
174.                 $this->setMedia();
175.             }
176. 
177.             // postProcess handles ajaxProcess
178.             $this->postProcess();
179. 
180.             if (!empty($this->redirect_after)) {
181.                 $this->redirect();
182.             }
183.
ControllerCore->run - [line 367 - classes/Dispatcher.php]

 

 

362.             if (isset($params_hook_action_dispatcher)) {
363.                 Hook::exec('actionDispatcher', $params_hook_action_dispatcher);
364.             }
365. 
366.             // Running controller
367.             $controller->run();
368.         } catch (PrestaShopException $e) {
369.             $e->displayMessage();
370.         }
371.     }
372. 
DispatcherCore->dispatch - [line 28 - index.php]

 

 

23. *  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
24. *  International Registered Trademark & Property of PrestaShop SA
25. */
26. 
27. require(dirname(__FILE__).'/config/config.inc.php');
28. Dispatcher::getInstance()->dispatch();

Thanks !

Edited by USB83 (see edit history)
Link to comment
Share on other sites

You are validating the order with western union order status (ps_os_westerunion) but you probably don't have that status.

 

$this->module->validateOrder($cart->id, Configuration::get('PS_OS_WESTERNUNION') .........

 

try to validate with existing status or create a one for western union.

 

just to see that its working try using 'PS_OS_CHEQUE'.

 

Good luck

Link to comment
Share on other sites

Hello,

 

Thank you for your reply,

 

Yes, i thought so.

 

I tried with 'PS_OS_CHEQUE'

 

Everything works fine until i click to confirm the order (as a customer), then this message appears :

We noticed a problem with your order. If you think this is an error, feel free to contact our customer service department.

But then the order appears both in the backoffice as 'pending check paiment' and as a customer i find it in the order history as well.

 

I tried adding a Western Union order status but apart from calling it : pending western union paiment, and picking a logo, i can't control how it is called internally ( eg : 'ps_os_westernunion') .

 

Any ideas on how to fix this ?

 

Thank a lot for your time

Link to comment
Share on other sites

Hi,

 

In order to call your new order status, you need to call it by its ID number so you can see the ID number in the BO under Order -> Statuses.

The reason you see Prestashop using PS_OS_CHEQUE or PS_OS_PAYMENT is because it is build in statuses that make the same as calling Configuration::get('PS_OS_CHEQUE') which return the number 1 for example from PS_CONFIGURATION Database table.

 

Now about the error that you get you should check hookPaymentReturn in your main module file.

The error is returned when the status is 'failed' instead of 'ok', so you should check that function.

 

Good luck

Link to comment
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...