Sunday, December 20, 2009

Subversion + Apache + Eclipse on Ubuntu 9.10 - the Karmic Koala

It's been many years I have been using Subversion (SVN), but didn't care much to know how it's installed, administrated & accessed over internet.

Here I will show you how to install & configure Subversion, Apache, to access Subversion over internet & accessing Subverion in Eclipse.

1) Installing Subversion

    a) sudo apt-get install subversion
       This will install Subversion

    b) sudo mkdir /var/svn
       This will create Subversion repository directory, I have choose to have it in /var, you can choose any other directory you want

2) Installing / Configuring Apache

    a) sudo apt-get install apache2 libapache2-svn
       apache2 (Apache 2 Http server), libapache2-svn (Apache module for SVN)
   
    b) gedit /etc/apache2/mods-available/dav_svn.conf

        I) Uncomment "DAV svn"

       II) SVNParentPath /var/svn - This you need to set if you want multiple repositories under a single directory
               
           SVNPath /var/svn/repo1 - This is when you just need a single repository
              
           For this example I will be using SVNParentPath set to /var/svn
   
      III) Uncomment / Set the below variables as

            AuthType Basic
            AuthName "Subversion Repository"
            AuthUserFile /etc/apache2/dav_svn.passwd

      IV) sudo /etc/init.d/apache2 restart

3) Creating Subversion repositories

    1) sudo mkdir /var/svn/project1
        sudo svnadmin create /var/svn/project1
        sudo svn mkdir file:///var/svn/project1/trunk -m "Trunk"
        sudo svn mkdir file:///var/svn/project1/tags -m "Tags"
        sudo svn mkdir file:///var/svn/project1/branches -m "Branches"

    2) sudo chown -R www-data.www-data /var/svn

4) Creating Users to access repository

    sudo htpasswd -c /etc/apache2/dav_svn.passwd user1

    Now if you hit http://localhost/svn/project1, you should be able to see trunk, branches & tags folder for project1 listed.

5) Configuring Eclipse to use Subversion

    I don't know there may be many plugins available, but I use Subversive plugin.

    a) Install Subversive plugin

    b) Go to SVN Repository Exploring perspective

    c) In SVN Repositories tab, Right click -> New -> Repository Location

        Enter http://localhost/svn/project1 into URL
        Enter user1 in User and the password
        Click on Finish

       You should be able to see the project1 repository along with its trunk, branches & tags folders.

Happy code versioning ..

Cheers !!

Saturday, December 19, 2009

sudo: /etc/sudoers is mode 0777, should be 0440

I wanted to edit /etc/sudoers, I try to edit it but it said "You do not have the permissions necessary to open the file."

AND THEN, I did chmod 777 /etc/sudoers, and yes, I know, that was so stupid to do :(

Anyways for those who did the same mistake, need not worry, just follow the steps below.

1) Restart your system in recovery mode
2) Drop into the root shell
3) Execute chmod 0440 /etc/sudoers
4) Reboot the system

That's it to it ..

And yes I am using Ubuntu 9.10 - the Karmic Koala :)

Tuesday, November 10, 2009

SagePay Payment Gateway Configuration in OFBiz

I was required to implement SagePay payment gateway for my client, as I had never implemented a payment gateway in Ofbiz before, I went through the test processor's method in PaymentGatewayServices and authorizedotnet payment gateway implementation code, and it helped me in implementing one myself.

When I started implementing, because of time constraint, I did it in an adhoc manner, and once it was working fine, I thought of contributing the code, for this again I had to properly structure the code and clean it up, anyways next time onwards I am planning of putting a bit more time and doing it correct at first time itself, so that I dont have to work again :)

If somebody wants to use SagePay as the payment gateway and if the code still isn't commited in Ofbiz, you can download the patch from


https://issues.apache.org/jira/browse/OFBIZ-3180.

Anyways let's get to the point, the implementation lets you configure all the usual parameters like the vendor name, version, payment gateway urls, but apart from this as SagePay has different transaction types, they too are configurable.

Now anybody using SagePay or planning to do so, may be aware of different transaction types available in SagePay.


Below are the transaction types available in SagePay :


1) PAYMENT - This is basically an authcapture.

2) AUTHENTICATE/AUTHORISE - This one is a normal auth/capture.
3) DEFERRED/RELEASE - This is same as auth/capture, but deferred transaction are not sent to the bank until you send a RELEASE request, ideally all deferred transacton should be released within 6 days.


So instead of hardcoding the transaction type in ccAuth & ccCapture service, the transaction type is take from the configuration, so it's easy to switch between the desired transactin types by just setting the config parameter. This should be clear by the screen shots below.

Once you have downloaded the code or applied the patch, you need to follow the steps below :

1) Run run-install-seed, this will build, create a new entity PaymentGatewaySagePay which stores the payment gateway configuration and insert seed configuration data.
2) Start ofbiz
3) Go to Accounting - Payment Gateway Config - select SagePay Payment Gateway from Payment Gateway Config Type Id from the dropdown and click LOOKUP
4) Click on SagePay Config from Search Results
5) Put your vendor name in Vendor Name field, I guess result all configuration will do, anyways check it out, and also notice the dropdown's for transaction types.
6) Click Update

We are done with payment gateway configuration, next is to configure payment services for store.

7) Go to Catalog - Stores - your store (am using ecommerce) - Payments
8) Configure the payment services, services are sagepayCCAuth, sagepayCCCapture, sagepayCCRefund & sagepayCCRelease, don't forget to set Payment Gateway Config Id to SagePay Config

That's it and you are ready to GO !!

Screen Shots