Class: PinPayment::Refund

Inherits:
Base
  • Object
show all
Defined in:
lib/pin_payment/refund.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PinPayment::Base

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/pin_payment/refund.rb', line 3

def amount
  @amount
end

#chargeObject

Returns the value of attribute charge.



3
4
5
# File 'lib/pin_payment/refund.rb', line 3

def charge
  @charge
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/pin_payment/refund.rb', line 3

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'lib/pin_payment/refund.rb', line 3

def currency
  @currency
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/pin_payment/refund.rb', line 3

def token
  @token
end

Class Method Details

.create(charge_or_token) ⇒ PinPayment::Refund

Uses the pin API to create a refund.



10
11
12
13
14
# File 'lib/pin_payment/refund.rb', line 10

def self.create charge_or_token
  token = charge_or_token.is_a?(Charge) ? charge_or_token.token : charge_or_token
  response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" })
  new(response.delete('token'), response)
end

Instance Method Details

#statusString



25
26
27
# File 'lib/pin_payment/refund.rb', line 25

def status
  status_message
end

#success?Boolean

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.



20
21
22
# File 'lib/pin_payment/refund.rb', line 20

def success?
  @success == true
end