class Express::Payment::Response

Attributes

ack[RW]
amount[RW]
bill_to[RW]
billing_agreement_id[RW]
currency_code[RW]
description[RW]
error_code[RW]
insurance_option_offered[RW]
items[RW]
long_message[RW]
note[RW]
notify_url[RW]
request_id[RW]
seller_id[RW]
severity_code[RW]
ship_to[RW]
short_message[RW]
transaction_id[RW]

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/express/payment/response.rb, line 6
def initialize(attributes = {})
  attrs = attributes.dup
  @amount = Common::Amount.new(
    :total => attrs.delete(:AMT),
    :item => attrs.delete(:ITEMAMT),
    :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::Address.new(
    :name => attrs.delete(:SHIPTONAME),
    :zip => attrs.delete(:SHIPTOZIP),
    :street => attrs.delete(:SHIPTOSTREET),
    :street2 => attrs.delete(:SHIPTOSTREET2),
    :city => attrs.delete(:SHIPTOCITY),
    :state => attrs.delete(:SHIPTOSTATE),
    :country_code => attrs.delete(:SHIPTOCOUNTRYCODE),
    :country_name => attrs.delete(:SHIPTOCOUNTRYNAME)
  )
  @bill_to = Payment::Response::Address.new(
    :owner => attrs.delete(:ADDRESSID),
    :status => attrs.delete(:ADDRESSSTATUS),
    :name => attrs.delete(:BILLINGNAME),
    :zip => attrs.delete(:ZIP),
    :street => attrs.delete(:STREET),
    :street2 => attrs.delete(:STREET2),
    :city => attrs.delete(:CITY),
    :state => attrs.delete(:STATE),
    :country_code => attrs.delete(:COUNTRY)
  )
  @description = attrs.delete(:DESC)
  @note = attrs.delete(:NOTETEXT)
  @notify_url = attrs.delete(:NOTIFYURL)
  @insurance_option_offered = attrs.delete(:INSURANCEOPTIONOFFERED) == 'true'
  @currency_code = attrs.delete(:CURRENCYCODE)
  @short_message = attrs.delete(:SHORTMESSAGE)
  @long_message = attrs.delete(:LONGMESSAGE)
  @error_code = attrs.delete(:ERRORCODE)
  @severity_code = attrs.delete(:SEVERITYCODE)
  @ack = attrs.delete(:ACK)
  @transaction_id = attrs.delete(:TRANSACTIONID)
  @billing_agreement_id = attrs.delete(:BILLINGAGREEMENTID)
  @request_id = attrs.delete(:PAYMENTREQUESTID)
  @seller_id = attrs.delete(:SELLERPAYPALACCOUNTID)

  # items
  items = []
  attrs.keys.each do |_attr_|
    key, index = _attr_.to_s.scan(/^(.+?)(\d+)$/).flatten
    if index
      items[index.to_i] ||= {}
      items[index.to_i][key.to_sym] = attrs.delete(:"#{key}#{index}")
    end
  end
  @items = items.collect do |_attr_|
    Item.new(_attr_)
  end

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