Class: SolidusBolt::Payments::CreditSyncService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/solidus_bolt/payments/credit_sync_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

call

Constructor Details

#initialize(payment:, amount:, transaction_id:) ⇒ CreditSyncService

Returns a new instance of CreditSyncService.



8
9
10
11
12
13
14
15
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 8

def initialize(payment:, amount:, transaction_id:)
  @payment = payment
  @amount = amount
  @transaction_id = transaction_id
  @refund_reason = Spree::RefundReason.return_processing_reason&.id
  @order = payment.order
  super
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



6
7
8
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 6

def amount
  @amount
end

#orderObject (readonly)

Returns the value of attribute order.



6
7
8
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 6

def order
  @order
end

#paymentObject (readonly)

Returns the value of attribute payment.



6
7
8
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 6

def payment
  @payment
end

#refund_reasonObject (readonly)

Returns the value of attribute refund_reason.



6
7
8
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 6

def refund_reason
  @refund_reason
end

#transaction_idObject (readonly)

Returns the value of attribute transaction_id.



6
7
8
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 6

def transaction_id
  @transaction_id
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'app/services/solidus_bolt/payments/credit_sync_service.rb', line 17

def call
  return if Spree::Refund.find_by(transaction_id: transaction_id)

  create_refund
  order.recalculate
end