Sha256: f8c3d1a15ce842af5fbd299af95a3e55b6487eca20dd4c3e02ae219a22aa92ff

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

module Paypal
  module Payment
    class Response < Base
      attr_accessor :amount, :ship_to, :insurance_option_offered, :currency_code, :error_code

      def initialize(attributes = {})
        attrs = attributes.dup
        @amount = Amount.new(
          :total => attrs.delete(:AMT),
          :handing => attrs.delete(:HANDLINGAMT),
          :insurance => attrs.delete(:INSURANCEAMT),
          :ship_disc => attrs.delete(:SHIPDISCAMT),
          :shipping => attrs.delete(:SHIPPINGAMT),
          :tax => attrs.delete(:TAXAMT)
        )
        @ship_to = Payment::Response::ShipTo.new(
          :name => attrs.delete(:SHIPTONAME),
          :zip => attrs.delete(:SHIPTOZIP),
          :street => attrs.delete(:SHIPTOSTREET),
          :city => attrs.delete(:SHIPTOCITY),
          :state => attrs.delete(:SHIPTOSTATE),
          :country_code => attrs.delete(:SHIPTOCOUNTRYCODE),
          :country_name => attrs.delete(:SHIPTOCOUNTRYNAME)
        )
        @insurance_option_offered = attrs.delete(:INSURANCEOPTIONOFFERED) == 'true'
        @currency_code = attrs.delete(:CURRENCYCODE)
        @error_code = attrs.delete(:ERRORCODE)

        # warn ignored params
        attrs.each do |key, value|
          Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
paypal-express-0.0.4 lib/paypal/payment/response.rb
paypal-express-0.0.3 lib/paypal/payment/response.rb
paypal-express-0.0.2 lib/paypal/payment/response.rb
paypal-express-0.0.1 lib/paypal/payment/response.rb