Class: Micropayment::Session
- Inherits:
-
Base
- Object
- OpenStruct
- Base
- Micropayment::Session
show all
- Defined in:
- lib/micropayment-rails/classes/session.rb
Constant Summary
collapse
- VALID_ATTRIBUTES =
[:sessionId, :customerId, :status, :expire, :statusDetail, :project, :projectCampaign, :account, :webmasterCampaign, :amount, :openAmount, :currency, :title, :payText, :ip, :freeParams]
- IDENTIFIER =
:sessionId
- FIND_METHOD =
:sessionGet
- CREATE_METHOD =
:sessionCreate
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
find, find_or_create_by_id, #id, valid_attributes
Class Method Details
.create!(project, customer, params = {}) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/micropayment-rails/classes/session.rb', line 10
def self.create!(project, customer, params={})
params.symbolize_keys!
params.merge!( :customerId => customer.id, :project => project )
result = Micropayment::Debit.sessionCreate( params )
case result["error"]
when "0"
self.new( valid_attributes(result) )
else
raise "#{result["error"]}: #{result["errorMessage"]}"
end
end
|
Instance Method Details
#approve! ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/micropayment-rails/classes/session.rb', line 22
def approve!
result = Micropayment::Debit.sessionApprove( :sessionId => id )
case result["error"]
when "0"
self.status = result["status"]
self.expire = result["expire"]
status
else
raise "#{result["error"]}: #{result["errorMessage"]}"
end
end
|