Sha256: 6e1ebfdb2b91177012e4cc4bb2fe729df5883eff3c0510349ead57186dc03acc

Contents?: true

Size: 693 Bytes

Versions: 5

Compression:

Stored size: 693 Bytes

Contents

module Pay
  module Stripe
    module Charge
      extend ActiveSupport::Concern

      included do
        scope :stripe, -> { where(processor: :stripe) }
      end

      def stripe?
        processor == "stripe"
      end

      def stripe_charge
        ::Stripe::Charge.retrieve(processor_id)
      rescue ::Stripe::StripeError => e
        raise Pay::Stripe::Error, e
      end

      def stripe_refund!(amount_to_refund)
        ::Stripe::Refund.create(
          charge: processor_id,
          amount: amount_to_refund
        )

        update(amount_refunded: amount_to_refund)
      rescue ::Stripe::StripeError => e
        raise Pay::Stripe::Error, e
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pay-2.5.0 lib/pay/stripe/charge.rb
pay-2.4.4 lib/pay/stripe/charge.rb
pay-2.4.3 lib/pay/stripe/charge.rb
pay-2.4.2 lib/pay/stripe/charge.rb
pay-2.4.0 lib/pay/stripe/charge.rb