Sha256: d19114493212e6240b1e178e9f22ade7ba78a25fa5c4dac3ce1e72e46242cd2f

Contents?: true

Size: 910 Bytes

Versions: 1

Compression:

Stored size: 910 Bytes

Contents

module PinPayment
  class Refund < Base
    attr_reader :token, :amount, :currency, :charge_token, :created_at

    def self.create options
      response = self.post(
        URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{options[:charge_token] || options['charge_token']}/refunds" },
        {}
      )
      self.new.tap do |charge|
        %w(token amount currency created_at error_message status_message).each do |key|
          charge.instance_variable_set("@#{key}", response[key])
        end
      end
    end

    # TODO: API documentation only shows success as being "null" in the JSON
    # response, so not sure this is possible. All my refunds on the test site
    # end up in a "Pending" state so not entirely sure on this one.
    def success?
      @success == true
    end

    def status
      @status_message
    end

    def errors
      @error_message
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pin_payment-0.0.5 lib/pin_payment/refund.rb