Integrating CBA’s BPOINT gateway using ActiveMerchant
Recently a client of ours wanted to use the Commonwealth Bank of Australia (CBA)’s BPOINT gateway for their web application. The first thing we do is usually turn to ActiveMerchant to see if there is already a gateway class for the merchant. In this case we couldn’t find a gateway class or anything or any sort of implementation in ruby.
So today we’re releasing our open source BPOINT plugin for ActiveMerchant. Installation instructions and usage are available at the GitHub project page: https://github.com/Sentia/activemerchant-bpoint.
It’s very simple to setup and use, good luck and enjoy.
Reset Mysql Root password on Mac OSX
Had a strange issue where mysql started asking for a password for my local mysql after updating my mysql2 gem. So to fix this had to update my root password and here is how l did it
1. Stop MySQL service. You can do that using the preference pane if you have that installed or you can stop it using Terminal sudo /Library/StartupItems/MySQLCOM/MySQLCOM stop
2. Skipping Access Tables. If you have installed MySQL5, fire up Terminal window and execute /usr/local/mysql/bin/mysqld_safe –skip-grant-tables For older versions of MySQL, execute the following command /usr/local/mysql/bin/safe_mysqld –skip-grant-tables
3. Reset MySQL root password. Now when safe_mysqld running in one Terminal window, open up another Terminal window and execute /usr/local/mysql/bin/mysql mysql. This opening up the MySQL console and opening the mysql table so we can update MySQL root user. Write the reset query into the console as follows UPDATE user SET Password=PASSWORD(‘YOUR_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;. Replace “YOUR_PASSWORD” with your desired password.
4. Once you’ve done that just exit the console “exit;” close the safe_mysqld execution and restart your MySQL server. You can do this using sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
Once you have done that you can access mysql again with no issues
Adding your own login method to Authlogic
So on a new project we are working on we have a need for a user to be able to login via either their “Login” or “Mobile” number. Now we are using the Authlogic gem which is a great gem and comes with all default methods for login etc and allows you to customise this very easily.
So firstly you need to add the following to your UserSession model. What this does is overwrite the default login method with the one we are defining below called “find_by_username_or_mobile”.
class UserSession < Authlogic::Session::Base find_by_login_method :find_by_username_or_mobile end
Then in your user model its as simply as creating the class method for login. Now of course the password is still apart of the login process but we only wanted to allow users to either login via their login or mobile so no need to change the password methods.
class User < ActiveRecord::Base
def self.find_by_username_or_mobile(login)
find_by_login(login) || find_by_mobile(login)
end
end
So give it a try and let us know how you go hope this helps




