Hikashop developing a payment plugin gateway

  • Posts: 48
  • Thank you received: 0
10 years 2 weeks ago #179141

-- HikaShop version -- : 2.3.1
-- Joomla version -- : 3.3.1
-- PHP version -- : 5.4.43
-- Browser(s) name and version -- : MOZILLA FF 33.0.3

Developed a payment plugin based on ok payment plugin that came with the system.
It's for Tranzila gateway.
The thing is when a payment is successful order status doesn't get updated ,to confirmed.
When payment is bad the order does get cancelled ,only when good it's not confirmed.
The payment gateway send notify on both success and failure and I've built pages for both.
and on both pages I give order ID.(I give to gateway and gateway gives it back)
So I think if you explain to me the procedure how the order gets confirmed I would know where to try and debug.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 2 weeks ago #179142

Hi,

Did you read the HikaShop sample payment plugin code ?
github.com/HikaShop/sample-payment-plugi...b/master/example.php

The confirmation of the order is made line 217 in that sample plugin

$this->modifyOrder($order_id, $this->payment_params->verified_status, true, true);
It change the order status with the "verified status" from the plugin configuration.

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: 48
  • Thank you received: 0
10 years 2 weeks ago #179250

Yes I have seen that ,I already tried this:

$this->modifyOrder($order_id,$this->payment_params->verified_status,true,true);

didn't work ,so tried this

$this->modifyOrder($order_id,'confirmed',true,true);
also didn't work ,the order is still on status "created"

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

  • Posts: 48
  • Thank you received: 0
10 years 2 weeks ago #179251

If you don't mind me asking ,where is it declared? Where do I see the possible values of payment_params->verified_status
and cancelled status and so on!
I looked here:
hikashopPaymentPlugin

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 1 week ago #179335

Hi,

$this->payment_params->verified_status comes from your own payment plugin.
Normally, you have such attribute at the beginning of your payment plugin class:

	var $pluginConfig = array(
		'pbx_site' => array('Site', 'input'),
		'pbx_rang' => array('Rang', 'input'),
		'pbx_indentifiant' => array('Indentifiant', 'input'),
		'cancel_url' => array('CANCEL_URL', 'input'),
		'return_url' => array('RETURN_URL', 'input'),
		'invalid_status' => array('INVALID_STATUS', 'orderstatus'),
		'pending_status' => array('PENDING_STATUS', 'orderstatus'),
		'verified_status' => array('VERIFIED_STATUS', 'orderstatus')
	);
where you define the options of the configuration of the payment method and there you can see the line:
'verified_status' => array('VERIFIED_STATUS', 'orderstatus')
which add the dropdown to select the status the merchant wants when a successful payment notification comes in.
The values of the options are then loaded by yourself in $this->payment_params at the beginning of the onPaymentNotification by calling the function $this->loadPaymentParams($dbOrder); as in the example payment plugin.

The following user(s) said Thank You: Saiah

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179350

You have been very helpful ,thank you.

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179490

What triggers function onPaymentNotification(&$statuses){..
I think it is not being triggered at all !
It should be triggered both on payment success and failure ,right?!
I put this line of code inside it for debugging:
if($verified){ $this->modifyOrder($order_id,$this->payment_params->verified_status,true,true);mail("This email address is being protected from spambots. You need JavaScript enabled to view it.", "verified", "ok");}
else mail("This email address is being protected from spambots. You need JavaScript enabled to view it.", "verified", "bad");
I receive no mails at all ,although in other functions I do get mail.

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179493

this function
function onAfterOrderConfirm(&$order,&$methods,$method_id){
is being called when user has pressed the finish button to move to payment gateway page(embedded iframe)
while this function
function onBeforeOrderConfirm(&$order)
is not being called at all ,which is kind of weird!
what's the usual scenario here ,if I may ask?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 1 week ago #179535

Hi,

onPaymentNotification is called automatically when the payment gateway calls the notification URL of your payment plugin.
As you can see in the example plugin, the notification URL is:

http://yourwebsite.com/index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=example&tmpl=component
And you need to pass that URL to the payment gateway so that it can notify your plugin of the payment. In most cases, that is done in the onAfterOrderConfirm function at the end of the checkout, but it can also be done in the merchant account of the payment gateway based on how the payment gateway is done.

The trigger onBeforeOrderConfirm doesn't exist so it's normal that the function is not called in your plugin.

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179562

Thanks ,that makes sense.
What does this
index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=12&Itemid=12
trigger?
and what does this
index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id='.$order_id.$this->url_itemid;
trigger?

which functions are called?

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 week ago #179600

Hi,

The first one triggers nothing, it's just calling a view. The trigger called just before this is "onAfterOrderCreate(&$order,&$do)"

For the second one, the called trigger is "onBeforeOrderUpdate(&$order,&$do)"

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179670

Thank you so very much nicolas and Xavier.
I am a first timer with the whole Hikashop thing so I ask you to bear with me for I have a lot to ask about.
What is the function responsible for calculating final price and displaying it in checkout?
I need to make 25% off shipping price on second product for customers who order more than one product.
Where the highest shipping rate product will be the first.
So if a customer buys product A which ships for 40 and product B which ships for 80 ,then I will charge 80 for product B and only 30 for product A.which is 25% off. and so on if he orders 5 products he pays 100% for shipping only for the expensive one the rest he gets 75% price.

So to do this I need to know where the calculation is done and how!

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 1 week ago #179676

Hi,

The best would be to create a copy of the manual shipping plugin (so that you don't loose the modifications each time you update hikashop) and in that shipping, you can implement the onShippingDisplay function (see administrator/components/com_hikashop/helpers/helper.php for info on what this function contains).
In it, you can change the shipping price of the shipping methods on the fly and you also get in its parameters the content of the cart for your checks.

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

  • Posts: 48
  • Thank you received: 0
10 years 1 week ago #179768

That sounds like fun ,I have some questions though:
- A copy of manual shippment plugin you mean copy the files folder rename the folder and modify xml file and install with different name right?
- onShippingDisplay should be implemented inside manual class and parent::onShippingDisplay should be called from there as well?
- How do I get shipping cost for the product? both in onShippingDisplay and in my payment plugin?
I tried something like this:
foreach($order->cart->products as $product)
$ship_cost=$product->order_product_shipping_price;
it was a no go!

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 1 week ago #179784

Hi,

1. Yes, that's the idea of the copy.

2. Calling the parent::onShippingDisplay is interesting so you will have all features of the shipping interface. After the call, you can put some custom PHP code in order to add more filters (or new features) for the shipping methods.

3. The function onShippingDisplay gives you the cart with his products.
The product in the cart is not a "product", it's an "item". So you can access to the item custom field.
Bu you can read the product_id values of the products in the cart and load the products ; so you can access to the product custom field.

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: 48
  • Thank you received: 0
9 years 11 months ago #182464

Hi,
Sorry for not being around so much.

I have tried the method you suggested ,I have the following in my manual.php file ,which I made sure is the one loaded by the system:

class plgHikaShopshippingManual extends hikashopShippingPlugin {
	var $multiple = true;
	var $name = 'manual';
	function onShippingDisplay(&$order, &$dbrates, &$usable_rates, &$messages) 
	{
		parent::onShippingDisplay($order, $dbrates, $usable_rates, $messages);
now the problem is whatever code I do here does not effect the price calculated for shipment it still is the same price I defined for the product shipment.
For example if a product costs 40 to ship ,and in my manual shipment I add this:
foreach($ret as $ship) {
$order->shipping_prices[$key]->price_per_product[$ship->shipping_id]['products'][$ship->ref_id] = 15;
this should turn all costs to 15 ,but it doesn't ! :(

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #182523

Hi,

Your code doesn't makes sense.
In the function onShippingDisplay, you have these variables: &$order, &$dbrates, &$usable_rates, &$messages
There is no $ret, so I don't know what you're trying to do but either you have some other code you didn't provide or something else.

The goal of onShippingDisplay is to check all the shipping methods pertaining to the plugin in $dbrates and then to copy them in $usbale_rates. In the process of doing the copy, you can modify the price of the rate to whatever you want, but it's not in the $order that you should do that. It's in the rates that you copy from $dbrates to $usable_rates.

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

  • Posts: 48
  • Thank you received: 0
9 years 11 months ago #182534

Thank you for your reply,

If I want to set the overall shipping price to 15, always simply 15 ,how do I do it!?

$usable_rates->$shipping_price=15;
would this work?
I tried it, and it had no effect on the shipping price.
and when I try this:
$usable_rates[0]->$shipping_price=15;
I get an error that stdClass can't be converted to string!
This is how I see $usable_rates:
Array ( 
[3] => stdClass Object ( 
[shipping_id] => 3 [shipping_type] => manual [shipping_zone_namekey] => [shipping_tax_id] => 0 

        [shipping_price] => 40 
...

Last edit: 9 years 11 months ago by Saiah.

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

  • Posts: 48
  • Thank you received: 0
9 years 11 months ago #182600

I used this:

$usable_rates[0]->shipping_price=15;
and it worked just fine.
I also need to display shipping price together with product price on price display .(list display)
how to do this?

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

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
9 years 11 months ago #182602

You'll have to edit the file "listing_img_title" of the view "product" via the menu Display>Views and add custom code there to display the price you want.

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

Time to create page: 0.086 seconds
Powered by Kunena Forum