Class: Spree::SolidusSixSaferpay::InitializePayment
- Inherits:
-
Object
- Object
- Spree::SolidusSixSaferpay::InitializePayment
- Defined in:
- app/services/spree/solidus_six_saferpay/initialize_payment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#payment_method ⇒ Object
readonly
Returns the value of attribute payment_method.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #gateway ⇒ Object
-
#initialize(order, payment_method) ⇒ InitializePayment
constructor
A new instance of InitializePayment.
- #success? ⇒ Boolean
Constructor Details
#initialize(order, payment_method) ⇒ InitializePayment
Returns a new instance of InitializePayment.
11 12 13 14 15 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 11 def initialize(order, payment_method) @order = order @payment_method = payment_method @success = false end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
5 6 7 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 5 def order @order end |
#payment_method ⇒ Object (readonly)
Returns the value of attribute payment_method.
5 6 7 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 5 def payment_method @payment_method end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
5 6 7 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 5 def redirect_url @redirect_url end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
5 6 7 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 5 def success @success end |
Class Method Details
.call(order, payment_method) ⇒ Object
7 8 9 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 7 def self.call(order, payment_method) new(order, payment_method).call end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 17 def call gateway_response = gateway.initialize_payment(order, payment_method) if gateway_response.success? saferpay_payment = build_saferpay_payment(gateway_response.api_response) @redirect_url = saferpay_payment.redirect_url @success = saferpay_payment.save! end self end |
#gateway ⇒ Object
35 36 37 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 35 def gateway raise NotImplementedError, "Must be implemented in InitializePaymentPage or InitializeTransaction by including UsePaymentPageGateway or UseTransactionGateway" end |
#success? ⇒ Boolean
31 32 33 |
# File 'app/services/spree/solidus_six_saferpay/initialize_payment.rb', line 31 def success? @success end |