Class: PinPayment::Refund
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#charge ⇒ Object
readonly
Returns the value of attribute charge.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
-
.create(refund_data) ⇒ PinPayment::Refund
Uses the pin API to create a refund.
-
.find(token) ⇒ PinPayment::Refund
Fetches a refund using the Pin API.
Instance Method Summary collapse
- #status ⇒ String
-
#success? ⇒ Boolean
TODO: API documentation only shows success as being “null” in the JSON response, so not sure this is possible.
Methods inherited from Base
Constructor Details
This class inherits a constructor from PinPayment::Base
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
3 4 5 |
# File 'lib/pin_payment/refund.rb', line 3 def amount @amount end |
#charge ⇒ Object
Returns the value of attribute charge.
3 4 5 |
# File 'lib/pin_payment/refund.rb', line 3 def charge @charge end |
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/pin_payment/refund.rb', line 3 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'lib/pin_payment/refund.rb', line 3 def currency @currency end |
#token ⇒ Object
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(refund_data) ⇒ PinPayment::Refund
Uses the pin API to create a refund.
10 11 12 13 14 15 16 |
# File 'lib/pin_payment/refund.rb', line 10 def self.create refund_data charge_or_token = refund_data.is_a?(Hash) ? refund_data[:charge] : refund_data token = charge_or_token.is_a?(Charge) ? charge_or_token.token : charge_or_token = refund_data.is_a?(Hash) && refund_data[:amount] ? { amount: refund_data[:amount] } : {} response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" }, ) new(response.delete('token'), response) end |
.find(token) ⇒ PinPayment::Refund
Fetches a refund using the Pin API.
22 23 24 25 |
# File 'lib/pin_payment/refund.rb', line 22 def self.find token response = get(URI.parse(PinPayment.api_url).tap{ |uri| uri.path = "/1/refunds/#{token}" }) new(response.delete('token'), response) end |
Instance Method Details
#status ⇒ String
36 37 38 |
# File 'lib/pin_payment/refund.rb', line 36 def status 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.
31 32 33 |
# File 'lib/pin_payment/refund.rb', line 31 def success? @success == true end |