7
votes

I'm trying to find a way to use the Joomla extension Hikashop in parallel with another external website built with Laravel.

I'm using :

  • Laravel 5.5
  • Joomla 3.8.x

Here is how the setup looks (extremely simplified) :

 ___________________________                         ________________
|Joomla server with Hikashop| <---- API calls ----> | Laravel server |
 ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻                         ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻

To get products, prices, purchases etc. all is done through API request to the Joomla website using the com_api component and a custom plugin that returns everything I need.

For user consistency, whenever a user is created, modified or deleted on Laravel, the user is created, modified or deleted on Joomla.
Note 1 : The user cannot edit his profile on Joomla so the sync is only one way.
Note 2 : The login should only be on the Laravel website

Here is the problem i can't get around : on the Laravel website, when the user wants to buy a product, he is redirected to the Joomla website to access the Hikashop interface and pay for the product. This creates multiple questions :

Question 1 : Since the user is on Laravel, he has not session yet on Joomla. How do you pre-create the Joomla session using an API so that when the user arrives on Joomla he is already logged in ?

Question 2 : Once the payment is made, how do you redirect the user the the previous page on Laravel ? (The trigger is good, the only issue is passing the "origin" URL around)

I've tried looking into SSO (Single Sign On) but i would like to keep the two systems separated.

Thank you in advance if you have any ideas or ways to pass session + data from one website to another !

1
Hi, blackjak231 I know it's too late to ask you. Do you find the solution to the mentioned problem?aMoL Thite
Hi @aMoLThite, we ended up doing a custom API on Joomla using the com_api extension. For the redirect+login from Laravel to Joomla, we created a GET api on Joomla that would take a token in a url parameter called token which was : base64(joomla_user_id+joomla_server_api_token+laravel_user_id+target_joomla_url). With this token, we would then call a login method for the joomla user and redirect to the target url passed in the parameter.blackjak231
For the payment, we were not able to do the "go back to previous page" like we wanted. Instead, we redirected the user back to the product he just bought (in this case, courses, videos etc. non-material things). For this, we used the joomla_product_id from hikashop and an API on Laravel to redirect to the details page of the product in question.blackjak231

1 Answers

0
votes

In my own understanding this is , how I will do it. First if you are form laravel, you needed to be authenticated. You assign the user from laravel with the equivalent user_id in joomla if you have same user in joomla. If not never mind.

just make the user authenticated either laravel and joomla. Make a token after signed private token not jwt or oauth2. Just to make sure that when you successfully login in both laravel and joomla. there is a similar token related for both of them. Then you are good to do now.