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 <adjustment-total> 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 <adjustment-total> tag contains the total adjustment to an order total based on tax, shipping, gift certificates and coupon codes (optional).
703 704 705 |
# File 'lib/google4r/checkout/notifications.rb', line 703 def adjustment_total @adjustment_total end |
#merchant_calculation_successful ⇒ Object
Boolean, true iff the merchant calculations have been successful (optional).
706 707 708 |
# File 'lib/google4r/checkout/notifications.rb', line 706 def merchant_calculation_successful @merchant_calculation_successful end |
#merchant_codes ⇒ Object
Array of MerchantCode objects.
709 710 711 |
# File 'lib/google4r/checkout/notifications.rb', line 709 def merchant_codes @merchant_codes end |
#shipping ⇒ Object
The chosen ShippingAdjustment object for this order.
712 713 714 |
# File 'lib/google4r/checkout/notifications.rb', line 712 def shipping @shipping end |
#total_tax ⇒ Object
The total amount of tax that has been paid for this order (Money, optional).
715 716 717 |
# File 'lib/google4r/checkout/notifications.rb', line 715 def total_tax @total_tax end |
Class Method Details
.create_from_element(element) ⇒ Object
Creates a new OrderAdjustment from a given REXML::Element object.
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 |
# File 'lib/google4r/checkout/notifications.rb', line 718 def self.create_from_element(element) result = OrderAdjustment.new amount = (BigDecimal.new(element.elements['total-tax'].text)*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 = (BigDecimal.new(element.elements['adjustment-total'].text)*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 |