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)


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

def braintree?
  processor == "braintree"
end

#braintree_chargeObject



14
15
16
17
18
# File 'lib/pay/braintree/charge.rb', line 14

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

#braintree_refund!(amount_to_refund) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/pay/braintree/charge.rb', line 20

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 Pay::Braintree::Error, e
end