Payment plugin/API

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
3 years 1 month ago #330300

-- HikaShop version -- : 4.4.0
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.4

Hello,

We are in the process of linking an API / payment plugin with Hikashop / Hikamarket.
If we fetch the data with "$ this-> getRecordByOrder ();" and then a "print_r ($ this-> oRecord);" to look up what we all bring in, then we get this:

This message contains confidential information

We see that the shipping and transaction costs are generated as individual products per order. For this we would have to create a look-up that searches for "SHIPPING" and "PAYMENT" to split it from the total amount (because that is necessary in our case).

Is there an easier / safer way to split this data from the total amount? This is because if the word "SHIPPING" ever changes when updating to "SHIPPING_COST" for example, the API will no longer work correctly.

Regards,
Michiel

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

  • Posts: 81509
  • Thank you received: 13065
  • MODERATOR
3 years 1 month ago #330303

Hi,

I'm not sure what you're asking.
If you want to know how to get the shipping / payment cost from an order in HikaShop or your plugin, that's quite easy.
In a HikaShop $order object, you'll have the shipping fee in $order->order_shipping_price and $order->order_shipping_tax and for the payment it's $order->order_payment_price and $order->order_payment_tax
And you have the total amount of the order in $order->order_full_price.
So if you want to remove the shipping fee and payment fee from the order_full_price, it's just a small calculation.

But maybe you're talking about something else ?

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

  • Posts: 386
  • Thank you received: 7
  • Hikashop Business
3 years 1 month ago #330335

Hello,
We don't want it from the order, but it is for our payment plugin, so we can divide split the payment in the api to the psp. e.g.
from the total amount including transaction costs and shipping costs, see screenshot.


From the subtotal we have a fee of 9,68% for us as main seller,
The shippingcosts (Bezorgkosten) € 1,75 are for the vendor.
The transactioncosts are only for the customer..
We need to split those for our psp so it will be divided to the different accounts automaticly by the api.
Hope you understand now a little better.

Another question is:
How can i make a calculation with the "Klant algemeen totaal" € 22,25 and the vendor total € 20,27 as follows:
€ 22,25 minus € 20,27 = € 1,98 and show this in the email??

Hope you can help!!

Thanks..
Mark

Attachments:

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

  • Posts: 81509
  • Thank you received: 13065
  • MODERATOR
3 years 1 month ago #330343

Hi,

If you want to know what code you should use to get the amount that should be sent to each vendor and to the store from the total amount paid by the customer because you're developing a payment plugin with "adaptive" support, then I would recommend you look at what we've done in the file plugins/hikashoppayment/paypaladaptive/paypaladaptive.php
There, you'll find the afterOrderConfirm_Adaptive function which generates the data to be sent to PayPal for the payment. And it has some specific code to get the amount to send to each vendor of the order plus the amount to send to the main vendor (yourself).
I suppose that's what you're looking for.

If you want to add extra rows for the products listing in the email notifications, you'll want to edit the email via the menu System>Emails and modify the section "preload" at the bottom.
There, you'll find such code which adds the total row to the table:

$cartFooters[] = array(
				'CLASS' => 'total_with_tax',
			'NAME' => JText::_('ORDER_TOTAL_WITH_VAT'),
			'VALUE' => $currencyHelper->format($data->cart->full_total->prices[0]->price_value_with_tax,$data->cart->order_currency_id)
		);
So you can add such code with the calculations you want to add extra rows.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum