Class: Google4R::Checkout::NewOrderNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::NewOrderNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends <new-order-notification> messages to the web service when a new order has been successfully filed with Google Checkout. These messages will be parsed into NewOrderNotification instances.
Instance Attribute Summary collapse
-
#buyer_billing_address ⇒ Object
The buyer’s billing address (Address).
-
#buyer_id ⇒ Object
The buyer’s ID from Google Checkout (String).
-
#buyer_shipping_address ⇒ Object
The buyer’s shipping adress (Address).
-
#financial_order_state ⇒ Object
The order’s financial order state (String, one of FinancialOrderState::*).
-
#fulfillment_order_state ⇒ Object
The order’s fulfillment state (String, one of FulfillmentOrderState::*).
-
#google_order_number ⇒ Object
The order’s number at Google Checkout (String).
-
#marketing_preferences ⇒ Object
The buyer’s marketing preferences (MarketingPreferences).
-
#order_adjustment ⇒ Object
The order’s total adjustment (OrderAdjustment).
-
#order_total ⇒ Object
The order’s total amount (Money).
-
#shopping_cart ⇒ Object
The order’s shopping cart (ShoppingCart).
-
#tax_tables ⇒ Object
readonly
The tax tables for the items in the order notification.
Attributes inherited from Notification
#frontend, #serial_number, #timestamp
Class Method Summary collapse
-
.create_from_element(element, frontend) ⇒ Object
Factory method to create a new CheckoutNotification object from the REXML:Element object.
Instance Method Summary collapse
-
#timestamp=(time) ⇒ Object
Set the order’s timestamp (Time).
Methods inherited from Notification
Constructor Details
This class inherits a constructor from Google4R::Checkout::Notification
Instance Attribute Details
#buyer_billing_address ⇒ Object
The buyer’s billing address (Address).
176 177 178 |
# File 'lib/google4r/checkout/notifications.rb', line 176 def buyer_billing_address @buyer_billing_address end |
#buyer_id ⇒ Object
The buyer’s ID from Google Checkout (String).
182 183 184 |
# File 'lib/google4r/checkout/notifications.rb', line 182 def buyer_id @buyer_id end |
#buyer_shipping_address ⇒ Object
The buyer’s shipping adress (Address).
179 180 181 |
# File 'lib/google4r/checkout/notifications.rb', line 179 def buyer_shipping_address @buyer_shipping_address end |
#financial_order_state ⇒ Object
The order’s financial order state (String, one of FinancialOrderState::*).
188 189 190 |
# File 'lib/google4r/checkout/notifications.rb', line 188 def financial_order_state @financial_order_state end |
#fulfillment_order_state ⇒ Object
The order’s fulfillment state (String, one of FulfillmentOrderState::*).
191 192 193 |
# File 'lib/google4r/checkout/notifications.rb', line 191 def fulfillment_order_state @fulfillment_order_state end |
#google_order_number ⇒ Object
The order’s number at Google Checkout (String).
194 195 196 |
# File 'lib/google4r/checkout/notifications.rb', line 194 def google_order_number @google_order_number end |
#marketing_preferences ⇒ Object
The buyer’s marketing preferences (MarketingPreferences).
185 186 187 |
# File 'lib/google4r/checkout/notifications.rb', line 185 def marketing_preferences @marketing_preferences end |
#order_adjustment ⇒ Object
The order’s total adjustment (OrderAdjustment).
197 198 199 |
# File 'lib/google4r/checkout/notifications.rb', line 197 def order_adjustment @order_adjustment end |
#order_total ⇒ Object
The order’s total amount (Money).
200 201 202 |
# File 'lib/google4r/checkout/notifications.rb', line 200 def order_total @order_total end |
#shopping_cart ⇒ Object
The order’s shopping cart (ShoppingCart)
203 204 205 |
# File 'lib/google4r/checkout/notifications.rb', line 203 def shopping_cart @shopping_cart end |
#tax_tables ⇒ Object (readonly)
The tax tables for the items in the order notification.
206 207 208 |
# File 'lib/google4r/checkout/notifications.rb', line 206 def tax_tables @tax_tables end |
Class Method Details
.create_from_element(element, frontend) ⇒ Object
Factory method to create a new CheckoutNotification object from the REXML:Element object
Raises NoMethodError and RuntimeError exceptions if the given element misses required elements.
You have to pass in the Frontend class this notification belongs to.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/google4r/checkout/notifications.rb', line 224 def self.create_from_element(element, frontend) result = NewOrderNotification.new(frontend) result. = Time.parse(element.elements['timestamp'].text) result.serial_number = element.attributes['serial-number'] result.google_order_number = element.elements['google-order-number'].text result.buyer_billing_address = Address.create_from_element(element.elements['buyer-billing-address']) result.buyer_shipping_address = Address.create_from_element(element.elements['buyer-shipping-address']) result.buyer_id = element.elements['buyer-id'].text result.marketing_preferences = MarketingPreferences.create_from_element(element.elements['buyer-marketing-preferences']) result.financial_order_state = element.elements['financial-order-state'].text result.fulfillment_order_state = element.elements['fulfillment-order-state'].text result.order_adjustment = OrderAdjustment.create_from_element(element.elements['order-adjustment']) result.shopping_cart = ShoppingCart.create_from_element(element.elements['shopping-cart'], result) amount = (BigDecimal.new(element.elements['order-total'].text)*100).to_i currency = element.elements['order-total'].attributes['currency'] result.order_total = Money.new(amount, currency) return result end |
Instance Method Details
#timestamp=(time) ⇒ Object
Set the order’s timestamp (Time). When the timestamp is set then the tax tables valid at the given point of time are set into the attribute tax tables from the frontend’s tax_table_factory.
211 212 213 214 215 216 |
# File 'lib/google4r/checkout/notifications.rb', line 211 def (time) @timestamp = time if frontend.tax_table_factory @tax_tables = frontend.tax_table_factory.effective_tax_tables_at(time) end end |