Sha256: 26ece4482762384a7731e754e528f60ee2b3829ad838cda4f603c74b815139b7
Contents?: true
Size: 1.06 KB
Versions: 73
Compression:
Stored size: 1.06 KB
Contents
class Wco::PricesController < Wco::ApplicationController def create @price = Wco::Price.new params[:price].permit( :amount_cents, :interval, :product_id ) authorize! :create, @price @price.interval = nil if !params[:price][:interval].present? @product = Wco::Product.find @price.product_id stripe_product = Stripe::Product.retrieve( @product.product_id ) price_hash = { product: stripe_product.id, unit_amount: @price.amount_cents, currency: 'usd', } if @price.interval.present? price_hash[:recurring] = { interval: @price.interval } end stripe_price = Stripe::Price.create( price_hash ) # puts! stripe_price, 'stripe_price' flash_notice 'Created stripe price.' @price.product = @product @price.price_id = stripe_price[:id] if @price.save flash_notice @price else flash_alert @price end redirect_to controller: :products, action: :index end def update # if !params[:price][:interval].present? # @price.interval = nil # end end end
Version data entries
73 entries across 73 versions & 1 rubygems