ForestAdmin/forest-rails

View on GitHub
app/services/forest_liana/stripe_payment_refunder.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
module ForestLiana
  class StripePaymentRefunder
    def initialize(params)
      @params = params
      Stripe.api_key = ForestLiana.integrations[:stripe][:api_key]
    end

    def perform
      return unless @params[:data][:attributes][:ids]

      @params[:data][:attributes][:ids].each do |id|
        ch = ::Stripe::Charge.retrieve(id)
        ch.refunds.create
      end
    end
  end
end