Class: PaysonAPI::Response::PaymentDetails

Inherits:
Object
  • Object
show all
Defined in:
lib/payson_api/response/payment_details.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ PaymentDetails

Returns a new instance of PaymentDetails.



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
# File 'lib/payson_api/response/payment_details.rb', line 11

def initialize(data)
  @envelope = Envelope.parse(data)
  @purchase_id = data['purchaseId']
  @payment_type = data['type']
  @comment = data['custom']
  @tracking_id = data['trackingId']
  @currency = data['currencyCode']
  @sender_email = data['senderEmail']
  @status = data['status']
  @token = data['token']
  @fundings = Funding.parse(data)
  @receivers = Receiver.parse(data)
  @order_items = OrderItem.parse(data)
  @errors = RemoteError.parse(data)

  case @payment_type
  when 'GUARANTEE'
    @guarantee_status = data['guaranteeStatus']
    @guarantee_deadline_at = Time.parse(CGI.unescape(data['guaranteeDeadlineTimestamp']))
  when 'INVOICE'
    @invoice_status = data['invoiceStatus']
    if %w[ORDERCREATED SHIPPED DONE CREDITED].include?(@invoice_status)
      @shipping_address = ShippingAddress.parse(data)
    end
  end
end

Instance Attribute Details

#currencyObject

Returns the value of attribute currency.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def currency
  @currency
end

#customObject

Returns the value of attribute custom.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def custom
  @custom
end

#envelopeObject

Returns the value of attribute envelope.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def envelope
  @envelope
end

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def errors
  @errors
end

#fundingsObject

Returns the value of attribute fundings.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def fundings
  @fundings
end

#guarantee_deadline_atObject

Returns the value of attribute guarantee_deadline_at.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def guarantee_deadline_at
  @guarantee_deadline_at
end

#guarantee_statusObject

Returns the value of attribute guarantee_status.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def guarantee_status
  @guarantee_status
end

#invoice_statusObject

Returns the value of attribute invoice_status.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def invoice_status
  @invoice_status
end

#order_itemsObject

Returns the value of attribute order_items.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def order_items
  @order_items
end

#payment_typeObject

Returns the value of attribute payment_type.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def payment_type
  @payment_type
end

#purchase_idObject

Returns the value of attribute purchase_id.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def purchase_id
  @purchase_id
end

#receiversObject

Returns the value of attribute receivers.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def receivers
  @receivers
end

#sender_emailObject

Returns the value of attribute sender_email.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def sender_email
  @sender_email
end

#shipping_addressObject

Returns the value of attribute shipping_address.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def shipping_address
  @shipping_address
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def status
  @status
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def token
  @token
end

#tracking_idObject

Returns the value of attribute tracking_id.



6
7
8
# File 'lib/payson_api/response/payment_details.rb', line 6

def tracking_id
  @tracking_id
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/payson_api/response/payment_details.rb', line 38

def success?
  @envelope.ack == 'SUCCESS'
end