Class: PinPayment::Charge
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#customer ⇒ Object
readonly
Returns the value of attribute customer.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#ip_address ⇒ Object
readonly
Returns the value of attribute ip_address.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#total_fees ⇒ Object
readonly
Returns the value of attribute total_fees.
Class Method Summary collapse
-
.all ⇒ Array<PinPayment::Charge>
Fetches all of your charges using the pin API.
-
.create(charge_data) ⇒ PinPayment::Charge
Uses the pin API to create a charge.
-
.find(token) ⇒ PinPayment::Charge
Fetches a charge using the Pin API.
Instance Method Summary collapse
-
#refund! ⇒ PinPayment::Refund
Refund a charge via the pin API.
-
#refunds ⇒ Array<PinPayment::Refund>
Fetches all refunds of your charge using the pin API.
- #success? ⇒ Boolean
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/charge.rb', line 3 def amount @amount end |
#card ⇒ Object
Returns the value of attribute card.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def card @card end |
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def customer @customer end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def description @description end |
#email ⇒ Object
Returns the value of attribute email.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def email @email end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def ip_address @ip_address end |
#success ⇒ Object
Returns the value of attribute success.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def success @success end |
#token ⇒ Object
Returns the value of attribute token.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def token @token end |
#total_fees ⇒ Object
Returns the value of attribute total_fees.
3 4 5 |
# File 'lib/pin_payment/charge.rb', line 3 def total_fees @total_fees end |
Class Method Details
.all ⇒ Array<PinPayment::Charge>
Fetches all of your charges using the pin API.
TODO: pagination
38 39 40 41 |
# File 'lib/pin_payment/charge.rb', line 38 def self.all response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/charges' }) response.map{|x| new(x.delete('token'), x) } end |
.create(charge_data) ⇒ PinPayment::Charge
Uses the pin API to create a charge.
17 18 19 20 21 22 |
# File 'lib/pin_payment/charge.rb', line 17 def self.create charge_data attributes = self.attributes - [:token, :success, :created_at] # fix attributes allowed by POST API = (attributes, charge_data) response = post(URI.parse(PinPayment.api_url).tap{|uri| uri.path = '/1/charges' }, ) new(response.delete('token'), response) end |
.find(token) ⇒ PinPayment::Charge
Fetches a charge using the Pin API.
28 29 30 31 |
# File 'lib/pin_payment/charge.rb', line 28 def self.find token response = get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}" }) new(response.delete('token'), response) end |
Instance Method Details
#refund! ⇒ PinPayment::Refund
Refund a charge via the pin API.
46 47 48 |
# File 'lib/pin_payment/charge.rb', line 46 def refund! Refund.create self end |
#refunds ⇒ Array<PinPayment::Refund>
Fetches all refunds of your charge using the pin API.
TODO: pagination
54 55 56 57 |
# File 'lib/pin_payment/charge.rb', line 54 def refunds response = Charge.get(URI.parse(PinPayment.api_url).tap{|uri| uri.path = "/1/charges/#{token}/refunds" }) response.map{|x| Refund.new(x.delete('token'), x) } end |
#success? ⇒ Boolean
60 61 62 |
# File 'lib/pin_payment/charge.rb', line 60 def success? success == true end |