Class: PaysonAPI::V1::Responses::IPN

Inherits:
Object
  • Object
show all
Defined in:
lib/payson_api/v1/responses/ipn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_data) ⇒ IPN

Returns a new instance of IPN.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/payson_api/v1/responses/ipn.rb', line 12

def initialize(raw_data)
  @raw = raw_data
  data_hash = PaysonAPI::V1::Client.params_to_hash(raw_data)
  @purchase_id = data_hash['purchaseId']
  @payment_type = data_hash['type']
  @comment = data_hash['custom']
  @tracking_id = data_hash['trackingId']
  @currency = data_hash['currencyCode']
  @sender_email = data_hash['senderEmail']
  @status = data_hash['status']
  @token = data_hash['token']
  @fundings = PaysonAPI::V1::Funding.parse(data_hash)
  @receivers = PaysonAPI::V1::Receiver.parse(data_hash)
  @order_items = PaysonAPI::V1::OrderItem.parse(data_hash)
  @hash = data_hash['HASH']
  append_payment_type_conditionals
end

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def currency
  @currency
end

#customObject

Returns the value of attribute custom.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def custom
  @custom
end

#fundingsObject

Returns the value of attribute fundings.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def fundings
  @fundings
end

#guarantee_deadline_atObject

Returns the value of attribute guarantee_deadline_at.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def guarantee_deadline_at
  @guarantee_deadline_at
end

#guarantee_statusObject

Returns the value of attribute guarantee_status.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def guarantee_status
  @guarantee_status
end

#hashObject

Returns the value of attribute hash.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def hash
  @hash
end

#invoice_statusObject

Returns the value of attribute invoice_status.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def invoice_status
  @invoice_status
end

#order_itemsObject

Returns the value of attribute order_items.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def order_items
  @order_items
end

#payment_typeObject

Returns the value of attribute payment_type.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def payment_type
  @payment_type
end

#purchase_idObject

Returns the value of attribute purchase_id.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def purchase_id
  @purchase_id
end

#rawObject

Returns the value of attribute raw.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def raw
  @raw
end

#receiversObject

Returns the value of attribute receivers.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def receivers
  @receivers
end

#sender_emailObject

Returns the value of attribute sender_email.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def sender_email
  @sender_email
end

#shipping_addressObject

Returns the value of attribute shipping_address.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def shipping_address
  @shipping_address
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def status
  @status
end

#tokenObject

Returns the value of attribute token.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def token
  @token
end

#tracking_idObject

Returns the value of attribute tracking_id.



7
8
9
# File 'lib/payson_api/v1/responses/ipn.rb', line 7

def tracking_id
  @tracking_id
end

Instance Method Details

#append_payment_type_conditionalsObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/payson_api/v1/responses/ipn.rb', line 30

def append_payment_type_conditionals
  case @payment_type
  when 'GUARANTEE'
    @guarantee_status = data_hash['guaranteeStatus']
    @guarantee_deadline_at = Time.parse(data_hash['guaranteeDeadlineTimestamp'])
  when 'INVOICE'
    @invoice_status = data_hash['invoiceStatus']
    @shipping_address = PaysonAPI::V1::ShippingAddress.parse(data_hash)
  end
end