Class: Spree::SolidusSixSaferpay::AuthorizePayment

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

Direct Known Subclasses

AssertPaymentPage, AuthorizeTransaction

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(saferpay_payment) ⇒ AuthorizePayment

Returns a new instance of AuthorizePayment.



10
11
12
13
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 10

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

Instance Attribute Details

#orderObject (readonly)

Returns the value of attribute order.



4
5
6
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 4

def order
  @order
end

#saferpay_paymentObject (readonly)

Returns the value of attribute saferpay_payment.



4
5
6
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 4

def saferpay_payment
  @saferpay_payment
end

#successObject (readonly)

Returns the value of attribute success.



4
5
6
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 4

def success
  @success
end

Class Method Details

.call(saferpay_payment) ⇒ Object



6
7
8
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 6

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

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 15

def call
  authorization = gateway.authorize(order.total, saferpay_payment)

  if authorization.success?
    saferpay_payment.update_attributes!(saferpay_payment_attributes(authorization.api_response))
    @success = true
  end
  self
end

#gatewayObject

Raises:

  • (NotImplementedError)


30
31
32
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 30

def gateway
  raise NotImplementedError, "Must be implemented in AssertPaymentPage or AuthorizeTransaction with UsePaymentPageGateway or UseTransactionGateway"
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'app/services/spree/solidus_six_saferpay/authorize_payment.rb', line 25

def success?
  @success
end