Pay Now button of My Orders display.

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 month ago #9383

The new Pay Now feature in customer My Orders listing looks good.

However there are 2 serious problems with the drop-down box,
Looking again at the paypal plugin, for example, found a couple of further issues (which I suppose could be irrelevant in amyn cases, but would be good to see fixed in the generic versions).

(a) It lists all payment methods defined in the payment table, including those which are disabled in the administration screen.

(b) It does not call the payment method onPaymentDisplay() function with the result that it displays all payment methods including those which are not valid in the context of the current order.

(c) Looking at the paypal onPaymentDisplay() function it does not check the enabled[/] flag.
This seems to be a generic problem of all the payment plug-ins.

The latest version of my own paypal plug-in onPaymentDisplay() function now looks like this (also showing call to my routine to check if paypal is compatible with selected shipping method):

function onPaymentDisplay(&$order,&$methods,&$usable_methods){
 if (!$this->isShippingValid(@$order->shipping)) return false;
 if (empty($order->total)) return false;
 if (empty($methods)) return false;

 $found = false;
 foreach($methods as $method){
   if($method->payment_type!='bf_paypal'){
    continue;
   }
   if (!$method->enabled) {
    continue;
   }
   if(empty($order->total)){
    continue;
   }
   if(!empty($method->payment_zone_namekey)){
    $zoneClass=hikashop::get('class.zone');
    $zones = $zoneClass->getOrderZones($order);
    if(!in_array($method->payment_zone_namekey,$zones)){
     continue;
    }
   }
   $currencyClass = hikashop::get('class.currency');
   $null=null;
   $currency_id = intval(@$order->total->prices[0]->price_currency_id);
   $currency = $currencyClass->getCurrencies($currency_id,$null);
   if(!empty($currency) && !in_array(@$currency[$currency_id]->currency_code,$this->accepted_currencies)){
    continue;
   }
   $usable_methods[$method->ordering]=$method;
   $found = true;
 }
 return $found;
}
(d) The paypal onPaymentSave() function does not check the value returned by the call to onPaymentDisplay(). My own version looks like this:
function onPaymentSave(&$cart,&$rates,&$payment_id){
 $usable = array();
 if ($this->onPaymentDisplay($cart,$rates,$usable)) { 
  $payment_id = (int) $payment_id;
  foreach($usable as $usable_method){
   if($usable_method->payment_id==$payment_id){
    return $usable_method;
   }
  }
 }
 return false;
}

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 month ago #9403

a and b/ Indeed, for now the onPaymentDisplay function is not triggered so everything is displayed. we'll have to look at that but that will mean that a LOT of data will have to be loaded as we will have to check the payment methods for each order and load the whole order data for each one...Over a few tens of orders, the system will probably just crash because of all the queries which have to be made for that.

c/That is not needed for the display as the function is only triggered for the published plugins. However, since that function is called from the onPaymentSave when the payment is selected, it would indeed be wise to check it to avoid hacks where a user would try to use a payment method which is not published...The consequences are really small so it's not really a problem.

d/ There is no need to check the return of the onPaymentDisplay function. That function will set the usable rate in the $usable variable. If the variable is empty, that means that there is no result and that it's false. The behavior will be exactly the same with or without the if.

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 month ago #9556

For (a) and (b) the Pay Now feature could be moved to the order display (shown when customer clicks order number).
Could be placed in the header next to the Print and Cancel buttons.
That way all the information about the particular order is to hand.

For now I will turn off the Payment of orders not paid immediately feature.

(c) Best to put enabled check in for completeness.

(d) Agreed, but including the if makes the code more readable and might be safer in the long term if some extra functionality gets added into that function.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 month ago #9564

We released a new version of HikaShopw which loads the data and only display the payment methods it should.

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11181

Disabled payment methods also appear in the drop-down list of the Administration / Sales form.

Should function load() in types/plugins.php after line 69 do a check like this:

else if (empty($method->enabled)) continue;

Could put the check in before line 67, but that would cause problems if a previously used payment method has since been disabled.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 week ago #11188

It's done on purpose. It allows you to change the payment method of an order after talking with the user so that he can pay with it without having to publish the payment method on the checkout.

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11189

Makes sense, but it is confusing.

For instance Moneybookers appears in my list, but are not using it, and may never.

Looks like if someone experiments with one of the payment methods (enabled it, changed config, disabled it) then it is always there.

If the payment method has never been touched then it does not appear.

Deleting the method from the payment table appears to solve the issue - but a less dangerous hide/display parameter would be preferred.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 week ago #11193

We indeed have to improve the payment plugins options... There is a bug where two set of options get in the table and mess the display but we couldn't find the cause of the problem yet. Having the possibility to remove the hikashop options of the payment plugins should do that "hide/display" parameter and make it easier to solve the other problem.

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11196

Just had a quick play with a shipping method I am not using.
Looks like the same hide/display feature would also be useful on the shipping methods.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 week ago #11198

Both payment and shipping handling have the same behaviour indeed.

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11260

When Pay Now button clicked in My Orders Shipping information $order->cart->shipping is missing in onAfterOrderConfirm() routine of payment plugin.

It is present during normal checkout.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 week ago #11262

Yes, the $order->cart object is not generated in the same way. And since no payment plugin need to use the shipping object, we didn't put the code to load it.
Is that something you need ?

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11263

In the payment plug-in I am using it to get:

$order->cart->shipping->shipping_name

$order->cart->shipping->shipping_price_with_tax

$order->cart->shipping->shipping_price

In the normal checkout process I could not see anywhere else to get these.

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

  • Posts: 81363
  • Thank you received: 13037
  • MODERATOR
13 years 1 week ago #11293

What you could try is to add the code below:
$shippingClass = hikashop::get('class.shipping');
$methods = $shippingClass->getMethods($order->cart);
$data = hikashop::import('hikashopshipping',$order->order_shipping_method);
$order->cart->shipping = $data->onShippingSave($order->cart,$methods,$order->order_shipping_id);

before the code:
ob_start();
$data = hikashop::import('hikashoppayment',$order->order_payment_method);

in the file components/com_hikashop/controllers/order.php
I didn't test so it might not work...

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

  • Posts: 291
  • Thank you received: 4
  • Hikashop Business
13 years 1 week ago #11309

That works, thanks.

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

Time to create page: 0.097 seconds
Powered by Kunena Forum