ish_manager 0.1.8.457 → 0.1.8.458

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0182df5197f378f6b0dac039e2df3c86058a3a3e9203257378d17118efe177e
4
- data.tar.gz: 499fe16c69807cc1cfb273017131bb60450d4d326e1640a93e3fe5db0c2d1783
3
+ metadata.gz: 42443ac595bb611c6e4dcd495212dea118197ce3d5cd736c4ffc13ff7672915f
4
+ data.tar.gz: 20b76203f7e205e0421a856bd832e5ae98e061552c59aeb33b76ba994663c736
5
5
  SHA512:
6
- metadata.gz: d766d3ce17a9366d99204fafcb7afdafcc9d2f2a0583896c635be3bace6eaf100b16e41071bb56a714a62ef1d02c1225999ee1848682e761db3d8f302e30ae31
7
- data.tar.gz: c6c07fee9694012636d01308dddc8ad78f7464abb4a633a7a37c604baa7adfb0b0a05430d2f27ab7e7129ec4dd4ffe5c11fb0ea259fe68da824f54f2fbd4c23d
6
+ metadata.gz: 91a07f1df419c2fce93601e0b35f48233f414ffc2a7f18d78019afa9d875a1417e5db42ba24d96be2aea66cc05a9ce472b25b0ba98cbe9d9ca3b6d6f34960bdb
7
+ data.tar.gz: 1cf8ed0befe718c28f386243798a4465e90a44abda909794a41842b32abf13d7c2383abee35fa47f5960b62406edef4bc382942da9bdeb3601d95064cf3878a4
@@ -3,47 +3,69 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
3
3
 
4
4
  before_action :set_lists
5
5
 
6
- # alphabetized : )
6
+ ## Alphabetized : )
7
7
 
8
8
  def create
9
- authorize! :create, Wco::Subscription
10
9
  @subscription = Wco::Subscription.new params[:subscription].permit!
11
- @stripe_subscription = Stripe::Subscription.create({
10
+ authorize! :create, @subscription
11
+
12
+ payment_methods = Stripe::Customer.list_payment_methods( params[:subscription][:customer_id] ).data
13
+ # puts! payment_methods, 'payment_methods'
14
+
15
+ params = {
12
16
  customer: params[:subscription][:customer_id],
17
+ default_payment_method: payment_methods[0][:id],
13
18
  items: [
14
19
  { price: params[:subscription][:price_id] },
15
20
  ],
16
- })
17
- puts! @stripe_subscription, '@stripe_subscription'
18
-
19
- # flag = @subscription.save
20
- # if flag
21
- # flash[:notice] = 'Created the subscription.'
22
- # redirect_to action: :show, id: @subscription.id
23
- # else
24
- # flash[:alert] = "Cannot create the subscription: #{@subscription.errors.full_messages.join(', ')}."
25
- # render action: :new
26
- # end
21
+ }
22
+ puts! params, 'params'
23
+ @stripe_subscription = Stripe::Subscription.create( params )
24
+ # puts! @stripe_subscription, '@stripe_subscription'
25
+
26
+
27
+ flag = @subscription.save
28
+ if flag
29
+ flash[:notice] = 'Created the subscription.'
30
+ redirect_to action: :show, id: @subscription.id
31
+ else
32
+ flash[:alert] = "Cannot create the subscription: #{@subscription.errors.full_messages.join(', ')}."
33
+ render action: :new
34
+ end
27
35
  end
28
36
 
29
37
  def index
30
38
  authorize! :index, Wco::Subscription
31
39
 
32
- @stripe_customers = Stripe::Customer.list().data
40
+ @stripe_customers = Stripe::Customer.list().data
33
41
  @stripe_subscriptions = Stripe::Subscription.list().data
34
42
 
35
- emails = @stripe_customers.map &:email
36
- @leadsets = Leadset.find_by( email: emails )
37
- end
43
+ @customers = {}
44
+ customer_ids = @stripe_customers.map &:id
45
+ @leadsets = Leadset.where( :customer_id.in => customer_ids )
46
+ @leadsets.each do |i|
47
+ @customers[i[:customer_id]] ||= {}
48
+ @customers[i[:customer_id]][:leadsets] ||= []
49
+ @customers[i[:customer_id]][:leadsets].push( i )
50
+ end
51
+ @profiles = Ish::UserProfile.where( :customer_id.in => customer_ids )
52
+ @profiles.each do |i|
53
+ @customers[i[:customer_id]] ||= {}
54
+ @customers[i[:customer_id]][:profiles] ||= []
55
+ @customers[i[:customer_id]][:profiles].push( i )
56
+ end
38
57
 
39
- def show
40
- authorize! :show, Wco::Subscription
41
- @subscription = Wco::Subscription.find params[:id]
58
+ # puts! @customers, '@customers'
42
59
  end
43
60
 
44
61
  def new
45
- authorize! :new, Wco::Subscription
46
62
  @subscription = Wco::Subscription.new
63
+ authorize! :new, @subscription
64
+ end
65
+
66
+ def show
67
+ @subscription = Wco::Subscription.find params[:id]
68
+ authorize! :show, @subscription
47
69
  end
48
70
 
49
71
  ##
@@ -53,9 +75,11 @@ class IshManager::SubscriptionsController < IshManager::ApplicationController
53
75
 
54
76
  def set_lists
55
77
  super
56
- @products_list = Wco::Product.list
57
- @customer_ids_list = Leadset.where( "customer_id IS NOT NULL" ).map { |i| [ i.company_url, i.customer_id ] }
58
- @price_ids_list = Wco::Product.all.map { |i| [ i.name, i.price_id ] }
78
+ @products_list = Wco::Product.list
79
+ leadsets = Leadset.where( "customer_id IS NOT NULL" ).map { |i| [ "leadset // #{i.company_url}", i.customer_id ] }
80
+ profiles = ::Ish::UserProfile.where( :customer_id.ne => nil ).map { |i| [ "profile ++ #{i.email}", i.customer_id ] }
81
+ @customer_ids_list = leadsets + profiles
82
+ @price_ids_list = Wco::Product.all.map { |i| [ i.name, i.price_id ] }
59
83
  end
60
84
 
61
85
  end
@@ -57,6 +57,13 @@ class IshManager::UserProfilesController < IshManager::ApplicationController
57
57
  @profile.profile_photo = photo
58
58
  end
59
59
 
60
+ puts! params[:profile][:customer_id].present?, 'params[:profile][:customer_id].present?'
61
+ if !params[:profile][:customer_id].present? || params[:delete_customer_id]
62
+ params[:profile][:customer_id] = nil
63
+ end
64
+
65
+ puts! params[:profile], 'ze params'
66
+
60
67
  flag = @profile.update_attributes params[:profile].permit!
61
68
 
62
69
  if flag
@@ -29,5 +29,5 @@
29
29
  - @products.each do |product|
30
30
  %li
31
31
  = link_to '[~]', edit_product_path( product )
32
- = product.inspect
33
-
32
+ #{product.name} // $#{product.price_cents.to_f/100}/#{product.interval.presence || 'onetime'}
33
+ [ #{product.product_id}, #{product.price_id} ]
@@ -28,5 +28,9 @@
28
28
  %li plan: $#{sub[:plan][:amount].to_f/100}/#{sub[:plan][:interval]}
29
29
  %li product: #{sub[:plan][:product]}
30
30
  %li customer: #{sub[:customer]}
31
- -# %li= sub.inspect
31
+ -# %li= @customers.inspect
32
+ - if @customers[sub[:customer]] && @customers[sub[:customer]][:leadsets]
33
+ %li leadsets: #{ @customers[sub[:customer]][:leadsets]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
34
+ - if @customers[sub[:customer]] && @customers[sub[:customer]][:profiles]
35
+ %li profiles: #{ @customers[sub[:customer]][:profiles]&.map { |i| "#{i[:id]} - #{i[:email]}" } }
32
36
 
@@ -30,10 +30,19 @@
30
30
  .input-field
31
31
  = f.label :fb_access_token
32
32
  = f.text_field :fb_access_token
33
+
33
34
  .input-field
34
35
  = f.label :fb_long_access_token
35
36
  = f.text_field :fb_long_access_token
36
37
 
38
+ .input-field
39
+ = f.label :customer_id
40
+ = f.text_field :customer_id
41
+ %label [X]
42
+ = check_box_tag :delete_customer_id
43
+
44
+
45
+
37
46
  = f.submit 'Save', :class => %w(button)
38
47
 
39
48
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.457
4
+ version: 0.1.8.458
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox