Class: Spree::SolidusSixSaferpay::InquirePayment
- Inherits:
-
Object
- Object
- Spree::SolidusSixSaferpay::InquirePayment
- Defined in:
- app/services/spree/solidus_six_saferpay/inquire_payment.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#saferpay_payment ⇒ Object
readonly
Returns the value of attribute saferpay_payment.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#user_message ⇒ Object
readonly
Returns the value of attribute user_message.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
NOTE: This will be successful regardless of the API response.
- #gateway ⇒ Object
-
#initialize(saferpay_payment) ⇒ InquirePayment
constructor
A new instance of InquirePayment.
- #success? ⇒ Boolean
Constructor Details
#initialize(saferpay_payment) ⇒ InquirePayment
Returns a new instance of InquirePayment.
10 11 12 13 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 10 def initialize(saferpay_payment) @saferpay_payment = saferpay_payment @order = saferpay_payment.order end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
4 5 6 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 4 def order @order end |
#saferpay_payment ⇒ Object (readonly)
Returns the value of attribute saferpay_payment.
4 5 6 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 4 def saferpay_payment @saferpay_payment end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
4 5 6 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 4 def success @success end |
#user_message ⇒ Object (readonly)
Returns the value of attribute user_message.
4 5 6 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 4 def @user_message end |
Class Method Details
.call(saferpay_payment) ⇒ Object
6 7 8 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 6 def self.call(saferpay_payment) new(saferpay_payment).call end |
Instance Method Details
#call ⇒ Object
NOTE: This will be successful regardless of the API response. The reason is that the API returns HTTP error codes for failed payments, but the inquiry was still successful
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 18 def call inquiry = gateway.inquire(saferpay_payment) if inquiry.success? saferpay_payment.update_attributes(saferpay_payment_attributes(inquiry.api_response)) else saferpay_payment.update_attributes(response_hash: saferpay_payment.response_hash.merge(error: "#{inquiry.error_name}")) general_error = I18n.t(:general_error, scope: [:solidus_six_saferpay, :errors]) specific_error = I18n.t(inquiry.error_name, scope: [:six_saferpay, :error_names]) @user_message = "#{general_error}: #{specific_error}" end @success = true self end |
#gateway ⇒ Object
39 40 41 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 39 def gateway raise NotImplementedError, "Must be implemented in AssertPaymentPage or AuthorizeTransaction with UsePaymentPageGateway or UseTransactionGateway" end |
#success? ⇒ Boolean
35 36 37 |
# File 'app/services/spree/solidus_six_saferpay/inquire_payment.rb', line 35 def success? @success end |