SlideShare a Scribd company logo
1 of 13
Download to read offline
Google
Checkout with
Ruby on Rails
Software Engineer, Consultant, Trainer
http://simplabs.com
Open Source
http://github.com/marcoow
http://github.com/simplabs
Marco Otte-Witte
USA/UK only!
Merchant Accounts
• Production Merchant Account
https://checkout.google.com/sell
• Sandbox Merchant Accournt
http://sandbox.google.com/checkout/sell
• => Merchant ID, Merchant Key
APIs
• HTML and XML APIs
• Notification APIs
• Example uses HTML API via HTTParty
Very(!) simple example
• Create Purchase with Google Checkout
• When Google Checkout confirms the
payment handle the Purchase in the app
Create Purchase
• Post an HTML Form to Google
• or create via HTML API:
post("/requestForm/Merchant/#{merchant_id}", :body => {
:_type => 'checkout-shopping-cart',
:'shopping-cart.items.item-1.item-name' => product.name,
:'shopping-cart.items.item-1.item-description' => product.description,
:'shopping-cart.items.item-1.quantity' => 1,
:'shopping-cart.items.item-1.unit-price' => price,
:'shopping-cart.items.item-1.unit-price.currency' => currency
})
• => returns serial-number to later identify
the purchase
Create Purchase
Notifications
• Register for Notifications:
(need SSH tunnel for local development)
Complete Purchase
• State Change Notifications:
def callback
type = params[:'_type']
serial_number = params[:'serial-number']
if type == 'order-state-change-notification'
order_state = params[:'new-financial-order-state']
purchase = GoogleCheckoutPurchase.find_by_serial_number(serial_number)
case order_state.try(:downcase)
when 'charged'
purchase.book!
when 'payment_declined', 'cancelled', 'cancelled_by_google'
purchase.fail!
end
end
render :text => "serial-number=#{serial_number}", :status => :ok
rescue
head :internal_server_error
end
A lot more can
be done!
Resources
• http://code.google.com/intl/de-DE/apis/checkout/
• https://rubygems.org/gems/google4r-checkout
Q&A

More Related Content

Viewers also liked (6)

Ember.SimpleAuth
Ember.SimpleAuthEmber.SimpleAuth
Ember.SimpleAuth
 
Open eGo, open source eGov-platform - Congres 2009 - V-ICT-OR
Open eGo, open source eGov-platform - Congres 2009 - V-ICT-OROpen eGo, open source eGov-platform - Congres 2009 - V-ICT-OR
Open eGo, open source eGov-platform - Congres 2009 - V-ICT-OR
 
Excellent
ExcellentExcellent
Excellent
 
Day 1 Jordan's Energy Efficiency Policies
Day 1 Jordan's Energy Efficiency PoliciesDay 1 Jordan's Energy Efficiency Policies
Day 1 Jordan's Energy Efficiency Policies
 
RSpec
RSpecRSpec
RSpec
 
Rails is not just Ruby
Rails is not just RubyRails is not just Ruby
Rails is not just Ruby
 

Similar to Google Checkout with Ruby on Rails

Similar to Google Checkout with Ruby on Rails (20)

Google Checkout for Umbraco
Google Checkout for UmbracoGoogle Checkout for Umbraco
Google Checkout for Umbraco
 
Shopify
ShopifyShopify
Shopify
 
Chrome Web Store に登録してみた
Chrome Web Store に登録してみたChrome Web Store に登録してみた
Chrome Web Store に登録してみた
 
A Tale of Two Shopping Carts - Cart66 vs WooCommerce
A Tale of Two Shopping Carts - Cart66 vs WooCommerceA Tale of Two Shopping Carts - Cart66 vs WooCommerce
A Tale of Two Shopping Carts - Cart66 vs WooCommerce
 
Flamingo Commerce Module Details
Flamingo Commerce Module DetailsFlamingo Commerce Module Details
Flamingo Commerce Module Details
 
Building Ecommerce Storefronts on the JAMstack
Building Ecommerce Storefronts on the JAMstackBuilding Ecommerce Storefronts on the JAMstack
Building Ecommerce Storefronts on the JAMstack
 
Testing In App Billing
Testing In App BillingTesting In App Billing
Testing In App Billing
 
OpenCart Amazon Connector Extension
OpenCart Amazon Connector ExtensionOpenCart Amazon Connector Extension
OpenCart Amazon Connector Extension
 
An Introduction to Drupal Commerce & Real World Examples
An Introduction to Drupal Commerce & Real World ExamplesAn Introduction to Drupal Commerce & Real World Examples
An Introduction to Drupal Commerce & Real World Examples
 
Customer Automation Masterclass - Workshop 1: Data Enrichment using Clearbit
Customer Automation Masterclass - Workshop 1: Data Enrichment using ClearbitCustomer Automation Masterclass - Workshop 1: Data Enrichment using Clearbit
Customer Automation Masterclass - Workshop 1: Data Enrichment using Clearbit
 
How to migrate Yahoo Store to Shopify with Litextension
How to migrate Yahoo Store to Shopify with LitextensionHow to migrate Yahoo Store to Shopify with Litextension
How to migrate Yahoo Store to Shopify with Litextension
 
B2C-Commerce-Developer Dumps
B2C-Commerce-Developer DumpsB2C-Commerce-Developer Dumps
B2C-Commerce-Developer Dumps
 
LA2M Google Tools Presentation Apr 1st 09
LA2M Google Tools Presentation Apr 1st 09LA2M Google Tools Presentation Apr 1st 09
LA2M Google Tools Presentation Apr 1st 09
 
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckboxCustom Automation Masterclass – Workshop 2: Email validation using kKckbox
Custom Automation Masterclass – Workshop 2: Email validation using kKckbox
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integration
 
Ecommerce for Associations
Ecommerce for AssociationsEcommerce for Associations
Ecommerce for Associations
 
How To: Use Google Search Ap Is On Your Blog
How To: Use Google Search Ap Is On Your BlogHow To: Use Google Search Ap Is On Your Blog
How To: Use Google Search Ap Is On Your Blog
 
Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01Cart creation-101217222728-phpapp01
Cart creation-101217222728-phpapp01
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
 
How to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdfHow to Integrate Google Adwords API in Laravel App.pdf
How to Integrate Google Adwords API in Laravel App.pdf
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Google Checkout with Ruby on Rails

  • 2. Software Engineer, Consultant, Trainer http://simplabs.com Open Source http://github.com/marcoow http://github.com/simplabs Marco Otte-Witte
  • 4. Merchant Accounts • Production Merchant Account https://checkout.google.com/sell • Sandbox Merchant Accournt http://sandbox.google.com/checkout/sell • => Merchant ID, Merchant Key
  • 5. APIs • HTML and XML APIs • Notification APIs • Example uses HTML API via HTTParty
  • 6. Very(!) simple example • Create Purchase with Google Checkout • When Google Checkout confirms the payment handle the Purchase in the app
  • 7. Create Purchase • Post an HTML Form to Google • or create via HTML API: post("/requestForm/Merchant/#{merchant_id}", :body => { :_type => 'checkout-shopping-cart', :'shopping-cart.items.item-1.item-name' => product.name, :'shopping-cart.items.item-1.item-description' => product.description, :'shopping-cart.items.item-1.quantity' => 1, :'shopping-cart.items.item-1.unit-price' => price, :'shopping-cart.items.item-1.unit-price.currency' => currency }) • => returns serial-number to later identify the purchase
  • 9. Notifications • Register for Notifications: (need SSH tunnel for local development)
  • 10. Complete Purchase • State Change Notifications: def callback type = params[:'_type'] serial_number = params[:'serial-number'] if type == 'order-state-change-notification' order_state = params[:'new-financial-order-state'] purchase = GoogleCheckoutPurchase.find_by_serial_number(serial_number) case order_state.try(:downcase) when 'charged' purchase.book! when 'payment_declined', 'cancelled', 'cancelled_by_google' purchase.fail! end end render :text => "serial-number=#{serial_number}", :status => :ok rescue head :internal_server_error end
  • 11. A lot more can be done!
  • 13. Q&A