class Payonline::PaymentGateway

Constants

BASE_URL
PAYMENT_TYPE_URL
PERMITTED_PARAMS
SIGNED_PARAMS

Public Class Methods

new(params = {}) click to toggle source
# File lib/payonline/payment_gateway.rb, line 17
def initialize(params = {})
  @params = prepare_params(params)
end

Public Instance Methods

payment_url(type: :card, language: :ru) click to toggle source
# File lib/payonline/payment_gateway.rb, line 21
def payment_url(type: :card, language: :ru)
  params = Payonline::Signature.new(@params, SIGNED_PARAMS).sign

  "#{BASE_URL}/#{language}/payment/#{PAYMENT_TYPE_URL[type]}?#{params.to_query}"
end

Private Instance Methods

default_params() click to toggle source
# File lib/payonline/payment_gateway.rb, line 37
def default_params
  {
    return_url: Payonline.configuration.return_url,
    fail_url: Payonline.configuration.fail_url
  }
end
prepare_params(params) click to toggle source
# File lib/payonline/payment_gateway.rb, line 29
def prepare_params(params)
  params
    .with_indifferent_access
    .slice(*PERMITTED_PARAMS)
    .merge(default_params){ |_, important, _| important }
    .merge(amount: format('%.2f', params[:amount]))
end