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
57 58 59 |
# File 'app/models/supercharged/charge/base.rb', line 57 def self.min_amount 1 end |
.with_token(token) ⇒ Object
47 48 49 |
# File 'app/models/supercharged/charge/base.rb', line 47 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
52 53 54 55 |
# File 'app/models/supercharged/charge/base.rb', line 52 def approve(real_amount) self.real_amount = real_amount set_ok! end |
#complete(options = {}) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/models/supercharged/charge/base.rb', line 78 def complete( = {}) get_purchase_details response = process_purchase approve(amount) if response.success? response.success? end |
#gateway ⇒ Object
88 89 90 |
# File 'app/models/supercharged/charge/base.rb', line 88 def gateway Supercharged::Helpers.gateway(gateway_name) end |
#setup_purchase(options) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/models/supercharged/charge/base.rb', line 61 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 |