Google Checkout Fees Download 2010

It’s tax time again. If you have been using Google Checkout for a couple of years, you already know that you need to record Google Checkout fees on a regular basis since Google does not provide a way to get this information at the end of the year. The ability to get a year’s worth of transaction fees has been a highly requested feature from merchants for years. It’s 2011 and guess what, it’s still a highly requested feature. Why Google won’t make this simple change to their web interface, we’ll never know. I doubt it’s a scalability issue, as that is something Google is very good at. And many financial institutions, while they don’t allow you go back very far when doing downloads, provide year end statements, which is actually what most people need.

There is a solution that we have been using for the past few years. Actual steps change from year to year, but the idea behind it still works for tax year 2010.

You will need to use Firefox as your browser. You will also need to install the FireBug add-on for Firefox. Once you have Firefox with FireBug, we are ready to go to the next step.

1. Login to your Google Checkout Seller account and click on the Payouts tab.

2. At the bottom you will see two date dropdowns and a Download button. Click on the checkbox “Payout Details”.

3. Open FireBug and go to the HTML tab.

4. Search for the word “startRD”, and you will see the first date dropdown in the HTML source.

5. Click on the first option value and change it to “d:2010-01-01”. You can change the option label too if you want, but that’s not required.

6. Scroll down a little and you will see “endRD”, which is the second date dropdown in HTML source.

7. Click on the option value and change it to “d:2010-12-31”.

8. Now go back to the Download button you saw earlier on the HTML page and click on it. That will download a year’s worth of payout details, which includes transaction fees.

That’s it. You don’t have to go to each transaction and add all the transaction fees up. If you are having problems with the steps above, or have trouble using FireBug, let me know.


Testing Android Notification PendingIntent

So you’ve followed the Creating Status Bar Notifications in the Android DevGuide. You got the notification icon and ticker to appear on the status bar. In case you haven’t, here’s a code snippet.

NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

Notification notification = new Notification(R.drawable.icon, "ticker...", System.currentTimeMillis());
notification.flags = Notification.FLAG_AUTO_CANCEL;

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MyActivity.class), 0);
notification.setLatestEventInfo(this, "title...", "text...", pendingIntent);

nm.notify("tag...", 0, notification);

Note the code snippet above is more concise, and also automatically cancels the notification when the users selects it.

So how do you test the PendingIntent in your emulator? Those new to Android development would logically think that clicking on the notification icon in the status bar will call the PendingIntent Activity. However, the notification icon is not clickable. In the Android 2.x emulator, just like in the real mobile device, you would need to drag the statusbar down to see the notifications. You can also do it the long way by clicking the “Menu” button, and it will display the “Notifications” option.

Click on “Notifications” and you will get a list of notifications. Click on the one you created to trigger the Activity.


YUI Compressor in Java

Here’s how you can use the YUI Compressor in your Java code. This is useful if you need to integrate JavaScript compression into your application instead of simply adding it as a step in the build process. Parts of the code below have been taken from the actual YUI Compressor source code.

1. Download the YUI Compressor from the YUI Library Downloads page. Extract the YUI Compressor JAR file and add it to your classpath. The JAR filename follows the pattern yuicompressor-*.jar. The JAR file we used for this blog post is yuicompressor-2.4.2.jar.

2. You can use the command line program called com.yahoo.platform.yui.compressor.YUICompressor, passing parameters to main(), or you can use the class com.yahoo.platform.yui.compressor.JavaScriptCompressor. For this blog post, we will use the JavaScriptCompressor class directly.

3. Before we look into the compressor, let’s setup our sample program. I’ve included the import statements of the libraries we will be using as well.

package com.ws.common.util;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.io.IOUtils;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;

import com.yahoo.platform.yui.compressor.JavaScriptCompressor;

public class YuiCompressor {
    public static void main(String args[]) {
        try {

        } catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
        }
    }

    private static Logger logger = Logger.getLogger(YuiCompressor.class.getName());
}

4. Next let’s add an inner private static class that implements org.mozilla.javascript.ErrorReporter. This will contain callback functions that will be called when the compressor finds warnings or errors in the JavaScript code.

	private static class YuiCompressorErrorReporter implements ErrorReporter {
		public void warning(String message, String sourceName, int line, String lineSource, int lineOffset) {
			if (line < 0) {
				logger.log(Level.WARNING, message);
			} else {
				logger.log(Level.WARNING, line + ':' + lineOffset + ':' + message);
			}
		}

		public void error(String message, String sourceName, int line, String lineSource, int lineOffset) {
			if (line < 0) {
				logger.log(Level.SEVERE, message);
			} else {
				logger.log(Level.SEVERE, line + ':' + lineOffset + ':' + message);
			}
		}

		public EvaluatorException runtimeError(String message, String sourceName, int line, String lineSource, int lineOffset) {
			error(message, sourceName, line, lineSource, lineOffset);
			return new EvaluatorException(message);
		}
	}

5. Next, we will setup the different options we can pass to the JavaScript compressor. To make things simple, I have created an inner static public struct with all the default settings.

	public static class Options {
		public String charset = "UTF-8";
		public int lineBreakPos = -1;
		public boolean munge = true;
		public boolean verbose = false;
		public boolean preserveAllSemiColons = false;
		public boolean disableOptimizations = false;
	}

6. Now let’s go the compressor. We create a method called compressJavaScript that calls JavaScriptCompressor. The JavaScriptCompressor constructor takes in a java.io.Reader and its compress method takes in a java.io.Writer. We close the Reader before calling the compress method so we can have the output filename to be the same as the input filename if we wanted to. We also use Commons IO to close the character streams.

	public static void compressJavaScript(String inputFilename, String outputFilename, Options o) throws IOException {
		Reader in = null;
		Writer out = null;
		try {
			in = new InputStreamReader(new FileInputStream(inputFilename), o.charset);

			JavaScriptCompressor compressor = new JavaScriptCompressor(in, new YuiCompressorErrorReporter());
			in.close(); in = null;

			out = new OutputStreamWriter(new FileOutputStream(outputFilename), o.charset);
			compressor.compress(out, o.lineBreakPos, o.munge, o.verbose, o.preserveAllSemiColons, o.disableOptimizations);
		} finally {
			IOUtils.closeQuietly(in);
			IOUtils.closeQuietly(out);
		}
	}

7. Finally, specify the input and output JavaScript files and call our compressJavaScript() method.

			String inputFilename = "/original.js";
			String outputFilename = "/compressed.js";
			Options o = new Options(); // use defaults
			YuiCompressor.compressJavaScript(inputFilename, outputFilename, o);

That’s it. You can now compress JavaScript in your Java code. You can also download the complete YuiCompressor.java example source code. If you would like to use the YUI CSS compressor, look at the class com.yahoo.platform.yui.compressor.CssCompressor. The code you will have to write is very similar to the code above.