class OffsitePayments::Integrations::PoliPay::Helper
Constants
- SUPPORTED_CURRENCIES
Attributes
token_parameters[R]
Public Class Methods
new(order, account, options = {})
click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/poli_pay.rb, line 155 def initialize(order, account, options = {}) @login = account @password = options.fetch(:password) @options = options.except(:password).merge(order: order) check_order!(order) super(order, account, options.except( :homepage_url, :failure_url, :cancellation_url, :password)) add_field 'MerchantDateTime', current_time_utc add_field 'Timeout', options[:timeout] if options[:timeout] # or defaults add_field 'SuccessUrl', options.fetch(:success_url) { options.fetch(:return_url) } add_field 'FailureUrl', options.fetch(:failure_url) { options.fetch(:return_url) } add_field 'CancellationUrl', options.fetch(:cancellation_url) { options.fetch(:return_url) } add_field 'MerchantHomepageURL', options.fetch(:homepage_url) end
Public Instance Methods
amount(money)
click to toggle source
# File lib/offsite_payments/integrations/poli_pay.rb, line 190 def amount(money) add_field mappings[:amount], '%.2f' % money.to_f.round(2) end
check_order!(order)
click to toggle source
# File lib/offsite_payments/integrations/poli_pay.rb, line 170 def check_order!(order) invalid = order.match /[^[[:alnum:]]_.:?\/\-|]/ return unless invalid fail ArgumentError, 'order not valid format, must only include alphanumeric, ' \ 'underscore (_), period (.), colon (:), question mark (?), ' \ 'forward slash (/), hyphen (-) or pipe (|)' end
credential_based_url()
click to toggle source
# File lib/offsite_payments/integrations/poli_pay.rb, line 194 def credential_based_url UrlInterface.new(@login, @password).call(form_fields) end
currency(symbol)
click to toggle source
# File lib/offsite_payments/integrations/poli_pay.rb, line 183 def currency(symbol) unless SUPPORTED_CURRENCIES.include?(symbol) raise ArgumentError, "Unsupported currency" end add_field mappings[:currency], symbol end
current_time_utc()
click to toggle source
# File lib/offsite_payments/integrations/poli_pay.rb, line 179 def current_time_utc Time.current.utc.strftime("%Y-%m-%dT%H:%M:%S") end