Sha256: 8acdfdc01bed2bd10a6e4aba499a196bc472713b9c998625863f18cbd7031466
Contents?: true
Size: 1.11 KB
Versions: 10
Compression:
Stored size: 1.11 KB
Contents
class IshManager::PricesController < IshManager::ApplicationController def create @price = Wco::Price.new params[:price].permit( :amount_cents, :interval, :product_id ) puts! @price, '@price' authorize! :create, @price if !params[:price][:interval].present? @price.interval = nil end @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
10 entries across 10 versions & 1 rubygems