Module: Reji::PerformsCharges
- Extended by:
- ActiveSupport::Concern
- Included in:
- Billable
- Defined in:
- lib/reji/concerns/performs_charges.rb
Instance Method Summary collapse
-
#charge(amount, payment_method, options = {}) ⇒ Object
Make a “one off” charge on the customer for the given amount.
-
#refund(payment_intent, options = {}) ⇒ Object
Refund a customer for a charge.
Instance Method Details
#charge(amount, payment_method, options = {}) ⇒ Object
Make a “one off” charge on the customer for the given amount.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/reji/concerns/performs_charges.rb', line 8 def charge(amount, payment_method, = {}) = { :confirmation_method => 'automatic', :confirm => true, :currency => self.preferred_currency, }.merge() [:amount] = amount [:payment_method] = payment_method [:customer] = self.stripe_id if self.has_stripe_id payment = Payment.new( Stripe::PaymentIntent.create(, self.) ) payment.validate payment end |
#refund(payment_intent, options = {}) ⇒ Object
Refund a customer for a charge.
29 30 31 32 33 34 |
# File 'lib/reji/concerns/performs_charges.rb', line 29 def refund(payment_intent, = {}) Stripe::Refund.create( {:payment_intent => payment_intent}.merge(), self. ) end |