Class: Pay::Braintree::Charge
- Inherits:
-
Object
- Object
- Pay::Braintree::Charge
- Defined in:
- lib/pay/braintree/charge.rb
Instance Attribute Summary collapse
-
#pay_charge ⇒ Object
readonly
Returns the value of attribute pay_charge.
Instance Method Summary collapse
- #charge ⇒ Object
-
#initialize(pay_charge) ⇒ Charge
constructor
A new instance of Charge.
- #refund!(amount_to_refund) ⇒ Object
Constructor Details
#initialize(pay_charge) ⇒ Charge
Returns a new instance of Charge.
8 9 10 |
# File 'lib/pay/braintree/charge.rb', line 8 def initialize(pay_charge) @pay_charge = pay_charge end |
Instance Attribute Details
#pay_charge ⇒ Object (readonly)
Returns the value of attribute pay_charge.
4 5 6 |
# File 'lib/pay/braintree/charge.rb', line 4 def pay_charge @pay_charge end |
Instance Method Details
#charge ⇒ Object
12 13 14 15 16 |
# File 'lib/pay/braintree/charge.rb', line 12 def charge Pay.braintree_gateway.transaction.find(processor_id) rescue ::Braintree::Braintree::Error => e raise Pay::Braintree::Error, e end |
#refund!(amount_to_refund) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/pay/braintree/charge.rb', line 18 def refund!(amount_to_refund) Pay.braintree_gateway.transaction.refund(processor_id, amount_to_refund / 100.0) pay_charge.update(amount_refunded: amount_to_refund) rescue ::Braintree::BraintreeError => e raise Pay::Braintree::Error, e end |