lib/pay/stripe/billable.rb
# Handles Billable#charge
#
# Returns Pay::Charge
Handles Billable#charge
Returns Pay::Charge
Handles Billable#charge Returns Pay :: Charge
def create_stripe_charge(amount, options = {})
        customer = stripe_customer
        args = {
          amount: amount,
          confirm: true,
          confirmation_method: :automatic,
          currency: "usd",
          customer: customer.id,
          payment_method: customer.invoice_settings.default_payment_method
        }.merge(options)
        payment_intent = ::Stripe::PaymentIntent.create(args)
        Pay::Payment.new(payment_intent).validate
        Stripe::Webhooks::ChargeSucceeded.new.create_charge(self, payment_intent.charges.first)
      rescue ::Stripe::StripeError => e
        raise Error, e.message
      end
def create_stripe_charge ( amount , options = { } ) customer = stripe_customer args = { amount : amount , confirm : true , confirmation_method : :automatic , currency : "usd" , customer : customer . id , payment_method : customer . invoice_settings . default_payment_method } . merge ( options ) payment_intent = :: Stripe :: PaymentIntent . create ( args ) Pay :: Payment . new ( payment_intent ) . validate Stripe :: Webhooks :: ChargeSucceeded . new . create_charge ( self , payment_intent . charges . first ) rescue :: Stripe :: StripeError => e raise Error , e . message end
Handles Billable#charge
Returns Pay::Charge
Handles Billable#charge Returns Pay :: Charge
# Create a new charge object
amount
options