Sha256: 9be244b2c3c098669840d792f7cbcfc8e9053e638ef7e5a23748bfd7549facf8

Contents?: true

Size: 1.23 KB

Versions: 5

Compression:

Stored size: 1.23 KB

Contents

module Paypal
  module Payment
    class Response::Info < Base
      cattr_reader :attribute_mapping
      @@attribute_mapping = {
        :ACK => :ack,
        :CURRENCYCODE => :currency_code,
        :ERRORCODE => :error_code,
        :ORDERTIME => :order_time,
        :PAYMENTSTATUS => :payment_status,
        :PAYMENTTYPE => :payment_type,
        :PENDINGREASON => :pending_reason,
        :PROTECTIONELIGIBILITY => :protection_eligibility,
        :PROTECTIONELIGIBILITYTYPE => :protection_eligibility_type,
        :REASONCODE => :reason_code,
        :TRANSACTIONID => :transaction_id,
        :TRANSACTIONTYPE => :transaction_type
      }
      attr_accessor *@@attribute_mapping.values
      attr_accessor :amount

      def initialize(attributes = {})
        attrs = attributes.dup
        @@attribute_mapping.each do |key, value|
          self.send "#{value}=", attrs.delete(key)
        end
        @amount = Common::Amount.new(
          :total => attrs.delete(:AMT),
          :fee => attrs.delete(:FEEAMT),
          :tax => attrs.delete(:TAXAMT)
        )

        # 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

5 entries across 5 versions & 1 rubygems

Version Path
paypal-express-0.0.9 lib/paypal/payment/response/info.rb
paypal-express-0.0.8 lib/paypal/payment/response/info.rb
paypal-express-0.0.7 lib/paypal/payment/response/info.rb
paypal-express-0.0.6 lib/paypal/payment/response/info.rb
paypal-express-0.0.5 lib/paypal/payment/response/info.rb