Sha256: 938625b370220c03e4c0abf616558eb505a3032d3dfa5322e6c6fa5565092db5

Contents?: true

Size: 1.27 KB

Versions: 12

Compression:

Stored size: 1.27 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,
        :RECEIPTID => :receipt_id
      }
      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

12 entries across 12 versions & 1 rubygems

Version Path
paypal-express-0.2.10 lib/paypal/payment/response/info.rb
paypal-express-0.2.9 lib/paypal/payment/response/info.rb
paypal-express-0.2.8 lib/paypal/payment/response/info.rb
paypal-express-0.2.7 lib/paypal/payment/response/info.rb
paypal-express-0.2.6 lib/paypal/payment/response/info.rb
paypal-express-0.2.5 lib/paypal/payment/response/info.rb
paypal-express-0.2.4 lib/paypal/payment/response/info.rb
paypal-express-0.2.3 lib/paypal/payment/response/info.rb
paypal-express-0.2.2 lib/paypal/payment/response/info.rb
paypal-express-0.2.1 lib/paypal/payment/response/info.rb
paypal-express-0.2.0 lib/paypal/payment/response/info.rb
paypal-express-0.1.0 lib/paypal/payment/response/info.rb