class Payonline::RebillGateway

Constants

BASE_URL
PERMITTED_PARAMS
SIGNED_PARAMS

Public Class Methods

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

Public Instance Methods

rebill() click to toggle source

Perform the rebill operation and return the response

# File lib/payonline/rebill_gateway.rb, line 12
def rebill
  response = HTTParty.get(rebill_url)
  return false unless response.success?

  Payonline::RebillResponse.new(response.body).success?
end
rebill_url() click to toggle source

Return the URL without performing a request

# File lib/payonline/rebill_gateway.rb, line 20
def rebill_url
  params = Payonline::Signature.new(@params, SIGNED_PARAMS).sign

  "#{BASE_URL}/payment/transaction/rebill/?#{params.to_query}"
end

Private Instance Methods

default_params() click to toggle source
# File lib/payonline/rebill_gateway.rb, line 36
def default_params
  {}
end
prepare_params(params) click to toggle source
# File lib/payonline/rebill_gateway.rb, line 28
def prepare_params(params)
  params
    .with_indifferent_access
    .slice(*PERMITTED_PARAMS)
    .merge(default_params)
    .merge(amount: format('%.2f', params[:amount]))
end