Module: Pay::Braintree::Charge

Extended by:
ActiveSupport::Concern
Defined in:
lib/pay/braintree/charge.rb

Instance Method Summary collapse

Instance Method Details

#braintree? ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/pay/braintree/charge.rb', line 6

def braintree?
  processor == "braintree"
end

#braintree_charge ⇒ Object



10
11
12
13
14
# File 'lib/pay/braintree/charge.rb', line 10

def braintree_charge
  Pay.braintree_gateway.transaction.find(processor_id)
rescue ::Braintree::BraintreeError => e
  raise Error, e.message
end

#braintree_refund!(amount_to_refund) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/pay/braintree/charge.rb', line 16

def braintree_refund!(amount_to_refund)
  Pay.braintree_gateway.transaction.refund(processor_id, amount_to_refund / 100.0)

  update(amount_refunded: amount_to_refund)
rescue ::Braintree::BraintreeError => e
  raise Error, e.message
end