Laravel Redirect:to is ignored and not working

I was implementing Paypal with Laravel framework and when it came to performing redirect then it did not happen no matter what I tried.

I tried in controller something like

header('Location: https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token));

and

Redirect::to('https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token));

Turned out that manual is best friend like always and you have to use Redirect::to only in return statement like this

return Redirect::to('https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token));
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Laravel and PayPal “You do not have permissions to make this API call”

I discovered great new PHP framework Laravel. When trying it out I implemented Laravel Paypal bundle which was supposed to make the integrating it very simple. (Un)fortunately it was not so out of the box. Firstly the Paypal bundle is just a wrapper to make it easier using it in Laravel. You still have to use implementation manual like http://coding.smashingmagazine.com/2011/09/05/getting-started-with-the-paypal-api/. Secondly no matter what call I tried I always got response like

( [TIMESTAMP] => 2012-12-05T20:02:14Z [CORRELATIONID] => 375ff5175b9d [ACK] => Failure [VERSION] => 74.0 [BUILD] => 4181146 [L_ERRORCODE0] => 10002 [L_SHORTMESSAGE0] => Authentication/Authorization Failed [L_LONGMESSAGE0] => You do not have permissions to make this API call [L_SEVERITYCODE0] => Error )

I renamed configuration file paypal-sample.php to paypal.php and added correct Paypal username, password and signature into there. File stayed into Laravel bundles/paypal/config folder where artisan installed it.

Turns out this was mistake, configuration was read from wrong location and no credentials was sent to Paypal. When reading github manual closer then it says clearly the config file must be move into more logical place application/config/paypal.php

Another comment I have for Laravel Paypal bundle is that you need to use method names so that you add replace capital letters with underscore and lowercase letter. For example if you want to send SetExpressCheckout then you must use method Paypal::set_express_checkout(). Paypal bundle will convert it back to original form.

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Application code deployment from SVN with fast and simple rollback

Most important thing in every new release is the rollback procedure. Once you discover issues in new version then you need to be able to swithc back to previous version until you work on a fix. I have developed shell script to handle the automated deployment process and which allows quick and simple rollbacks if there are no database changes that dont allow easy rollback. Main idea is to

  • download code from SVN, GIT or similar
  • copy all code to new folder
  • replace all configuration with environment related conf
  • use symlink to switch between code versions

Here is example script that handles the automated deployment for you  Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Quality software testing guidelines (for startups)

Importance of software testing=quality assurance=QA cannot be stressed enough.  Here is experience from my startup regarding good quality testing process.

The goal of testing is to guarantee that the released code does not contain any critical issues. This is contrary to understanding that this is just finding as many defects as possible. There are 2 main types of testing: a) testing new features and bug fixes b) regression testing to validate that old code is still working.

Reporting defects

When issue is discovered then it is important that it will be very easily understandable and reproducible. Making extra effort to report issues in understandable format means that development team will be able to fix the issue much faster. Recommended format for reporting bugs is: Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Run Apache2 as specific user, non-root

It is very easy but hard to find exact syntax. None of the current google top searches bring it out. You have to use mpm_itk module and exact example of syntax is here, enjoy!

<VirtualHost *:80>
    ServerName website.com
    DocumentRoot /var/www/website.com
    <IfModule mpm_itk_module>
        AssignUserId username groupname
    </IfModule>
</VirtualHost>
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Error: redirect_uri_mismatch – Reset google authentication oauth api secret

I have a few webapps where I am using google login.  When you are running the app in different domain then you will get error like

Error:redirect_uri_mismatch
The redirect URI in request: http://mywebsite.com/ did not match registered redirect URI.

Also  you might want to create new app for google oauth2 login. Anyway it is for some reason very difficult to find the correct url, I always tend to end up in google apps page.

Here is the secret link  that solves all of your troubles

https://code.google.com/apis/console/b/0/

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Access virtualbox shared folders from Ubuntu and fix ruined ubuntu installation.

If you are running Ubuntu virtualbox guest then you cannot access the shared folder under /media/shared with regular user. However you can fix this by adding your user to vboxsf additional group.

Important! make sure you append the additional group so that other groups are not removed! Run te command below as exactly as seen and replace you username. If the permission is not applied immediately then reboot.

usermod -a -G vboxsf username

In case you forgot flag -a then it is bad but not hopeless :) Read the rest of this entry »

Share on TumblrSubmit to StumbleUponhttp://marguspala.com/wp-includes/images/smilies/icon_smile.gifDigg ThisSubmit to reddit

Recover virtualbox guest from failing snapshot

When making snapshot of running virtualmachine guest the process got stuck and left below traces in logfile. I had to kill hte snapshot process and reboot machine to continue.

vboxmanage snapshot mymachine take initial
00:00:14.576 PCNet#0: The link is back up again after the restore.
00:03:47.980 Changing the VM state from 'RUNNING' to 'RUNNING_LS'.
00:03:48.014 
00:03:48.014 !!R0-Assertion Failed!!
00:03:48.014 Expression: <NULL>
00:03:48.014 Location  : /build/buildd/virtualbox-4.1.12-dfsg/src/VBox/VMM/VMMAll/PGMAllBth.h(1458) void pgmR0BthEPTProtSyncPageWorkerTrackDeref(PVMCPU, PPGMPOOLPAGE, RTHCPHYS, uint16_t, RTGCPHYS)
00:03:48.014 HCPhys=00000000d5a37000 wasn't found!

After  reboot i see:

# vboxmanage list vms
"<inaccessible>" {d1d42d8a-38ed-4d6d-95a1-356d2896ff26}

Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

sh: 2: Syntax error: newline unexpected

Error happened when running perl script on Ubuntu machine after coping it from another.

Issue must have been caused by different encodings and was resolved by removing newline in the middle of the command.

        # Monthly Backup
        system("$MYSQLDUMP --user=$DB_USER --password='$DB_PASS' $db_name >
$BACKUP_DIR/$db/${db}_monthly_$datestamp.sql");

Changed to

         # Monthly Backup
         system("$MYSQLDUMP --user=$DB_USER --password='$DB_PASS' $db_name > $BACKUP_DIR/$db/${db}_weekly_$datestamp.sql");
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Creating VM-s via CLI using VBoxManage

If you happen to setup virtual machines to remote server then you might not have good access to graphical interface to use the VirtualBox graphical interface but you have to be able to manage using CLI. This gives you even more flexibility but needs some time until you can figure out what and how to do.

First create virtualmachine and register it with virtualbox.

VBoxManage createvm --name myvirtmachine --register

Create harddisk for this virtualmachine

VBoxManage createhd --filename myvirtmachinedisk --size 100000

Set some useful params for tis virtual machine

VBoxManage modifyvm myvirtmachine--ostype Ubuntu_64 --memory 2048 --cpuhotplug on --cpus 2 --nic1 bridged --bridgeadapter1 eth0

Create storage controller for virtual machine

VBoxManage storagectl myvirtmachine --name myvirtmachinestoragectl --add sata

Attach installation media into DVD drive to this storage controller. In this case i have downloaded previously the ubuntu isntaller CD

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 0 --type dvddrive --medium ../ubuntu-12.04-server-amd64.iso

Attach HDD to this storage controller

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 1 --type hdd --medium myvirtmachinedisk.vdi

Now you are ready to start the VM. First command is without vnc access, another has vnc access and you can get the access to console by opening vnc session to host machine.

VBoxHeadless -startvm myvirtmachine --vrde off
VBoxHeadless -startvm myvirtmachine --vnc --vncpass 12345
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit