Additional fees (subtotal) not transmitted to checkout paiement gateway

  • Posts: 54
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
5 years 2 months ago #311273

-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9.11
-- PHP version -- : 7.2.20

Hello,

I'm making a specific « donation » plugin. I think all working well, with trigger onAfterCartProductsLoad(&$cart) for adding $cart->additonal amount of donation like this :

$cartClass=hikashop_get('class.cart');
$currencyClass = hikashop_get('class.currency');
$currency_id = hikashop_getCurrency();


$donation = new stdClass();
$donation->name = 'Don '.$this->params->get('title', 'Don Caritatif');
// $additional->value = '';
$donation->price_currency_id = $currency_id;
$donation->price_value = floatval($amount);
$donation->price_value_with_tax = floatval($amount);

$cart->additional[$this->name]=$donation;
$cartClass->save($cart);

the $cart is successfully saved on db, but on next step, to the payment gateway, amount of donation not added on final total to pay and when I cancel or return to the cart, the additional amount of donation is missing... (on db too).

What's wrong ?

Thank-you in advance for your help.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 1 month ago #311284

Hi,

From what I understand of your message, you're saying that after being redirected to the payment gateway for the payment the amount of the additional fee is missing there.
So the first thing is to check the order in the backend of HikaShop. Do you have the additional fee there and is the total amount correct ?
If so, the problem is in the payment plugin used to integrate with the payment gateway which doesn't take into account additional fees.
Normally, most payment plugins send the full total of the order so it should work just fine.
However, a few payment gateways require the plugin to send the details of the order and then the payment gateway calculate itself the total. That's the case with the PayPal standard plugin when you activate the "send order details" setting of the plugin. However, the PayPal plugin supports additional fees as far as I know.
I guess I would need more information on which payment gateway you're using for your tests and how you configured the payment plugin to be able to say more on what's wrong exactly.

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

  • Posts: 54
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
5 years 1 month ago #311308

Hi Nicolas,

Thank-you for your response. I think the probleme is at my level, after checking the orders test, I can't see my additonal fees and order_full_price is correct without them. maybe I must adding a trigger function onBeforeOrderCreate(&$order, &$do) to add my additinal fees ?

my code is largely inspired from userpoint plugin :

function onAfterCheckoutStep($controllerName, &$go_back, $original_go_back, &$controller) {

if($controllerName != 'plg.shop.donation')
			return;
		
		
		
		$app = JFactory::getApplication();
		$amount = $_REQUEST['donation'];
		
		$app->setUserState(HIKASHOP_COMPONENT.'.donation_value', $amount);
		
		
		$checkoutHelper = hikashopCheckoutHelper::get();
		
		$cart = $checkoutHelper->getCart();
		$cart_id = (int)$cart->cart_id;

		
		
	
		$cart = $checkoutHelper->getCart();
		$cart_id = (int)$cart->cart_id;
		unset($cart);

		$cartClass = hikashop_get('class.cart');
		$cartClass->get('reset_cache', $cart_id);
		$cartClass->getFullCart($cart_id);
		$cart = $checkoutHelper->getCart(true);

		$cartClass->save($cart);
		
		
		
		
		return true;
		
		
	}
Thank you for clarifications.

Last edit: 5 years 1 month ago by nicolas.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 1 month ago #311326

Hi,

The code you posted in your last message does two things after your own custom step:
- it adds the donation amount in the session of the user
- it loads the cart and saves it (for no reason)

This in itself won't add your donation fee to the cart/order.
The code in your first message looks good, but I don't know where you have it or where you get $amount from.
Normally, I would recommend to add that code in the onAfterCartProductsLoad trigger and set the $amount variable with the amount you stored in the session (from your second piece of code).
Then, it should work properly.

The following user(s) said Thank You: consultech

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

  • Posts: 54
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
5 years 1 month ago #311350

Thank-you Nicolas,

Because I wanted to refresh (in ajax) view of current checkout step in page (donation block and cart details), the only way I've found is with function onAfterCheckoutStep trigger and job is done with onAfterCartProductsLoad function where I get my session variable $amount.

I'm just understanding how it work and now it's perfect. Thank-you for your help.

Regards,

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

Time to create page: 0.058 seconds
Powered by Kunena Forum