External System Communication

I run an internet cafe and although there are plenty of software solutions out there for managing the computers, they all have fairly terrible POS solutions. I’ve been running SambaPOS4 for a while and it’s absolutely perfect. I’d now like to integrate the cafe management software a little bit more closely with SambaPOS, an example of this closer integration working for one use case is as follows:

  1. New Ticket Created
  2. Cashier scans purchased items
  3. Customer requests to purchase a package of “computer time”
  4. Cashier selects computer time menu item and quantity
  5. SambaPOS requests customers computer user name
  6. Lookup to xml / json webservice for computer usernames
  7. If matching user is found add the username as a property or tag to that ticket item, otherwise display error and retry.
  8. Customer settles ticket and pays in full
  9. A further call is made to the xml or json service for each gaming time purchase letting the recieving end know the hours purchased and the username.

Is this sort of integration possible with SambaPOS 4? I’ve modified a copy of the open source SambaPOS 3 to do something fairly similar in quite a different way but I’d much prefer for this to work in 4 and moving forward I know a number of internet cafe owners would start using this solution immediately if I could get this functionality working.

Thanks for creating a great product, I’ll be singing its praises regardless of this issue :slight_smile:

Hello @RandyMagnum. Can you give more information about how we should structure data to send to these web services? … and what kind of data these services returns?

Hi Emre, Thanks for getting back to me!

I’ve started writing an addon myself, just a few IActionTypes set up to manipulate the tags on Orders. To start with I will just be calling a json service with a get like the following: GET:http://smartlaunchserver/users/username to check for a valid username when enetered. The returned data will be an empty json structure if no user is found so : {} and will contain user data that I want to parse and display if one is found such as minutes of computer time remaining on their account.

When all tickets that require a username have a valid user tagged against them and the ticket is paid for a PUT needs to be made to each users addproduct url so PUT:http://smartlaunchserver/users/username/addproducts with json that looks like the following:

“UserAddProduct” : {
“ProductID” : “39”,
“Quantity” : 1,
“Paymode” : 1,
“TotalPrice” : 1.10,
“IsTaxIncluded” : true,
“Note” : “”

I’m most of the way there now after poking around a bit, there hasn’t been much change in the architecture from v3 to v4 so I’ve been able to expose my own actions from my libraries, I’m just working my way through the UI elements now so I can make an appropriate pop-up box for asking and verifying the Smart Launch user name for each order item.

I’m glad to hear someone discovered using IActionType interface :slight_smile: Nice Job!

what is that???

tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us tell us …



Interesting I didn’t even try I figured it was not available. I figured any sort of API was still in development. I guess I should study up on JSON. I can only assume this is the method for developers to release their own projects in Sambamarket

I am also guessing based on your response @emre that it actually is still under development :stuck_out_tongue:

I would love to use this for my TImeTrex application. However I wouldn’t expect you to expose the function of it if its still under development. Maybe I should dig around myself :stuck_out_tongue:

TimeTrex has JSON support so I cannot wait to play around with that. It might just make my TimeTrex integration workaround completely obsolete lol

Just looking through the TimeTrex api through JSON I could completely integrate it. I may just play around see what I can discover this is pretty exciting.

So long as you don’t mind @emre. I know it wouldn’t be too hard to protect SambaPOS from this kind of modification :slight_smile: I must commend you on what I’ve come across so far though, there’s a great deal of extensibility in there, if you think it would help the community I’ll write up a blog on creating a module to add a feature like this to SambaPOS aimed at other .Net developers. I am however conscious that allowing this kind of modification can turn into a nightmare for a developer when it comes to support later down the line, so I don’t want to go telling people how to do this without your approval.

It would be important for me to note to anyone else reading at this point that because of the nature of adding modules like this, my tweaks could negatively impact the stability of SambaPOS and may also break easily if the SambaPOS application gets updated, in fact every time Emre releases a new version of the application there is a good chance my mods will need to be re-compiled against the new libraries, it’s a whole can of woms that I am very aware of and as such I wouldn’t recommend this approach to anyone who isn’t an experienced .Net developer.

@Jesse What I’m working with isn’t an API per-se, I’m writing new libraries that SambaPOS can load and interact with, what I am writing becomes a part of SambaPOS like an add-on. I’m not using JSON to create this, I am interacting with a JSON service with the library I am creating, but the mods are extremely specific to my use case and are written specifically to work with one API.

Wow :slight_smile: Randy found he can add new modules to V4. This is something for people who knows C# and want to add new actions that can be used from rules. In fact it is possible to add modules, add ons, new payment processors, custom printers or even new printer template tags without touching SambaPOS code. However like Randy states we still do not expect external use so we may change how it works and we may break these external modules. Our vision is improving extensibility where possible and allow people to make their own modules and release them through SambaMarket. We don’t care much about personal uses of these features but of course we’ll have a control on Market Modules. We should know it does nothing harmful.

We have another plans for a module that publishes an API to create/read tickets or access such SambaPOS features but this is something different.

@Jesse what you’ve did with TimeTrex was really awesome. We can improve it by converting it to a module that publishes an action to trigger TimeTrex functions but the most awesome thing was you showed us such integrations possible. Our first priority is our community so current community attention helps us to decide what to build so as we get more attention for such integrations we’ll focus on it more.

@RandyMagnum for now there is no need to document it since we still have things to do but you can use it as you want. Anyone can study on V3 code to understand how actions works and can implement their own actions.

I see. I knew there had to be more to it. I am far from a programmer. I know my basics and can learn rather quick but I am no programmer. (Though I have pondered studying up and becoming more proficient.)That is great to know however. I try to figure everything out its just who I am. Sometimes I read too far between the lines and end up being wrong. Sometimes it pays off for me but either way thank you for clearing that up for me.

If you’ve got the curiosity @kendash then there are tonnes of resources out there for you to start learning and I would highly recommend c#, it’s a wonderful language to work in and all the tools you need are completely free and top notch! If trying to figure everything out is your thing then there could well be a programmer hiding in you :smile: Plus you get the added bonus of being able to implement more complex processes into SambaPOS and maybe even help emre and the SambaPOS community as a whole by providing early implementations of awesome features. If it looks like my work will be of use to others I’ll undoubtedly release it in some way, shape or form but for now I must continue trying to inject my own new view and have it show up where I want, curse you RegionManager :smile:

Where are you trying to inject your view?

So I have a WPF user control similar to the Customer Search view that I would like to pop on the right side of the PoS screen when a “Select SmartLaunch User” action is triggered. So I’ve got an ActionType that’s publishing an event on order with the following code:

public override void Process(ActionData actionData)
    var order = actionData.GetDataValue<Order>("Order");
        if (order != null && order != Order.Null)

I’ve subscribed to that event in my module and all that is triggering properly according to my debugger. My modules constructor is as follows:

    public SmartLaunchModule(IRegionManager regionManager, IUserService userService, SmartLaunchUsersView smartLaunchUsersView, SmartLaunchUsersViewModel smartLaunchUsersViewModel) : base(regionManager, AppScreens.TicketView)
        this._regionManager = regionManager;

        _regionManager = regionManager;
        _smartLaunchUsersView = smartLaunchUsersView;
        _smartLaunchUsersViewModel = smartLaunchUsersViewModel;            

I’ve registered a view with the RegionManager in my modules OnInitialization:

 protected override void OnInitialization()
    {            _regionManager.RegisterViewWithRegion(RegionNames.PosSubRegion, typeof (SmartLaunchUsersView));            

and then when the event fires I make a call to

 _regionManager.ActivateRegion(RegionNames.PosSubRegion, (object)this._smartLaunchUsersView); 

but all that happens is I return back to the full ticket view with the numberpad on the right. It’s not throwing any errors that I’ve been able to catch so I’m assuming I’m either using the wrong region or there’s some default behaviour on the ActionType when using it as an Order modifier that is returning me to the Ticket view.

I’ve got to do more reading on Prism, it’s been about 2 years since I touched WPF and I’m feeling rusty, I was hoping I was going to be able to just make my View and ViewModel, bind them up and all would be well.

Can you PM me your project as a zip file?

@RandyMagnum your code working pretty fine however automation commands mapped to order lines automatically resets screen to menu screen. When I skip that your view displays pretty fine.

Now I need to find a solution for this. I don’t want to add a new setting to automation command for that but I’ll try to find a solution and let you know how to solve that.

Aha, I felt like something was taking control and returning to the ticket screen after an order action has been performed… Could I extend the order tagging or modifiers screen and add my control in there for specific products perhaps?? Instead of having to perform an action…

How many related products you have?

@RandyMagnum i have a nephew that works for Google and i am always envious of what he can do. i at one point was planning computer science as a career but backed off. So yes it has and always will interest me i just need to find time to learn it now that’s my problem.

I only need to do this to one category of products, I have a category called “Internet” that contains all the products that involve adding minutes of computer time to their logins. There really aren’t many products, top of 6 right now. In fact it doesn’t even need to be a search box the way that is laid out, I just thought it would be an easy start… I can do the whole thing with an auto-complete text box… really small, one row in a WPF grid somewhere will do me :smile:

  1. Maybe you should handle Order Added Rule and display it immediately as a product added with Internet category. So I think implementing an action is a great idea to handle different cases easily.
  2. You can’t take control on modifiers screen.
  3. I made following change in the highlighted area to let SambaPOS finish whatever it does and immediately display region.

1 Like

Your changes produce the desired result, I’m going to add some more controls to the search box using the Order model now passed in so it’s a bit more obvious that you’re making a modification to that order line, especially now the line appears to be de-selected.

I almost certainly will do something with the Order Added event, I’ll be checking if we already have a customer selected and if that customer has a SmartLaunch account name linked to it already, if it does then I’ll just grab that value from the custom field, this screen will then only be used if someone wants to buy hours for multiple users at the same time, eg Parent of three children buys them each 5 hours of game time and currently it needs to go through as three transactions and three receipts. SambaPOS is going to let me put it all through as one sensible transaction.

Thank you for your help figuring this one out Emre. I’m probably going to have another question in a few days when I’ve implemented this and I’ve moved onto interacting with my station entities. It’ll be nice to be able to print a seat number on a food order ticket based on which user ordered it and where they are currently sat. That’s very much a nice to have and not a vital part of the operation though.

Thank you again! :smile: