Class: ActiveWepay::Preapproval

Inherits:
Base
  • Object
show all
Defined in:
lib/activewepay.rb

Constant Summary

Constants inherited from Base

Base::PRODUCTION_API_ENDPOINT, Base::PRODUCTION_UI_ENDPOINT, Base::STAGE_API_ENDPOINT, Base::STAGE_UI_ENDPOINT

Instance Attribute Summary

Attributes inherited from Base

#amount, #callback_uri, #errors, #id, #name, #oauth_token, #redirect_uri, #response

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize

Constructor Details

This class inherits a constructor from ActiveWepay::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveWepay::Base

Class Method Details

.create(options) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/activewepay.rb', line 160

def self.create(options)

  validates_presence_of :account_id, :amount, :redirect_uri, :callback_uri

  recurring = self.new(options)
  recurring.call('/preapproval/create', recurring.oauth_token, {
    short_description: 'Vocalem plan change',
    account_id: recurring.,
    amount: recurring.amount,
    period: 'monthly',
    redirect_uri: recurring.redirect_uri,
    callback_uri: recurring.callback_uri, 
    auto_recur: true,
    mode: 'iframe'
  }) 
end

.find(options) ⇒ Object



177
178
179
180
181
182
183
184
185
# File 'lib/activewepay.rb', line 177

def self.find(options)
  validates_presence_of :id

  recurring = self.new(options)
  
  recurring.call('/preapproval/', recurring.oauth_token, {
      preapproval_id: recurring.id
  })
end

Instance Method Details

#cancelObject



187
188
189
190
191
192
193
# File 'lib/activewepay.rb', line 187

def cancel
  validates_presence_of :id

  call('/preapproval/cancel', @oauth_token, {
    preapproval_id: @id
  })
end