Custom payment plugin error with the order confirmation

  • Posts: 5
  • Thank you received: 0
7 years 2 months ago #278376

-- HikaShop version -- : 2.6.4
-- Joomla version -- : 3.7.5
-- PHP version -- : 5.5.38
-- Browser(s) name and version -- : chrome

I made a plugin and the problem that I have is that in the function "onPaymentNotification" to confirm the order status it is not possible to make the funcion "getOrder" get the acrual order. When I check the log the variable "$dbOrder" is always empty and therefore "if(empty($this->payment_params))" is always true and I cannot continue processing the order status.

function onPaymentNotification(&$statuses)
	{
		$vars = array();
		$filter = JFilterInput::getInstance();
		foreach($_REQUEST as $key => $value) //Se reciben todas las variables provenientes de un HTTP POST de PayU
		{
			$key = $filter->clean($key);
			$value = JRequest::getString($key);
			$vars[$key]=$value;
		}
		$this->writeToLog(print_r($vars,true)."Array Recibido\n\n\n");

		//$order_id = (int)@$vars['reference_sale'];
		$order_id = (string)@$vars['reference_sale'];
		$this->writeToLog("\n Orden #: $order_id\n\n");
		$this->writeToLog("\n 2\n\n");
		$dbOrder = $this->getOrder($order_id);
		$this->writeToLog("\n dbOrder: $dbOrder\n\n");
		$this->writeToLog("\n 3\n\n");
		$this->loadPaymentParams($dbOrder);
		$this->writeToLog("\n 4\n\n");
		if(empty($this->payment_params))
		{
			$this->writeToLog("\n payment_params vacio\n\n");
			return false;
		}

Last edit: 7 years 2 months ago by Jerome. Reason: removing duplicate content (please do not put your message in the "error message" while it's not your error message). usage of [code] tag which is really, really nice !

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
7 years 2 months ago #278383

Hello,

First please note that the order_id must be a number and it need to contain the ID of an order created with the payment method.
Since your plugin right inherit from the HikaShop payment plugin ; the function getOrder will just get the order from the database.
The function loadPaymentParams will check that the plugin name is right according to the name of the plugin (stored in the $name variable).
And depending if your plugin is a multiple-instance or not, the code which will be processed to load the parameters will be different.
github.com/HikaShop/sample-payment-plugi...b/master/example.php

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
7 years 2 months ago #278463

Thank you very much. Now it is solved. The issue was that I was sending a string to the function getOrder and it wasn´t the ID of the order it was the Id number.
Thanks for your support.

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum