Class: Payment::Gateways::Default
- Inherits:
-
BasePaymentGateway
- Object
- BasePaymentGateway
- Payment::Gateways::Default
- Defined in:
- app/services/payment/gateways/default.rb
Overview
Pass-through gateway used as the fallback strategy for payment
categories that don't talk to an external processor (Cash, Store
Credit, etc). Authorize and void simply flip the local state machine;
the remaining actions raise to make accidental misuse loud.
Defined Under Namespace
Classes: Result
Instance Method Summary collapse
-
#authorize ⇒ Payment::Gateways::Default::Result
Mark the Payment authorized without contacting any gateway.
- #capture(params1 = nil, options = {}) ⇒ Object
- #credit(params1 = nil) ⇒ Object
-
#initialize(payment, _delivery = nil) ⇒ Default
constructor
A new instance of Default.
- #purchase(params1 = nil, options = {}) ⇒ Object
- #reauthorize(params1 = nil) ⇒ Object
- #refund(params1 = nil, params2 = nil) ⇒ Object
-
#void(report_fraud = false) ⇒ Payment::Gateways::Default::Result
Void an authorized non-gateway payment via the local state machine.
Constructor Details
#initialize(payment, _delivery = nil) ⇒ Default
Returns a new instance of Default.
11 12 13 14 15 |
# File 'app/services/payment/gateways/default.rb', line 11 def initialize(payment, _delivery = nil) @payment = payment success = nil = nil end |
Instance Method Details
#authorize ⇒ Payment::Gateways::Default::Result
Mark the Payment authorized without contacting any gateway.
20 21 22 23 |
# File 'app/services/payment/gateways/default.rb', line 20 def @payment. Result.new(success: true) end |
#capture(params1 = nil, options = {}) ⇒ Object
42 43 44 |
# File 'app/services/payment/gateways/default.rb', line 42 def capture(params1=nil, = {}) raise StandardError, "Payment 'Capture' action reached but not supported. Payment ID #{@payment.id}" end |
#credit(params1 = nil) ⇒ Object
54 55 56 |
# File 'app/services/payment/gateways/default.rb', line 54 def credit(params1=nil) raise StandardError, "Payment 'Credit' action reached but not supported. Payment ID #{@payment.id}" end |
#purchase(params1 = nil, options = {}) ⇒ Object
46 47 48 |
# File 'app/services/payment/gateways/default.rb', line 46 def purchase(params1=nil, = {}) raise StandardError, "Payment 'Purchase' action reached but not supported. Payment ID #{@payment.id}" end |
#reauthorize(params1 = nil) ⇒ Object
50 51 52 |
# File 'app/services/payment/gateways/default.rb', line 50 def (params1=nil) raise StandardError, "Payment 'Reauthorize' action reached but not supported. Payment ID #{@payment.id}" end |
#refund(params1 = nil, params2 = nil) ⇒ Object
38 39 40 |
# File 'app/services/payment/gateways/default.rb', line 38 def refund(params1=nil, params2=nil) raise StandardError, "Payment 'Refund' action reached but not supported. Payment ID #{@payment.id}" end |
#void(report_fraud = false) ⇒ Payment::Gateways::Default::Result
Void an authorized non-gateway payment via the local state
machine. No-op (returns failure) for non-authorized payments.
31 32 33 34 35 36 |
# File 'app/services/payment/gateways/default.rb', line 31 def void(report_fraud = false) return Result.new(success: false) unless @payment. @payment.payment_voided! Result.new(success: true) end |