Class: Paypal::Payment::Response

Inherits:
Base
  • Object
show all
Defined in:
lib/paypal/payment/response.rb

Defined Under Namespace

Classes: Info, Item, Payer, Reference, Refund, ShipTo

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Util

#==, formatted_amount, #numeric_attribute?, to_numeric

Constructor Details

#initialize(attributes = {}) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/paypal/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::ShipTo.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)
  )
  @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|
    Paypal.log "Ignored Parameter (#{self.class}): #{key}=#{value}", :warn
  end
end

Instance Attribute Details

#ackObject

Returns the value of attribute ack.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def ack
  @ack
end

#amountObject

Returns the value of attribute amount.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def amount
  @amount
end

#billing_agreement_idObject

Returns the value of attribute billing_agreement_id.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def billing_agreement_id
  @billing_agreement_id
end

#currency_codeObject

Returns the value of attribute currency_code.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def currency_code
  @currency_code
end

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def description
  @description
end

#error_codeObject

Returns the value of attribute error_code.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def error_code
  @error_code
end

#insurance_option_offeredObject

Returns the value of attribute insurance_option_offered.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def insurance_option_offered
  @insurance_option_offered
end

#itemsObject

Returns the value of attribute items.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def items
  @items
end

#long_messageObject

Returns the value of attribute long_message.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def long_message
  @long_message
end

#noteObject

Returns the value of attribute note.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def note
  @note
end

#notify_urlObject

Returns the value of attribute notify_url.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def notify_url
  @notify_url
end

#request_idObject

Returns the value of attribute request_id.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def request_id
  @request_id
end

#seller_idObject

Returns the value of attribute seller_id.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def seller_id
  @seller_id
end

#severity_codeObject

Returns the value of attribute severity_code.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def severity_code
  @severity_code
end

#ship_toObject

Returns the value of attribute ship_to.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def ship_to
  @ship_to
end

#short_messageObject

Returns the value of attribute short_message.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def short_message
  @short_message
end

#transaction_idObject

Returns the value of attribute transaction_id.



4
5
6
# File 'lib/paypal/payment/response.rb', line 4

def transaction_id
  @transaction_id
end