Class: SolidusBolt::Payments::CaptureSyncService
- Inherits:
-
BaseService
- Object
- BaseService
- SolidusBolt::Payments::CaptureSyncService
- Defined in:
- app/services/solidus_bolt/payments/capture_sync_service.rb
Instance Attribute Summary collapse
-
#capture_amount ⇒ Object
readonly
Returns the value of attribute capture_amount.
-
#payment ⇒ Object
readonly
Returns the value of attribute payment.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(payment:, capture_amount:) ⇒ CaptureSyncService
constructor
A new instance of CaptureSyncService.
Methods inherited from BaseService
Constructor Details
#initialize(payment:, capture_amount:) ⇒ CaptureSyncService
Returns a new instance of CaptureSyncService.
8 9 10 11 12 |
# File 'app/services/solidus_bolt/payments/capture_sync_service.rb', line 8 def initialize(payment:, capture_amount:) @payment = payment @capture_amount = capture_amount super end |
Instance Attribute Details
#capture_amount ⇒ Object (readonly)
Returns the value of attribute capture_amount.
6 7 8 |
# File 'app/services/solidus_bolt/payments/capture_sync_service.rb', line 6 def capture_amount @capture_amount end |
#payment ⇒ Object (readonly)
Returns the value of attribute payment.
6 7 8 |
# File 'app/services/solidus_bolt/payments/capture_sync_service.rb', line 6 def payment @payment end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/services/solidus_bolt/payments/capture_sync_service.rb', line 14 def call return if payment.completed? amount = Money.new(capture_amount).to_d payment.capture_events.create!(amount: amount) payment.update!(amount: amount, state: 'completed') end |