Class: PaysonAPI::Request::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/payson_api/request/payment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(return_url, cancel_url, ipn_url, memo, sender, receivers, custom = nil) ⇒ Payment

Returns a new instance of Payment.



8
9
10
11
12
13
14
15
16
# File 'lib/payson_api/request/payment.rb', line 8

def initialize(return_url, cancel_url, ipn_url, memo, sender, receivers, custom = nil)
  @return_url = return_url
  @cancel_url = cancel_url
  @ipn_url = ipn_url
  @memo = memo
  @sender = sender
  @receivers = receivers
  @custom = custom
end

Instance Attribute Details

#cancel_urlObject

Returns the value of attribute cancel_url.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def cancel_url
  @cancel_url
end

#currencyObject

Returns the value of attribute currency.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def currency
  @currency
end

#customObject

Returns the value of attribute custom.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def custom
  @custom
end

#fees_payerObject

Returns the value of attribute fees_payer.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def fees_payer
  @fees_payer
end

#fundingsObject

Returns the value of attribute fundings.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def fundings
  @fundings
end

#guarantee_offeredObject

Returns the value of attribute guarantee_offered.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def guarantee_offered
  @guarantee_offered
end

#invoice_feeObject

Returns the value of attribute invoice_fee.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def invoice_fee
  @invoice_fee
end

#ipn_urlObject

Returns the value of attribute ipn_url.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def ipn_url
  @ipn_url
end

#localeObject

Returns the value of attribute locale.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def locale
  @locale
end

#memoObject

Returns the value of attribute memo.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def memo
  @memo
end

#order_itemsObject

Returns the value of attribute order_items.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def order_items
  @order_items
end

#receiversObject

Returns the value of attribute receivers.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def receivers
  @receivers
end

#return_urlObject

Returns the value of attribute return_url.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def return_url
  @return_url
end

#senderObject

Returns the value of attribute sender.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def sender
  @sender
end

#tracking_idObject

Returns the value of attribute tracking_id.



4
5
6
# File 'lib/payson_api/request/payment.rb', line 4

def tracking_id
  @tracking_id
end

Instance Method Details

#to_hashObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/payson_api/request/payment.rb', line 18

def to_hash
  {}.tap do |hash|
    # Append mandatory params
    hash['returnUrl'] = @return_url
    hash['cancelUrl'] = @cancel_url
    hash['memo'] = @memo
    hash.merge!(@sender.to_hash)
    hash.merge!(Receiver.to_hash(@receivers))

    # Append optional params
    append_locale(hash, @locale) if @locale
    append_currency(hash, @currency) if @currency
    append_fees_payer(hash, @fees_payer) if @fees_payer
    append_guarantee(hash, @guarantee_offered) if @guarantee_offered
    hash.merge!(OrderItem.to_hash(@order_items)) if @order_items
    hash.merge!(Funding.to_hash(@fundings)) if @fundings
    hash['ipnNotificationUrl'] = @ipn_url if @ipn_url
    hash['invoiceFee'] = @invoice_fee if @invoice_fee
    hash['trackingId'] = @tracking_id if @tracking_id
    hash['custom'] = @custom if @custom
  end
end