Notice: Due to a redesign of the MBNet site, this application no longer works. I hope to update it someday. In the meantime, don't bother downloading it.
The MBNet service
Those living in Portugal will be familiar with the MBNet service. It is a service that allows to use a Portuguese debit card to make payments in sites that accept credit cards only. In practice, you login with a user name and password, enter a maximum amount, and it generates a virtual credit card number that can be used for a single payment for up to the amount you specified. This service is very useful and I use it for most of the payments I make on the Internet.
Sometimes I need to make payments by credit card and the only trustworthy Internet access available is my Android phone. That is a problem because the MBNet site is not designed for small touch screens. It has a virtual keyboard that is a mess to use on a touch device. Not satisfied with this situation, I decided to create an Android application that could be used as a front-end for the Web site. The result can be seen in the following pictures.
Downloading the application
Warning: When you download applications from unknown sources, you are exposing yourself to a risk. Before using this application, think about the following risks:
- Maybe this application sends your user name and password to some random hacker?
- Even if you trust me, maybe the application has a bug that could expose your password?
- This site might have been compromised and the application has been replaced by spyware?
In general, instead of downloading the application, you should download the source code, review it and then compile it yourself. In any case, I will not be held responsible if something happens to you after installing it.
If you are still interested, you can download the MBNet application here.
Since MBNet does not provide a publicly accessible API, which is understandable due to the nature of the service, I had to resort to Web scraping to implement the application. Web scraping consists of having a program interact with a Web site as if a real user was accessing it. This technique has some drawbacks. One of them is that even minor changes to the site can cause the application to break. Since there's no other way to do it, we will have to live with these potential problems.
A web scraper can be implemented in various ways. Some of them include:
- performing HTTP requests to the site;
- embedding a Web browser in the application.
The Android platform provides the WebView control to display HTML pages. Opening a Web page is as simple as invoking loadUrl on the WebView:
Interacting with the Web page
After finding out how to communicate with the page inside the WebView, it proved a viable solution for implementing Web scraping. I encourage you to read the source code for more details.
This program, along with its source code, is free software. You can use it under the terms of the GNU GPL license. For more information please consult the license.txt file inside the source distribution.