Module: Spree::Payment::Processing
- Included in:
- Spree::Payment
- Defined in:
- app/models/spree/payment/processing.rb
Instance Method Summary collapse
- #authorize! ⇒ Object
- #capture! ⇒ Object
- #process! ⇒ Object
- #purchase! ⇒ Object
- #void_transaction! ⇒ Object
Instance Method Details
#authorize! ⇒ Object
20 21 22 23 |
# File 'app/models/spree/payment/processing.rb', line 20 def started_processing! gateway_action(source, :authorize, :pend) end |
#capture! ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/spree/payment/processing.rb', line 30 def capture! protect_from_connection_error do check_environment if payment_method.payment_profiles_supported? # Gateways supporting payment profiles will need access to creditcard object because this stores the payment profile information # so supply the authorization itself as well as the creditcard, rather than just the authorization code response = payment_method.capture(self, source, ) else # Standard ActiveMerchant capture usage response = payment_method.capture((amount * 100).round, response_code, ) end handle_response(response, :complete, :failure) end end |
#process! ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/models/spree/payment/processing.rb', line 4 def process! if payment_method && payment_method.source_required? if source if !processing? if Spree::Config[:auto_capture] purchase! else end end else raise Core::GatewayError.new(I18n.t(:payment_processing_failed)) end end end |
#purchase! ⇒ Object
25 26 27 28 |
# File 'app/models/spree/payment/processing.rb', line 25 def purchase! started_processing! gateway_action(source, :purchase, :complete) end |
#void_transaction! ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/models/spree/payment/processing.rb', line 49 def void_transaction! protect_from_connection_error do check_environment if payment_method.payment_profiles_supported? # Gateways supporting payment profiles will need access to creditcard object because this stores the payment profile information # so supply the authorization itself as well as the creditcard, rather than just the authorization code response = payment_method.void(self.response_code, source, ) else # Standard ActiveMerchant void usage response = payment_method.void(self.response_code, ) end record_response(response) if response.success? self.response_code = response. self.void else gateway_error(response) end end end |