Class: Google4R::Checkout::OrderAdjustment
- Inherits:
-
Object
- Object
- Google4R::Checkout::OrderAdjustment
- Defined in:
- lib/google4r/checkout/notifications.rb
Overview
OrderAdjustment objects contain the adjustments (i.e. the entities in the cart that represent positive and negative amounts (at the moment Google Checkout support coupons, gift certificates and shipping)).
Instance Attribute Summary collapse
-
#adjustment_total ⇒ Object
The
tag contains the total adjustment to an order total based on tax, shipping, gift certificates and coupon codes (optional). -
#merchant_calculation_successful ⇒ Object
Boolean, true iff the merchant calculations have been successful (optional).
-
#merchant_codes ⇒ Object
Array of MerchantCode objects.
-
#shipping ⇒ Object
The chosen ShippingAdjustment object for this order.
-
#total_tax ⇒ Object
The total amount of tax that has been paid for this order (Money, optional).
Class Method Summary collapse
-
.create_from_element(element) ⇒ Object
Creates a new OrderAdjustment from a given REXML::Element object.
Instance Attribute Details
#adjustment_total ⇒ Object
The
629 630 631 |
# File 'lib/google4r/checkout/notifications.rb', line 629 def adjustment_total @adjustment_total end |
#merchant_calculation_successful ⇒ Object
Boolean, true iff the merchant calculations have been successful (optional).
632 633 634 |
# File 'lib/google4r/checkout/notifications.rb', line 632 def merchant_calculation_successful @merchant_calculation_successful end |
#merchant_codes ⇒ Object
Array of MerchantCode objects.
635 636 637 |
# File 'lib/google4r/checkout/notifications.rb', line 635 def merchant_codes @merchant_codes end |
#shipping ⇒ Object
The chosen ShippingAdjustment object for this order.
638 639 640 |
# File 'lib/google4r/checkout/notifications.rb', line 638 def shipping @shipping end |
#total_tax ⇒ Object
The total amount of tax that has been paid for this order (Money, optional).
641 642 643 |
# File 'lib/google4r/checkout/notifications.rb', line 641 def total_tax @total_tax end |
Class Method Details
.create_from_element(element) ⇒ Object
Creates a new OrderAdjustment from a given REXML::Element object.
644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 |
# File 'lib/google4r/checkout/notifications.rb', line 644 def self.create_from_element(element) result = OrderAdjustment.new amount = (element.elements['total-tax'].text.to_f*100).to_i rescue nil currency = element.elements['total-tax'].attributes['currency'] rescue nil result.total_tax = Money.new(amount, currency) unless amount.nil? shipping_element = element.elements["shipping/*"] result.shipping = ShippingAdjustment.create_from_element(shipping_element) unless shipping_element.nil? result.merchant_codes = Array.new element.elements.each(%q{merchant-codes/*}) { |elem| result.merchant_codes << MerchantCode.create_from_element(elem) } result.merchant_calculation_successful = (element.elements['merchant-calculation-successful'].text.downcase == 'true') rescue nil amount = (element.elements['adjustment-total'].text.to_f*100).to_i rescue nil currency = element.elements['adjustment-total'].attributes['currency'] rescue nil result.adjustment_total = Money.new(amount, currency) unless amount.nil? return result end |