ishapi 0.1.8.247 → 0.1.8.248
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 +4 -4
- data/app/controllers/ishapi/payments_controller.rb +81 -117
- data/app/jobs/ishapi/email_message_intake_job.rb +1 -12
- data/config/routes.rb +1 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c22c9af79d588c3398c93d419294e103fb1cf0a2832dc194767e5355875a3540
|
4
|
+
data.tar.gz: e478c4d3932697c2c8fa9f5626b87c4942ab5df270b74db7a1971031008af2b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83d25afaa7f23d1ac7f1902d1112ed3b65f70848bca00e93ea98072fecabe889837472f1b2b97c37f2fa026e1c873409a0ef24ff90d4757f7adb2f8e2971e4b4
|
7
|
+
data.tar.gz: cb3f87379270bfd0ded5f35bdc7e12bdbc146b04361748221631bdb5269e4fd66f350d085d80b4827a188f51408dd0999dfd49aa09e9243b45e1f056360b1bec
|
@@ -1,132 +1,96 @@
|
|
1
1
|
require_dependency "ishapi/application_controller"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
render :status => 404, :json => {}
|
43
|
-
end
|
2
|
+
class Ishapi::PaymentsController < ApplicationController
|
3
|
+
|
4
|
+
before_action :check_profile, only: %i| create2 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
|
+
##
|
14
|
+
def create
|
15
|
+
authorize! :create, ::Ish::Payment
|
16
|
+
@current_profile.update_attributes({ is_purchasing: true })
|
17
|
+
|
18
|
+
begin
|
19
|
+
amount_cents = params[:amount_cents].to_i # @TODO: change
|
20
|
+
|
21
|
+
::Stripe.api_key = ::STRIPE_SK
|
22
|
+
intent = Stripe::PaymentIntent.create({
|
23
|
+
amount: amount_cents,
|
24
|
+
currency: 'usd',
|
25
|
+
metadata: { integration_check: "accept_a_payment" },
|
26
|
+
})
|
27
|
+
|
28
|
+
payment = Ish::Payment.create!(
|
29
|
+
client_secret: intent.client_secret,
|
30
|
+
email: @current_profile.email,
|
31
|
+
payment_intent_id: intent.id,
|
32
|
+
profile_id: @current_profile.id,
|
33
|
+
)
|
34
|
+
render json: {
|
35
|
+
client_secret: intent.client_secret,
|
36
|
+
clientSecret: intent.client_secret,
|
37
|
+
}
|
38
|
+
|
39
|
+
rescue Mongoid::Errors::DocumentNotFound => e
|
40
|
+
puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
|
41
|
+
render :status => 404, :json => e
|
44
42
|
end
|
43
|
+
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
45
|
+
##
|
46
|
+
## webhook
|
47
|
+
##
|
48
|
+
def stripe_confirm
|
49
|
+
authorize! :open_permission, ::Ishapi
|
50
|
+
payload = request.body.read
|
51
|
+
event = nil
|
52
|
+
begin
|
53
|
+
event = Stripe::Event.construct_from(JSON.parse(payload, symbolize_names: true))
|
54
|
+
rescue StandardError => err
|
55
|
+
puts! err, 'could not #stripe_confirm'
|
56
|
+
render status: 400, json: { status: :not_ok }
|
57
|
+
return
|
78
58
|
end
|
79
59
|
|
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
|
60
|
+
payment_intent = event.data.object
|
108
61
|
|
109
|
-
|
110
|
-
|
111
|
-
##
|
112
|
-
def unlock
|
113
|
-
authorize! :unlock, ::Ish::Payment
|
114
|
-
item = Object::const_get(params['kind']).find params['id']
|
62
|
+
payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
|
63
|
+
if payment && payment_intent['status'] == 'succeeded'
|
115
64
|
|
116
|
-
|
117
|
-
|
118
|
-
render status: 200, json: { status: :ok, message: 'already purchased' }
|
119
|
-
return
|
120
|
-
end
|
65
|
+
payment.update_attributes( status: :confirmed )
|
66
|
+
n_unlocks = payment.profile.n_unlocks + 1 # @TODO: it's not always 5, adjust! herehere
|
121
67
|
|
122
|
-
|
68
|
+
payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false )
|
69
|
+
end
|
123
70
|
|
124
|
-
|
71
|
+
render status: 200, json: { status: :ok }
|
72
|
+
end
|
125
73
|
|
126
|
-
|
127
|
-
|
74
|
+
##
|
75
|
+
## Spend an unlock without spending money. _vp_ 2022-03-01
|
76
|
+
##
|
77
|
+
def unlock
|
78
|
+
authorize! :unlock, ::Ish::Payment
|
79
|
+
item = Object::const_get(params['kind']).find params['id']
|
80
|
+
|
81
|
+
existing = Purchase.where( user_profile: @current_profile, item: item ).first
|
82
|
+
if existing
|
83
|
+
render status: 200, json: { status: :ok, message: 'already purchased' }
|
84
|
+
return
|
128
85
|
end
|
129
86
|
|
87
|
+
@current_profile.inc( n_unlocks: -item.premium_tier )
|
88
|
+
|
89
|
+
purchase = ::Gameui::PremiumPurchase.create!( item: item, user_profile: @current_profile, )
|
90
|
+
|
91
|
+
@profile = @current_profile
|
92
|
+
render 'ishapi/user_profiles/account'
|
130
93
|
end
|
94
|
+
|
131
95
|
end
|
132
96
|
|
@@ -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_
|
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
@@ -47,10 +47,8 @@ Ishapi::Engine.routes.draw do
|
|
47
47
|
|
48
48
|
post 'do_purchase', to: 'gameui#do_purchase' # @TODO: rename to just purchase, or destroy endpoint
|
49
49
|
post 'payments', :to => 'payments#create'
|
50
|
-
post 'payments2', :to => 'payments#create2' # @TODO: change
|
51
|
-
get 'payments2', to: 'payments#create2'
|
52
50
|
post 'payments/unlock', to: 'payments#unlock' # do_purchase
|
53
|
-
post
|
51
|
+
post 'payments/stripe_confirm', to: 'payments#stripe_confirm' # @TODO: test-drive herehere
|
54
52
|
|
55
53
|
get 'photos/view/:id', to: 'photos#show'
|
56
54
|
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.
|
4
|
+
version: 0.1.8.248
|
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-
|
11
|
+
date: 2023-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|