Class: Supercharged::Charge::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Supercharged::Charge::Base
- Includes:
- ActiveModel::ForbiddenAttributesProtection
- Defined in:
- app/models/supercharged/charge/base.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#approve(real_amount) ⇒ Object
require implicit amount from gateway, not from user.
- #complete(options = {}) ⇒ Object
- #gateway ⇒ Object
- #setup_purchase(options) ⇒ Object
Class Method Details
.min_amount ⇒ Object
53 54 55 |
# File 'app/models/supercharged/charge/base.rb', line 53 def self.min_amount 1 end |
.with_token(token) ⇒ Object
43 44 45 |
# File 'app/models/supercharged/charge/base.rb', line 43 def self.with_token(token) where(gateway_token: token).first end |
Instance Method Details
#approve(real_amount) ⇒ Object
require implicit amount from gateway, not from user
48 49 50 51 |
# File 'app/models/supercharged/charge/base.rb', line 48 def approve(real_amount) self.real_amount = real_amount set_ok! end |
#complete(options = {}) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'app/models/supercharged/charge/base.rb', line 74 def complete( = {}) get_purchase_details response = process_purchase approve(amount) if response.success? response.success? end |
#gateway ⇒ Object
84 85 86 |
# File 'app/models/supercharged/charge/base.rb', line 84 def gateway Supercharged::Helpers.gateway(gateway_name) end |
#setup_purchase(options) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/supercharged/charge/base.rb', line 57 def setup_purchase() response = gateway.setup_purchase(amount_in_cents, ip: [:id], return_url: [:return_url], cancel_return_url: [:cancel_return_url] ) if response.success? update_attributes!( gateway_token: response.token, ip_address: [:id] ) end response.token end |