Class: Spree::SolidusSixSaferpay::ProcessAuthorizedPayment

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree/solidus_six_saferpay/process_authorized_payment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(saferpay_payment) ⇒ ProcessAuthorizedPayment

Returns a new instance of ProcessAuthorizedPayment.



11
12
13
14
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 11

def initialize(saferpay_payment)
  @saferpay_payment = saferpay_payment
  @order = saferpay_payment.order
end

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



5
6
7
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 5

def order
  @order
end

#saferpay_paymentObject (readonly)

Returns the value of attribute saferpay_payment.



5
6
7
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 5

def saferpay_payment
  @saferpay_payment
end

#successObject (readonly)

Returns the value of attribute success.



5
6
7
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 5

def success
  @success
end

#user_messageObject (readonly)

Returns the value of attribute user_message.



5
6
7
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 5

def user_message
  @user_message
end

Class Method Details

.call(saferpay_payment) ⇒ Object



7
8
9
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 7

def self.call(saferpay_payment)
  new(saferpay_payment).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 16

def call
  check_liability_shift_requirements!

  validate_payment!

  # SUCCESS!

  cancel_old_solidus_payments
  saferpay_payment.create_solidus_payment!
  @success = true

  self

rescue ::SolidusSixSaferpay::InvalidSaferpayPayment => e
  cancel_saferpay_payment
  @user_message = e.full_message
  @success = false

  self
end

#gatewayObject

Raises:

  • (NotImplementedError)


41
42
43
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 41

def gateway
  raise NotImplementedError, "Must be implemented in ProcessPaymentPagePayment or ProcessTransactionPayment"
end

#success?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/services/spree/solidus_six_saferpay/process_authorized_payment.rb', line 37

def success?
  @success
end