Module: Supercharged::Charge::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- Charge
- Defined in:
- app/models/supercharged/charge/base.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#approve(real_amount) ⇒ Object
require implicit amount from gateway, not from user.
- #complete(options = {}) ⇒ Object
- #fail ⇒ Object
- #gateway ⇒ Object
- #min_amount ⇒ Object
- #setup_purchase(options) ⇒ Object
Instance Method Details
#approve(real_amount) ⇒ Object
require implicit amount from gateway, not from user
53 54 55 56 |
# File 'app/models/supercharged/charge/base.rb', line 53 def approve(real_amount) self.real_amount = real_amount set_ok! end |
#complete(options = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'app/models/supercharged/charge/base.rb', line 84 def complete( = {}) get_purchase_details response = process_purchase approve(amount) if response.success? response.success? end |
#fail ⇒ Object
58 59 60 61 |
# File 'app/models/supercharged/charge/base.rb', line 58 def fail self.state_event = "set_failed" save(validate: false) end |
#gateway ⇒ Object
94 95 96 |
# File 'app/models/supercharged/charge/base.rb', line 94 def gateway Supercharged::Helpers.gateway(gateway_name) end |
#min_amount ⇒ Object
63 64 65 |
# File 'app/models/supercharged/charge/base.rb', line 63 def min_amount 1 end |
#setup_purchase(options) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/models/supercharged/charge/base.rb', line 67 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 |