Class: Google4R::Checkout::NewOrderNotification
- Inherits:
-
Notification
- Object
- Notification
- Google4R::Checkout::NewOrderNotification
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
Google Checkout sends
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).
169 170 171 |
# File 'lib/google4r/checkout/notifications.rb', line 169 def buyer_billing_address @buyer_billing_address end |
#buyer_id ⇒ Object
The buyer's ID from Google Checkout (String).
175 176 177 |
# File 'lib/google4r/checkout/notifications.rb', line 175 def buyer_id @buyer_id end |
#buyer_shipping_address ⇒ Object
The buyer's shipping adress (Address).
172 173 174 |
# File 'lib/google4r/checkout/notifications.rb', line 172 def buyer_shipping_address @buyer_shipping_address end |
#financial_order_state ⇒ Object
The order's financial order state (String, one of FinancialOrderState::*).
181 182 183 |
# File 'lib/google4r/checkout/notifications.rb', line 181 def financial_order_state @financial_order_state end |
#fulfillment_order_state ⇒ Object
The order's fulfillment state (String, one of FulfillmentOrderState::*).
184 185 186 |
# File 'lib/google4r/checkout/notifications.rb', line 184 def fulfillment_order_state @fulfillment_order_state end |
#google_order_number ⇒ Object
The order's number at Google Checkout (String).
187 188 189 |
# File 'lib/google4r/checkout/notifications.rb', line 187 def google_order_number @google_order_number end |
#marketing_preferences ⇒ Object
The buyer's marketing preferences (MarketingPreferences).
178 179 180 |
# File 'lib/google4r/checkout/notifications.rb', line 178 def marketing_preferences @marketing_preferences end |
#order_adjustment ⇒ Object
The order's total adjustment (OrderAdjustment).
190 191 192 |
# File 'lib/google4r/checkout/notifications.rb', line 190 def order_adjustment @order_adjustment end |
#order_total ⇒ Object
The order's total amount (Money).
193 194 195 |
# File 'lib/google4r/checkout/notifications.rb', line 193 def order_total @order_total end |
#shopping_cart ⇒ Object
The order's shopping cart (ShoppingCart)
196 197 198 |
# File 'lib/google4r/checkout/notifications.rb', line 196 def shopping_cart @shopping_cart end |
#tax_tables ⇒ Object (readonly)
The tax tables for the items in the order notification.
199 200 201 |
# File 'lib/google4r/checkout/notifications.rb', line 199 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.
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/google4r/checkout/notifications.rb', line 215 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 = (element.elements['order-total'].text.to_f*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.
204 205 206 207 |
# File 'lib/google4r/checkout/notifications.rb', line 204 def (time) = time @tax_tables = frontend.tax_table_factory.effective_tax_tables_at(time) end |