Payment return URL fails

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #352976

-- HikaShop version -- : 4.7.1
-- Joomla version -- : 4.2.8
-- PHP version -- : 8
-- Error-message(debug-mod must be tuned on) -- : Questa pagina non reindirizza in modo corretto

Hi,
I've implemented a payment plugin based on the one indicated, but slightly different because based in API and not on forma data sending.
Everything works ok until redirect to checkout, which fails. This is the plugin workflow:

- onAfterOrderConfirm: I send payment data to API and receive back Transaction Id and the return url for display payment options
- I store transcation Id in order_payment_params DB (needed later) and redirect to return URL
- on returned URL I make the payment (sandbox mode)
- after payment is completed the system redirects to notify URL
- onPaymentNotification: I get the transaction Id from DB, based on order Id and send it back to API to check payment
- Payment is confirmed, so I update the order state to verifiled

Until now everythig works like a charm, but when I try to redirect to return URL I get the error
"Questa pagina non reindirizza in modo corretto
Si è verificato un errore durante la connessione a zoequattro.davide-strati.it.
Questo problema spesso è causato dal blocco o dal rifiuto dei cookie."

Return URL is:
HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$order_id.$this->url_itemid;
Returned is like:
zoequattro.davide-strati.it/index.php?op...order_token=ADnplTaq

I tried disabling Attachinvoice plugin, that gave problems, with no result.
I enabled debugging at higher grade, bu no error is outputted.
Payment logs are ok.

If you want you can test the payment with the following data:
MasterCard nr. 5256103270096532
valid until 04/25
CVV2: 241

Attached you can see Payment log.
Thanks for help!

Barbara

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #352983

Hi,

I think you redirect to the return URL from inside the onPaymentNotification function, right ?
In there, it uses the current Itemid parameter is receives to set $this->url_itemid which you then add at the end of the URL.
However, in your log, I can see that you don't add the Itemid in the notification URL:

notifyURL = https://zoequattro.davide-strati.it/index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=pagonline&tmpl=component&order_id=219
If you had instead
notifyURL = https://zoequattro.davide-strati.it/index.php?option=com_hikashop&ctrl=checkout&task=notify&notif_payment=pagonline&tmpl=component&order_id=219&Itemid=125
it would provide the Itemid parameter to $this->url_itemid and then your return URL would have the Itemid parameter in it and it would probably display fine.

Now all this is speculation on my end because I don't have the code of the plugin. If that doesn't help you, I think I would need to look at the code to better understand the situation.

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353088

HI,
thanks for the answer.

nicolas wrote: I think you redirect to the return URL from inside the onPaymentNotification function, right ?

Yes

I tried your suggestion and saw than, even if both error_url and notify_url has all parameters set, they are not sent on redirect.
I made another test, that failed, and the redirect to error_url was missing both parameters: order_id and ItemId and the result was the redirect error as usual.

What is strange is that even if I write manually the right URL, ie zoequattro.davide-strati.it/index.php?op...er_id=222&Itemid=125 the redirect error raises.

Another strange thing is that, even if on log file the notify_url is correct:
zoequattro.davide-strati.it/index.php?op...&ctrl=checkout&task= notify¬if_payment=pagonline&tmpl=component&order_id=222&Itemid=125
on HikaShop logs it results like this:
zoequattro.davide-strati.it/index.php?op...&ctrl=checkout&task= notify¬if_payment=pagonline&tmpl=component&order_id=222&Itemid=125
Why? Could it be a problem?

Thanks for support.
Barbara

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353089

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #353100

Hi,

The ¬ character you see is just a byproduct of your browser displaying the URL without having it first htmlentities applied on the URL. So it's not a problem. The URL used in the plugin is actually correct.

Could you provide again the log with the changes you made and a copy of the code so that we can better understand what could go wrong ?
Maybe there is some kind of logic issue in the code of your onPaymentNotification function which leads to the Itemid not being added to the return URL where the user is being redirected to

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353252

Hi,
I made some other test.

Parameters are correctly sent to API and received back.
In fact, onPaymentNotification I get order_id by query, get transaction_id by payment parameters and update order status correctly as you can see from logs).

I then tried to put a die($redirect_url) at the end of onPaymentNotification function and the url result was correc, with all parameters sett:
mytestsite.it/index.php?option=com_hikas...=NwkZJDZV&Itemid=125
The problem raises on redirect.

I checked that login cookies were maintained and it was ok.
But I know for sure (from other sites implementations) that SESSION parameters are lost after redirect from API url.
Could it be the problem that causes the malfunction in redirect?

Thank you again.
Barbara

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353253

I forgot to tell you that after redirect error, if I go to main page, I'm not logged anymore, even if in cookies joomla_user_state is set as logged_in.
I think that, after redirect, the user results unlogged and redirect try to send him to login page, causing redirect loop.
Is there a way to keep user data without sessions after API redirect?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #353257

Hi,

Redirecting the user won't loose the user session. We often do redirects in HikaShop and this is not an issue.
If the redirect URL is correct just before the redirect, then, the only reason I can see is this:
Could it be that the product you're trying to purchase for your tests has the option "user group after purchase" set to something ?
In that case, the HikaShop user group after purchase plugin will change the user group of the user and delete its current user session in order to force the user to login with the new accesses (otherwise, the user wouldn't see the new access as it is cached by Joomla in the user session).

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353272

HI,

nicolas wrote: Redirecting the user won't loose the user session. We often do redirects in HikaShop and this is not an issue.


I believe that redirects inside Hikashop won't loose users session.
The problem is that redirect after API call looses sessions. It's an API related problem unfortunately.
In another site, for example, after redirect I loose Privacy cookie session and had to study a trick not to show privacy window again...

But I made now another test, checking if the user was still logged and I could retrieve user data, so it's not a session problem...

All products have "user group after purchase" option disabled.

I've got no more ideas on what it could be the problem... :(

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353275

One more idea...

The last thing I do before redirecting is to modify order status in this way:

$this->modifyOrder($order_id, $this->payment_params->verified_status, true, true);
That means that confirmation email should be sent, true?

If I go to email history I can see all emails sent, but I never received a mail!!!
Could it be an email related problem?
May be from test site mails are not sent because website domain and email domain are not the same or a similar misconfiguration.

I'm sorry but I was called only to develop this payment plugin and didn't set all other shop parameters and don't know all of them.
Thanks again.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #353279

Hi,

If you see the emails in the email history, it means HikaShop sent the emails to the email sending server of the hosting based on how you configured the email settings of the Joomla configuration and the HikaShop configuration.
If you don't receive them, first, you can use the test email button of the Joomla configuration to make sure that the email settings of Joomla are properly configured.
Then, supposing this is ok, it's probably a problem with the email settings of the HikaShop configuration. For example, if the receiver and sender of an email are the same, some email servers won't deliver the email and will just ignore it.

In anyways, it's not linked to the redirect or cookies.

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

  • Posts: 11
  • Thank you received: 0
1 year 4 months ago #353296

Hi,
finally I found the problem!!!

In plugin payment parameters configuration I set as return URL:
www.mytestsite.it/index.php?option=com_h...ckout&task=after_end
with no parameters, but on redirect there were parameters about order.

I tried deleting return_url from configuration parameters and finally order finished on a static (and poor) page confirming order payment, but with no SEF rewrite in the URL.

I think this is not the best way...
Maybe I should update return_url with parameters onPaymentNotification? How can I do it?
Or what else?
I would like to approde to www.mytestsite.it/order/confirm/ page.

Thanks.
Barbara

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
1 year 4 months ago #353297

Hi,

If your payment plugin has a "return_url" option, then it means you want to allow the customer to provide the URL where you redirect back the customer when it arrives on the after_end URL. So if you enter the after_end URL in there, it creates a loop, which you don't want.

If you the user doesn't provide a "return URL" or if you don't have the option in the plugin, then HikaShop will stay on the default after_end URL. If you want that URL to be SEFed, you need to call JRoute::_() on it.
So intead of :
$return_url = 'index.php?option_com_hikashop&ctrl=checkout&task=after_end'.$this->url_itemid;
you could write:
$return_url = JRoute::_('index.php?option_com_hikashop&ctrl=checkout&task=after_end'.$this->url_itemid);
The resulting URL should then be something like that:
mywebsite.com/alias-on-checkout/checkout/after_end

The following user(s) said Thank You: longhiba

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

Time to create page: 0.056 seconds
Powered by Kunena Forum