Class: Tipjoy::Payment
- Inherits:
-
Object
- Object
- Tipjoy::Payment
- Includes:
- Requestor
- Defined in:
- lib/tipjoy/payment.rb
Constant Summary collapse
- NOTIFY_PATH =
"/api/tweetpayment/notify/"
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#client ⇒ Object
Returns the value of attribute client.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#message ⇒ Object
Returns the value of attribute message.
-
#to_account ⇒ Object
Returns the value of attribute to_account.
-
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
-
#tweet_id ⇒ Object
Returns the value of attribute tweet_id.
Instance Method Summary collapse
-
#initialize(client, to_account, amount, message = "") ⇒ Payment
constructor
A new instance of Payment.
- #pay ⇒ Object
- #valid? ⇒ Boolean
Methods included from Requestor
Constructor Details
#initialize(client, to_account, amount, message = "") ⇒ Payment
Returns a new instance of Payment.
9 10 11 |
# File 'lib/tipjoy/payment.rb', line 9 def initialize(client, to_account, amount, ="") self.to_account, self.amount, self.client, self. = to_account, amount, client, end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def amount @amount end |
#client ⇒ Object
Returns the value of attribute client.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def client @client end |
#errors ⇒ Object
Returns the value of attribute errors.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def errors @errors end |
#message ⇒ Object
Returns the value of attribute message.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def @message end |
#to_account ⇒ Object
Returns the value of attribute to_account.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def to_account @to_account end |
#transaction_id ⇒ Object
Returns the value of attribute transaction_id.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def transaction_id @transaction_id end |
#tweet_id ⇒ Object
Returns the value of attribute tweet_id.
7 8 9 |
# File 'lib/tipjoy/payment.rb', line 7 def tweet_id @tweet_id end |
Instance Method Details
#pay ⇒ Object
13 14 15 16 17 18 |
# File 'lib/tipjoy/payment.rb', line 13 def pay raise Tipjoy::InvalidPaymentError.new(errors.join(", ")) unless valid? tweet_payment notify_tipjoy end |
#valid? ⇒ Boolean
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tipjoy/payment.rb', line 20 def valid? self.errors = [] self.errors << "amount required" unless amount self.errors << "to_account required" unless to_account self.errors << "no client" unless client self.errors << "amount not > 0 " unless amount.to_f > 0 self.errors.empty? end |