class PaysonAPI::V1::Requests::Payment
Attributes
cancel_url[RW]
currency[RW]
custom[RW]
fees_payer[RW]
fundings[RW]
guarantee_offered[RW]
invoice_fee[RW]
ipn_url[RW]
locale[RW]
memo[RW]
order_items[RW]
receivers[RW]
return_url[RW]
sender[RW]
tracking_id[RW]
Public Instance Methods
to_hash()
click to toggle source
# File lib/payson_api/v1/requests/payment.rb, line 11 def to_hash # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity {}.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
Private Instance Methods
append_currency(hash, currency)
click to toggle source
# File lib/payson_api/v1/requests/payment.rb, line 42 def append_currency(hash, currency) unless PaysonAPI::V1::CURRENCIES.include?(currency) raise PaysonAPI::V1::Errors::UnknownCurrencyError(currency) end hash['currencyCode'] = currency end
append_fees_payer(hash, fees_payer)
click to toggle source
# File lib/payson_api/v1/requests/payment.rb, line 58 def append_fees_payer(hash, fees_payer) unless PaysonAPI::V1::FEES_PAYERS.include?(fees_payer) raise PaysonAPI::V1::Errors::UnknownFeesPayer(fees_payer) end hash['feesPayer'] = fees_payer end
append_guarantee(hash, guarantee_offered)
click to toggle source
# File lib/payson_api/v1/requests/payment.rb, line 50 def append_guarantee(hash, guarantee_offered) unless PaysonAPI::V1::GUARANTEE_OFFERINGS.include?(guarantee_offered) raise PaysonAPI::V1::Errors::UnknownGuaranteeOffering(guarantee_offered) end hash['guaranteeOffered'] = guarantee_offered end
append_locale(hash, locale)
click to toggle source
# File lib/payson_api/v1/requests/payment.rb, line 36 def append_locale(hash, locale) raise PaysonAPI::V1::Errors::UnknownCurrencyError(locale) unless LOCALES.include?(locale) hash['localeCode'] = locale end