Class: Payonline::RebillGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/payonline/rebill_gateway.rb

Constant Summary collapse

SIGNED_PARAMS =
%w(rebill_anchor order_id amount currency)
PERMITTED_PARAMS =
%w(rebill_anchor order_id amount currency)
BASE_URL =
'https://secure.payonlinesystem.com'

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ RebillGateway

Returns a new instance of RebillGateway.



7
8
9
# File 'lib/payonline/rebill_gateway.rb', line 7

def initialize(params = {})
  @params = prepare_params(params)
end

Instance Method Details

#rebillObject

Perform the rebill operation and return the response



12
13
14
15
16
17
# 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_urlObject

Return the URL without performing a request



20
21
22
23
24
# 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