Sha256: df899c90fe27acf872a1e516d9b36b8b8986a22184b623c122fa6512bbcdbb20

Contents?: true

Size: 568 Bytes

Versions: 1

Compression:

Stored size: 568 Bytes

Contents

class StripeRefund < Refund

  def do_refund(params = {})
    return unless can_refund?

    refund = Stripe::Refund.create(charge: payment.payment_uuid, amount: (self.total_amount * 100).to_i)

    order.payment_status = 'refunded'

    self.operator_id = params[:operator_id]
    self.refund_uuid = refund.id

    if refund.status == 'succeeded'
      self.state = 'completed'
      self.refunded_at = Time.now
      self.class.transaction do
        order.save!
        self.save!
      end
    else
      self.update reason: 'failed'
    end
    refund
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_trade-0.0.1 app/models/rails_trade/refunds/stripe_refund.rb