Class: ActivePayment::Models::Sale
- Inherits:
-
Object
- Object
- ActivePayment::Models::Sale
- Defined in:
- lib/active_payment/models/sale.rb
Instance Attribute Summary collapse
-
#payable ⇒ Object
Returns the value of attribute payable.
-
#payee ⇒ Object
Returns the value of attribute payee.
-
#payer ⇒ Object
Returns the value of attribute payer.
Instance Method Summary collapse
- #amount ⇒ Object
- #amount_in_cents ⇒ Object
- #description ⇒ Object
-
#initialize(payable:, payer:, payee:) ⇒ Sale
constructor
A new instance of Sale.
- #paypal_hash ⇒ Object
- #paypal_recipient ⇒ Object
- #shipping ⇒ Object
- #tax ⇒ Object
Constructor Details
#initialize(payable:, payer:, payee:) ⇒ Sale
Returns a new instance of Sale.
6 7 8 9 10 |
# File 'lib/active_payment/models/sale.rb', line 6 def initialize(payable:, payer:, payee:) @payable = payable @payer = payer @payee = payee end |
Instance Attribute Details
#payable ⇒ Object
Returns the value of attribute payable.
4 5 6 |
# File 'lib/active_payment/models/sale.rb', line 4 def payable @payable end |
#payee ⇒ Object
Returns the value of attribute payee.
4 5 6 |
# File 'lib/active_payment/models/sale.rb', line 4 def payee @payee end |
#payer ⇒ Object
Returns the value of attribute payer.
4 5 6 |
# File 'lib/active_payment/models/sale.rb', line 4 def payer @payer end |
Instance Method Details
#amount ⇒ Object
12 13 14 |
# File 'lib/active_payment/models/sale.rb', line 12 def amount payable.amount.to_f / 100 end |
#amount_in_cents ⇒ Object
16 17 18 |
# File 'lib/active_payment/models/sale.rb', line 16 def amount_in_cents payable.amount.to_i end |
#description ⇒ Object
20 21 22 |
# File 'lib/active_payment/models/sale.rb', line 20 def description payable.description end |
#paypal_hash ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/active_payment/models/sale.rb', line 40 def paypal_hash { description: payable.description, invoice_data: { item: [{ name: payable.description, item_count: 1, item_price: amount, price: amount }], total_shipping: payable.shipping, total_tax: payable.tax }, receiver: { email: @payee.paypal_identifier } } end |
#paypal_recipient ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/active_payment/models/sale.rb', line 32 def paypal_recipient { email: payee.paypal_identifier, amount: amount, primary: false } end |
#shipping ⇒ Object
24 25 26 |
# File 'lib/active_payment/models/sale.rb', line 24 def shipping payable.shipping || 0 end |
#tax ⇒ Object
28 29 30 |
# File 'lib/active_payment/models/sale.rb', line 28 def tax payable.tax || 0 end |