class Pay::Braintree::Charge

Attributes

pay_charge[R]

Public Class Methods

new(pay_charge) click to toggle source
# File lib/pay/braintree/charge.rb, line 8
def initialize(pay_charge)
  @pay_charge = pay_charge
end

Public Instance Methods

charge() click to toggle source
# 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) click to toggle source
# 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