Class: PayPal::Charge
- Inherits:
-
Object
- Object
- PayPal::Charge
- Includes:
- Merchant::DoDirectPayment
- Defined in:
- lib/paypal/charge.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#card ⇒ Object
Returns the value of attribute card.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Charge
constructor
A new instance of Charge.
- #success? ⇒ Boolean
Constructor Details
#initialize(params = {}) ⇒ Charge
Returns a new instance of Charge.
15 16 17 18 19 20 21 22 |
# File 'lib/paypal/charge.rb', line 15 def initialize(params = {}) @amount, @card = params[:amount], params[:card] if @amount && @card @response = charge(@amount, @card, params) else raise "You must provide an amount and credit card" end end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
5 6 7 |
# File 'lib/paypal/charge.rb', line 5 def amount @amount end |
#card ⇒ Object
Returns the value of attribute card.
5 6 7 |
# File 'lib/paypal/charge.rb', line 5 def card @card end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/paypal/charge.rb', line 5 def response @response end |
Class Method Details
.create(params = {}) ⇒ Object
9 10 11 |
# File 'lib/paypal/charge.rb', line 9 def create(params = {}) new(params) end |
Instance Method Details
#success? ⇒ Boolean
25 26 27 |
# File 'lib/paypal/charge.rb', line 25 def success? @response && @response.try(:success?) end |