Sha256: 9270f962ca2c494cdcb1cc452ba387c7c549d9de8e432400f52f223d4e801e15

Contents?: true

Size: 555 Bytes

Versions: 10

Compression:

Stored size: 555 Bytes

Contents

# frozen_string_literal: true

module SolidusBolt
  module Payments
    class CaptureSyncService < SolidusBolt::BaseService
      attr_reader :payment, :capture_amount

      def initialize(payment:, capture_amount:)
        @payment = payment
        @capture_amount = capture_amount
        super
      end

      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
solidus_bolt-0.7.2 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.7.1 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.7.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.6.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.5.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.4.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.3.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.2.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.1.0 app/services/solidus_bolt/payments/capture_sync_service.rb
solidus_bolt-0.0.1 app/services/solidus_bolt/payments/capture_sync_service.rb