Class: Pin::Charge

Inherits:
Base
  • Object
show all
Defined in:
lib/pin-payments/charge.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, all_pages, find, first, #initialize, last

Constructor Details

This class inherits a constructor from Pin::Base

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def amount
  @amount
end

#amount_refundedObject

Returns the value of attribute amount_refunded.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def amount_refunded
  @amount_refunded
end

#cardObject

Returns the value of attribute card.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def card
  @card
end

#card_tokenObject

Returns the value of attribute card_token.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def card_token
  @card_token
end

#created_atObject

Returns the value of attribute created_at.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def currency
  @currency
end

#customer_tokenObject

Returns the value of attribute customer_token.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def customer_token
  @customer_token
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def description
  @description
end

#emailObject

Returns the value of attribute email.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def email
  @email
end

#error_messageObject

Returns the value of attribute error_message.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def error_message
  @error_message
end

#ip_addressObject

Returns the value of attribute ip_address.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def ip_address
  @ip_address
end

#merchant_entitlementObject

Returns the value of attribute merchant_entitlement.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def merchant_entitlement
  @merchant_entitlement
end

#refund_pendingObject

Returns the value of attribute refund_pending.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def refund_pending
  @refund_pending
end

#refundsObject

find all refunds for the current Charge object returns a list of Refunds



28
29
30
# File 'lib/pin-payments/charge.rb', line 28

def refunds
  @refunds
end

#status_messageObject

Returns the value of attribute status_message.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def status_message
  @status_message
end

#successObject

Returns the value of attribute success.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def success
  @success
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def token
  @token
end

#total_feesObject

Returns the value of attribute total_fees.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def total_fees
  @total_fees
end

#transferObject

Returns the value of attribute transfer.



3
4
5
# File 'lib/pin-payments/charge.rb', line 3

def transfer
  @transfer
end

Class Method Details

.create(options = {}) ⇒ Object

options should be a hash with the following params email, description, amount, currency, ip_address are mandatory identifier must be a hash, can take the forms

{card: <Pin::Card>}
{card_token: String<"...">}
{customer_token: String<"...">}
{customer: <Pin::Customer>}

eg. ‘[email protected]’, description: ‘One month subscription’, amount: 19900, currency: ‘USD’, ip_address: ‘192.0.0.1’, customer_token: ‘asdf’



20
21
22
23
# File 'lib/pin-payments/charge.rb', line 20

def create(options = {})
  options[:customer_token] = options.delete(:customer).token unless options[:customer].nil?
  super(options)
end

Instance Method Details

#refund!(amnt = nil) ⇒ Object

creates a refund for this Charge refunds the full amount of the charge by default, provide an amount in cents to override



34
35
36
# File 'lib/pin-payments/charge.rb', line 34

def refund!(amnt = nil)
  Refund.create(token, amnt)
end