// Obtain the credentials from your configs
credentialObj = new APICredential();
credentialObj.setAPIUsername(getServletConfig()
.getInitParameter("PPAPIUsername"));
credentialObj.setAPIPassword(getServletConfig()
.getInitParameter("PPAPIPassword"));
credentialObj.setSignature(getServletConfig()
.getInitParameter("PPAPISignature"));
// setup your AppID from X.com
credentialObj.setAppId(getServletConfig()
.getInitParameter("PPAppID"));
// setup your Test Business account email
// in most cases this would be associated with API Credentials
credentialObj.setAccountEmail(getServletConfig()
.getInitParameter("PPAccountEmail"));
// add required error condition checks
//....
try {
// CreateSimplePreapproval request to setup a simple
// preapproval with no Payment Period Set
CreateSimplePreapproval simplePreapproval =
new CreateSimplePreapproval();
// set the API Credentials object (as given in the code above)
simplePreapproval.setCredentialObj(credentialObj);
// starting date in yyyy-MM-dd format
simplePreapproval.setStartingDate("2010-06-25");
// ending date in yyyy-MM-dd format
// in this case it's for an year from the starting date
simplePreapproval.setEndingDate("2011-06-25");
// set max total amount of all Payments
simplePreapproval.setMaxTotalAmountOfAllPayments(52.00);
// set max amount for each payment - let's say $1
simplePreapproval.setMaxAmountPerPayment(1.00);
// set max number of payments allowed - (52 weeks)
simplePreapproval.setMaxNumberOfPayments(52);
// set where to send the user in case of a cancellation
simplePreapproval.setCancelUrl(req.getRequestURL() +
"?action=preapproval&cancel=1");
// set where to return the user after successful approval
simplePreapproval.setReturnUrl(req.getRequestURL() + "?
return=1&action=preapproval&preapprovalKey=${preapprovalKey}");
/* Set other required fields */
// ... //
// set memo for user's transaction history
simplePreapproval.setMemo("Preapproval for GAE Sample");
// send the request
PreapprovalResponse preapprovalResponse =
simplePreapproval.makeRequest();
} catch (//...exceptions go here...//) {
// handle exceptions as necessary
}
I'm Reza and work in London, UK for a startup called TweetDeck. Our vision is to develop the best tools to manage and filter real time information streams like Twitter, Facebook, LinkedIn and MySpace. We offer products like our TweetDeck desktop client built on Adobe AIR, and our iPhone application. We are happy to say that we use App Engine as key part in our backend.
We're a small startup, so early on we started to look for tools that would give us the biggest bang for our buck. Combined with the fact we love Python, we thought it might be worth taking a look at what Google App Engine had to offer. The first feature we started playing with was the mail sending facility.
It was easy! Sending mail was a single call-- no messing around. Combined with the fact that it was sent via tried-and-tested Google Mail servers, this meant that we had a simple mailing solution where we didn't have to deal with spam blacklists, mail retries or SPF records. We could really see App Engine being our sole email provider for transactional emails (new users and forgotten passwords), but also for newsletter-type mailing.
When we got started, our existing backend was hosted on Amazon EC2 and SimpleDB, and we knew that we needed a way for the two systems to communicate with each other. App Engine provides all the basic tools to define any sort of resources you want--but more importantly, it has the Python standard library. We implemented a small mail API, with authentication provided by an HMAC-SHA1 of the request information and a shared secret key. The API has been made extremely general: its JSON input format contains fields to send messages to blocks of email addresses that are either defined in the request itself, or which exist as a template in App Engine (templates are defined as strings in a Python module).
The whole setup currently works quite well. We're already extending our mailing system to use App Engine's task queues-- exposing a number of queues to break large mailing jobs into a series of subtasks, thus spreading mailing sending over a large period of time. We have plans to make an even tighter bridge between our EC2 systems and App Engine, which involves keeping our subscriber list entirely in App Engine, and adding and removing from that list as appropriate.
We also use App Engine for various other prototypes and smaller applications that are part of our product. We use it to serve our "TweetDeck Recommends" feed, and we've even developed small tools to apply TweetDeck fan badges on Twitter homepage backgrounds using the Imaging API! The lesson from us, of course, is that using something like App Engine doesn't have to mean everything runs on it. It's an extremely good platform for creating APIs or smaller parts of your application that do specific tasks, and do them well. Think of it as the UNIX metaphor applied to the Cloud.
We love that we've been able to grow the functionality that Tweetdeck provides by progressively using more of the cloud. App Engine provides the perfect platform to compose new services quickly, iterate on them in production, and scale with demand as Tweetdeck's install base grows. Thanks to App Engine and the cloud, there's nothing holding us back from tackling the needs of our user base.
Here is a video interview of Reza and the Tweetdeck team.