Class: ActiveWepay::Checkout

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



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/activewepay.rb', line 110

def self.create(options)
  checkout = self.new(options)
  checkout.call('/checkout/create', checkout.oauth_token, {
    account_id: checkout.,
    amount: checkout.amount,
    short_description: 'Payment',
    type: 'DONATION',
    mode: 'iframe',
    app_fee: checkout.amount * 0.021,
    redirect_uri: checkout.redirect_uri,
    callback_uri: checkout.callback_uri 
  })
end

.find(options) ⇒ Object



124
125
126
127
# File 'lib/activewepay.rb', line 124

def self.find(options)
  checkout = self.new(options)
  checkout.information
end

Instance Method Details

#cancelObject



137
138
139
140
141
142
143
144
# File 'lib/activewepay.rb', line 137

def cancel
  validates_presence_of :id
 
  self.call('/checkout/cancel/', @oauth_token, {
    checkout_id: @id,
    cancel_reason: 'Refund'
  })
end

#informationObject



129
130
131
132
133
134
135
# File 'lib/activewepay.rb', line 129

def information
  validates_presence_of :id

  call('/checkout/', @oauth_token, {
    checkout_id: @id
  })
end

#refundObject



146
147
148
149
150
151
152
153
# File 'lib/activewepay.rb', line 146

def refund
  validates_presence_of :id

  call('/checkout/refund', @oauth_token, {
    checkout_id: @id,
    refund_reason: 'Refunded'
  })
end