To be able to place orders locally using a payment app it needs to be able to communicate with the outside world. Lets have a look how to get that working with ngrok.
1. Download and register ngrok
Download ngrok and sign up free account. We will need that to use https. After you have signed up you will get an authtoken. Fire up you ngrok-terminal and type:
use ngrok.exe if you are using windows.
2. Exposing a server
Open up your docker-compose.yaml-file and scroll down to the ports section of the desired app. Shown below is the direct-payment example, in which we are interested in knowing that it uses port 10011.
The direct-payment app doesn’t need ngrok to work. But since it is present in the default installation of Litium we will use it as an example. You are probably doing this for a payment app such as Svea or Klarna.
Now go back to your terminal and run:
Or this in Windows:
You will now see something looking like this:
Copy the ngrok-url using https and lets continue.
3. Using the ngrok url
Go back to your docker-compose.yaml-file and set the AppMetadata__AppUrl to your ngrok url.
4. Docker time
Now stop your applications in docker and then run:
I got the error Client secret validation failed for client when using a Litium app one day. The reason was that Litium apps are not built to be used in a multiple development environment scenario and another developer has reinstalled an app on his machine. That way the app got new service account-credentials, that my environment did not know about.
To fix this you need to uninstall the app in question and remove the folder containing the app information as explained in the Payment and shipping documentation.
Litium apps are single install only, when you have installed your app once that apps install-link will not work again. If needed just follow the steps below to clear the app for re-installation:
Stop the container of the app you want to clear
Open the folder where you keep the docker-compose.yaml file from the docker-task
In the /data-subfolder of that folder you will find a direct-payment and a direct-shipment folder, delete the one you want to clear
Start the container again and the install link will work
Thanks to Nils at the Litium support for pointing this out to me.
One way to access the shared files folder that is used in some projects is to let the IIS application pool use the identity of the user that has access to that shared folder. That won’t work now when we are using the Kestrel web server.
Instead you can map that shared folder as a Network drive and reference that in appsettings.json. In Windows you right click in the explorer and select Add network location, on the mac you open Finder, select Go in the menu and click on Connect to server.
If you are going to use a multi-site setup where the sites should look a bit different to each other you need to change the default webpack configuration that is delivered with the Accelerator.
This is tested with the first version of the Litium 8 accelerator. Previous and later versions may differ.
1. Change entries
Add a new .scss file at Litium.Accelerator.Mvc/Client/Styles that we call secondsite.scss.
The existing site.scss has been renamed to firstsite.scss in this example.
Open up Litium.Accelerator.Mvc/Client/webpack/webpack.es6.js and find the entry points. At the time when I’m writing this post the entries looks like this:
Now lets split that up to add a second entry:
2. Update the MiniCssExtractPlugin
Scroll down to the MiniCssExtractPlugin settings in the same file as above. Right now it looks like this:
Update this section to look like this instead:
If you have yarn run build:w running you should restart it. This will generate two separate .css-files in the output directory.
3.Reference the correct file
This is out of scope of the post so I leave this up to you. But you must reference the correct css-file in Litium.Accelerator.Mvc/Views/Framework/Head.cshtml