ishapi 0.1.8.247 → 0.1.8.249

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: 2aacf8a72aa5ec583348564983e0f4669c77cfe34e5fc2937ec2fd034035da67
4
- data.tar.gz: 86176dafc89e2950c1fcdbcf05b109025cf8daac11419ec456c1d2016d9b1779
3
+ metadata.gz: 7a2fa517bcafd99d966e6766dd6208f5de27e50c933abf3ec2da3ddc818ccad7
4
+ data.tar.gz: 12db5b785227dbd18112ce8d054d935a547071edde7bf827009e0063f6bc3706
5
5
  SHA512:
6
- metadata.gz: 122a756190be6286e6ea4859aba9b2a7122ef9299c3d43b382d2633be8797b4b6fa24a1631acb37f351d872ff8b325f52f34748e052a5bb890e09bca69bfe6d0
7
- data.tar.gz: 559b8e6c0b1bc7c2124aa7e3b57056212db0db13c6631952e4d7abfec41f891aa04301b74606f7a1b2f1668b4b5dacc61a408025053714005bac1e600c1a9825
6
+ metadata.gz: aa23ab17391b6f2fe2cf51c359be661dbe3856c38a847d6d7387ed025402f953f33164d26268c48bdad7de95737399830e615d427e620b873688c52b3a22678d
7
+ data.tar.gz: bafad99ab0371992514d11f1be613a36d79cce650d6f9da2588880b63ec27e784f484c2dad30b029e9f4128825d13e5b38fbc10125488ae2748f9e96125388b4
@@ -61,7 +61,7 @@ class ::Ishapi::ApplicationController < ActionController::Base
61
61
 
62
62
  private
63
63
 
64
- ## This returns an empty profile if not logged in!
64
+ ## This returns an empty profile if not logged in
65
65
  def check_profile
66
66
  begin
67
67
  decoded = decode(params[:jwt_token])
@@ -1,132 +1,100 @@
1
1
  require_dependency "ishapi/application_controller"
2
- module Ishapi
3
- class PaymentsController < ApplicationController
4
-
5
- before_action :check_profile, only: %i| create2 unlock |
6
-
7
- # alphabetized : )
8
-
9
- ##
10
- ## this was for invoices on wasya.co
11
- ## 20200712
12
- ##
13
- def create
14
- authorize! :open_permission, ::Ishapi
15
- begin
16
- invoice = Ish::Invoice.where( :email => params[:email], :number => params[:number] ).first
17
- payment = Ish::Payment.new :invoice => invoice, :email => params[:email], :amount => params[:amount]
18
- amount_cents = ( params[:amount].to_f * 100 ).to_i
19
-
20
- ::Stripe.api_key = STRIPE_SK
21
- acct = Stripe::Account.create(
22
- :country => 'US',
23
- :type => 'custom'
24
- )
25
- charge = ::Stripe::Charge.create(
26
- :amount => amount_cents,
27
- :currency => 'usd',
28
- :source => params[:token][:id],
29
- :destination => {
30
- :account => acct,
31
- }
32
- )
33
-
34
- payment.charge = JSON.parse( charge.to_json )
35
- if payment.save
36
- render :json => { :status => :ok }
37
- else
38
- render :status => 404, :json => {}
39
- end
40
- rescue Mongoid::Errors::DocumentNotFound => e
41
- puts! e, 'e'
42
- render :status => 404, :json => {}
43
- end
2
+ class Ishapi::PaymentsController < ApplicationController
3
+
4
+ before_action :check_profile, only: %i| create unlock |
5
+
6
+ # alphabetized : )
7
+
8
+ ## _vp_ 2020-07-21 This is for guyd
9
+ ## _vp_ 2022-03-01 It's been a while!
10
+ ## _vp_ 2022-09-04 continue
11
+ ##
12
+ ## @TODO: cannot proceed if already is_purchasing?
13
+ ## @TODO: and this doesn't say what you're buying! herehere
14
+ ##
15
+ def create
16
+ authorize! :create, ::Ish::Payment
17
+
18
+ puts! @current_profile, 'current_profile'
19
+
20
+ @current_profile.update_attributes({ is_purchasing: true })
21
+
22
+ begin
23
+ amount_cents = params[:amount_cents].to_i # @TODO: change
24
+
25
+ ::Stripe.api_key = ::STRIPE_SK
26
+ intent = Stripe::PaymentIntent.create({
27
+ amount: amount_cents,
28
+ currency: 'usd',
29
+ metadata: { integration_check: "accept_a_payment" },
30
+ })
31
+
32
+ payment = Ish::Payment.create!(
33
+ client_secret: intent.client_secret,
34
+ email: @current_profile.email,
35
+ payment_intent_id: intent.id,
36
+ profile_id: @current_profile.id,
37
+ )
38
+ render json: {
39
+ client_secret: intent.client_secret,
40
+ clientSecret: intent.client_secret,
41
+ }
42
+
43
+ rescue Mongoid::Errors::DocumentNotFound => e
44
+ puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
45
+ render :status => 404, :json => e
44
46
  end
47
+ end
45
48
 
46
- ## _vp_ 2020-07-21 This is for guyd
47
- ## _vp_ 2022-03-01 It's been a while!
48
- ## _vp_ 2022-09-04 continue
49
- ##
50
- ## @TODO: cannot proceed if already is_purchasing?
51
- ##
52
- def create2
53
- authorize! :create, ::Ish::Payment
54
- @current_profile.update_attributes({ is_purchasing: true })
55
-
56
- begin
57
- amount_cents = params[:amount_cents].to_i # @TODO: change
58
-
59
- ::Stripe.api_key = ::STRIPE_SK
60
- intent = Stripe::PaymentIntent.create({
61
- amount: amount_cents,
62
- currency: 'usd',
63
- metadata: { integration_check: "accept_a_payment" },
64
- })
65
-
66
- payment = Ish::Payment.create!(
67
- client_secret: intent.client_secret,
68
- email: @current_profile.email,
69
- payment_intent_id: intent.id,
70
- profile_id: @current_profile.id,
71
- )
72
-
73
- render json: { client_secret: intent.client_secret }
74
- rescue Mongoid::Errors::DocumentNotFound => e
75
- puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
76
- render :status => 404, :json => e
77
- end
49
+ ##
50
+ ## webhook
51
+ ##
52
+ def stripe_confirm
53
+ authorize! :open_permission, ::Ishapi
54
+ payload = request.body.read
55
+ event = nil
56
+ begin
57
+ event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
58
+ rescue StandardError => err
59
+ puts! err, 'could not #stripe_confirm'
60
+ render status: 400, json: { status: :not_ok }
61
+ return
78
62
  end
79
63
 
80
- ##
81
- ## webhook
82
- ##
83
- def stripe_confirm
84
- authorize! :open_permission, ::Ishapi
85
- payload = request.body.read
86
- event = nil
87
- begin
88
- event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
89
- rescue StandardError => e
90
- puts! e, 'could not #stripe_confirm'
91
- render status: 400, json: { status: :not_ok }
92
- return
93
- end
94
-
95
- payment_intent = event.data.object
96
-
97
- payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
98
- if payment && payment_intent['status'] == 'succeeded'
99
-
100
- payment.update_attributes( status: :confirmed )
101
- n_unlocks = payment.profile.n_unlocks + 1 # @TODO: it's not always 5? adjust
102
-
103
- payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false )
104
- end
105
-
106
- render status: 200, json: { status: :ok }
107
- end
64
+ payment_intent = event.data.object
108
65
 
109
- ##
110
- ## Spend an unlock without spending money. _vp_ 2022-03-01
111
- ##
112
- def unlock
113
- authorize! :unlock, ::Ish::Payment
114
- item = Object::const_get(params['kind']).find params['id']
66
+ payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
67
+ if payment && payment_intent['status'] == 'succeeded'
115
68
 
116
- existing = Purchase.where( user_profile: @current_profile, item: item ).first
117
- if existing
118
- render status: 200, json: { status: :ok, message: 'already purchased' }
119
- return
120
- end
69
+ payment.update_attributes( status: :confirmed )
70
+ n_unlocks = payment.profile.n_unlocks + 1 # @TODO: it's not always 5, adjust! herehere
121
71
 
122
- @current_profile.inc( n_unlocks: -item.premium_tier )
72
+ payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false )
73
+ end
123
74
 
124
- purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_profile, )
75
+ render status: 200, json: { status: :ok }
76
+ end
125
77
 
126
- @profile = @current_profile
127
- render 'ishapi/user_profiles/account'
78
+ ##
79
+ ## Spend an unlock without spending money. _vp_ 2022-03-01
80
+ ##
81
+ def unlock
82
+ authorize! :unlock, ::Ish::Payment
83
+ item = Object::const_get(params['kind']).find params['id']
84
+
85
+ existing = Purchase.where( user_profile: @current_profile, item: item ).first
86
+ if existing
87
+ render status: 200, json: { status: :ok, message: 'already purchased' }
88
+ return
128
89
  end
129
90
 
91
+ @current_profile.inc( n_unlocks: -item.premium_tier )
92
+
93
+ purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_profile, )
94
+
95
+ @profile = @current_profile
96
+ render 'ishapi/user_profiles/account'
130
97
  end
98
+
131
99
  end
132
100
 
@@ -1,17 +1,6 @@
1
1
 
2
- =begin
3
-
4
- m_id_2 = "2021-07-12T19_17_26Fpedidos_jmc2_gmail_com"
5
- stub = Stub.new( object_key: m_id_2 )
6
- stub = Stub.find_by( object_key: m_id_2 )
7
- stub.update_attribute(:state, 'state_pending')
8
- Ishapi::EmailMessageIntakeJob.perform_now( stub.id.to_s )
9
-
10
- =end
11
-
12
-
13
2
  ##
14
- ## 2023-02-26 _vp_ let's go
3
+ ## 2023-02-26 _vp_ Let's go
15
4
  ## 2023-03-02 _vp_ Continue
16
5
  ## 2023-03-07 _vp_ Continue
17
6
  ##
data/config/routes.rb CHANGED
@@ -4,9 +4,6 @@ Ishapi::Engine.routes.draw do
4
4
  root :to => 'application#home'
5
5
  post 'home', :to => 'application#home'
6
6
 
7
- # A
8
- resources :addresses
9
-
10
7
  # E
11
8
  post 'email_messages', to: 'email_messages#receive'
12
9
  get 'email_messages/:id', to: 'email_messages#show', as: :email_message
@@ -47,10 +44,8 @@ Ishapi::Engine.routes.draw do
47
44
 
48
45
  post 'do_purchase', to: 'gameui#do_purchase' # @TODO: rename to just purchase, or destroy endpoint
49
46
  post 'payments', :to => 'payments#create'
50
- post 'payments2', :to => 'payments#create2' # @TODO: change
51
- get 'payments2', to: 'payments#create2'
52
47
  post 'payments/unlock', to: 'payments#unlock' # do_purchase
53
- post 'stripe_confirm', to: 'payments#stripe_confirm' # @TODO: test-drive
48
+ post 'payments/stripe_confirm', to: 'payments#stripe_confirm' # @TODO: test-drive herehere
54
49
 
55
50
  get 'photos/view/:id', to: 'photos#show'
56
51
  get 'profiles/view/:username', :to => 'user_profiles#show'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.247
4
+ version: 0.1.8.249
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-28 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -208,7 +208,6 @@ files:
208
208
  - app/assets/stylesheets/ishapi/galleries.scss
209
209
  - app/assets/stylesheets/ishapi/locations.scss
210
210
  - app/assets/stylesheets/scaffold.css
211
- - app/controllers/ishapi/addresses_controller.rb
212
211
  - app/controllers/ishapi/application_controller.rb
213
212
  - app/controllers/ishapi/email_conversations_controller.rb
214
213
  - app/controllers/ishapi/email_messages_controller.rb
@@ -1,23 +0,0 @@
1
- require_dependency "ishapi/application_controller"
2
-
3
- module Ishapi
4
- class AddressesController < ApplicationController
5
- before_action :check_profile, :only => [ :create ]
6
-
7
- def create
8
- if @current_profile.addresses.length == 0
9
- @address = CoTailors::Address.new({ :profile_id => @current_profile.id })
10
- else
11
- @address = @current_profile.addresses[0]
12
- end
13
- authorize! :update, @address
14
- flag = @address.update_attributes( params[:address].permit(:name, :phone, :address_1, :address_2, :city, :state, :zipcode ) )
15
- if flag
16
- render :json => { :status => :ok, :message => 'Successfully put an address.' }
17
- else
18
- render :json => { :status => :not_ok, :error => @address.errors.messages }
19
- end
20
- end
21
-
22
- end
23
- end