Now we can adapt our checkout process to use our new shopping cart. Previously we created a simple checkout process using Django templates and the Google Checkout buy-it-now button. The obvious limitation of this approach was that customers can only purchase one item at a time. Using our shopping cart, we allow customers to select as many items as they like, but this requires us to modify the checkout process.
Earlier we discussed the checkout view and a helper method, doGoogleCheckout()
, which performed two actions. First, it converted our internal representation of the customer's shopping cart to a format that Google Checkout API can understand. Second, it created a cryptographic signature of this shopping cart using our secret Merchant Key identification. This signature is how Google Checkout's API verifies that the purchase request is coming from our web application.
Here is the doGoogleCheckout
function in its entirety:
Import hmac, sha, base64 from django.template...