-- HikaShop version -- : 2.3.5
-- Joomla version -- : 3.4
-- PHP version -- : 5.5
-- Browser(s) name and version -- : Chrome
Hi,
I've made my own payment plugin that selects a payment method and issuer in the payment selection pane. When I accept my choices and press the 'finish' button, the same page reappears. Pressing 'finish' once more takes me to the redirect to payment service provider page.
While debugging this issue I found in checkout.php the following snippet that plays an important role here (lines 1187 and further)
$app = JFactory::getApplication();
$old_payment_method = $app->getUserState(HIKASHOP_COMPONENT.'.payment_method');
$old_payment_data = $app->getUserState(HIKASHOP_COMPONENT.'.payment_data');
$old_payment_id = $app->getUserState(HIKASHOP_COMPONENT.'.payment_id');
$app->setUserState( HIKASHOP_COMPONENT.'.payment_method',$payment);
$app->setUserState( HIKASHOP_COMPONENT.'.payment_id',$payment_id);
$price_all = @$cart->full_total->prices[0]->price_value_with_tax;
if(isset($cart->full_total->prices[0]->price_value_without_payment_with_tax)){
$price_all = @$cart->full_total->prices[0]->price_value_without_payment_with_tax;
}
$currencyClass = hikashop_get('class.currency');
$currencyClass->convertPayments($rates);
$paymentData->payment_price = ($price_all * (float)@$paymentData->payment_params->payment_percentage / 100) + $paymentData->payment_price;
$app->setUserState( HIKASHOP_COMPONENT.'.payment_data',$paymentData);
if(!empty($paymentData->ask_cc)){
$paymentClass = hikashop_get('class.payment');
if(!$paymentClass->readCC()){
return false;
}
}
if(($old_payment_id!=$payment_id || $old_payment_method!=$payment) || @$old_payment_data->payment_price!=$paymentData->payment_price && ($this->_getStep('cart',(int)$this->previous)===(int)$this->previous || $this->_getStep('confirm',(int)$this->previous)===(int)$this->previous)){
return false;
}
My workaround is to preload the $app->getUserState(HIKASHOP_COMPONENT.'.payment_method'); and $app->getUserState(HIKASHOP_COMPONENT.'.payment_id'); in the plugin's onPaymentSave() method in the following manner:
$app = JFactory::getApplication();
$app->setUserState( HIKASHOP_COMPONENT.'.payment_id',$payment_id);
$app->setUserState( HIKASHOP_COMPONENT.'.payment_method','mypayment');
This workaround seems to be OK, but I'm wondering what the purpose of the check in checkout is and whether such a workaround is needed.
Your thoughts are appreciated, as always.
Best regards, Paul