ishapi 0.1.8.256 → 0.1.8.259
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/ishapi/payments_controller.rb +35 -28
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b2b1dfb4bd9597b2d12c84d53282ee8574c15ef652c4beafbe9238b382c49f3
|
4
|
+
data.tar.gz: c845cd0828bc8316ca4884bd8484637dc04bcc42990cad24b9ea63bafa705ea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b5fffc9ea10304e43316a34ef25190e08e7ade5958b2fc2218a41924d93e0fc8ec4c237b7ea4eaf8a892c7dd2fc5a3c2fe8bbcd648c9484424c7e802578828f
|
7
|
+
data.tar.gz: 8b4a8eae4b0af269d71b0e0552e7061b2cf0f97e263b94f813ad7e5b766e488df49483a3c8a7b28223245f0998b007404c9138e9d5166a4a254d4ce663be4b40
|
@@ -3,52 +3,58 @@ class Ishapi::PaymentsController < ::Ishapi::ApplicationController
|
|
3
3
|
|
4
4
|
before_action :check_profile, only: %i| create unlock |
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
protect_from_forgery with: :exception
|
7
|
+
skip_before_action :verify_authenticity_token, only: %i| stripe_confirm |
|
8
8
|
|
9
9
|
# alphabetized : )
|
10
10
|
|
11
11
|
## _vp_ 2020-07-21 This is for guyd
|
12
12
|
## _vp_ 2022-03-01 It's been a while!
|
13
13
|
## _vp_ 2022-09-04 continue
|
14
|
+
## _vp_ 2023-03-29 Continue
|
14
15
|
##
|
15
16
|
## @TODO: cannot proceed if already is_purchasing?
|
16
17
|
## @TODO: and this doesn't say what you're buying! herehere
|
17
18
|
##
|
18
19
|
def create
|
19
|
-
authorize! :create,
|
20
|
+
authorize! :create, Ish::Payment.new
|
20
21
|
|
21
22
|
@current_profile.update_attributes({ is_purchasing: true })
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
profile_id: @current_profile.id,
|
38
|
-
)
|
39
|
-
render json: {
|
40
|
-
client_secret: intent.client_secret,
|
41
|
-
clientSecret: intent.client_secret,
|
42
|
-
}
|
43
|
-
|
44
|
-
rescue Mongoid::Errors::DocumentNotFound => e
|
45
|
-
puts! e, '#create2 Mongoid::Errors::DocumentNotFound'
|
46
|
-
render :status => 404, :json => e
|
24
|
+
amount_cents = params[:amount_cents].to_i # @TODO: change
|
25
|
+
|
26
|
+
::Stripe.api_key = ::STRIPE_SK
|
27
|
+
intent = Stripe::PaymentIntent.create({
|
28
|
+
amount: amount_cents,
|
29
|
+
currency: 'usd',
|
30
|
+
metadata: { integration_check: "accept_a_payment" },
|
31
|
+
})
|
32
|
+
|
33
|
+
item_type = case params[:item_type]
|
34
|
+
when 'Ish::Location'
|
35
|
+
'Gameui::Map'
|
36
|
+
else
|
37
|
+
throw "item_type not implemented: #{params[:item_type]}"
|
47
38
|
end
|
39
|
+
item = item_type.constantize.find params[:item_id]
|
40
|
+
|
41
|
+
payment = Ish::Payment.create!(
|
42
|
+
client_secret: intent.client_secret,
|
43
|
+
email: @current_profile.email,
|
44
|
+
item: item,
|
45
|
+
payment_intent_id: intent.id,
|
46
|
+
profile_id: @current_profile.id,
|
47
|
+
)
|
48
|
+
render json: {
|
49
|
+
client_secret: intent.client_secret,
|
50
|
+
clientSecret: intent.client_secret,
|
51
|
+
}
|
52
|
+
|
48
53
|
end
|
49
54
|
|
50
55
|
##
|
51
56
|
## webhook
|
57
|
+
## _vp_ 2023-03-29 Continue
|
52
58
|
##
|
53
59
|
def stripe_confirm
|
54
60
|
authorize! :open_permission, ::Ishapi
|
@@ -63,11 +69,12 @@ class Ishapi::PaymentsController < ::Ishapi::ApplicationController
|
|
63
69
|
end
|
64
70
|
|
65
71
|
payment_intent = event.data.object
|
72
|
+
puts! payment_intent, 'payment_intent'
|
66
73
|
|
67
74
|
payment = Ish::Payment.where( payment_intent_id: payment_intent.id ).first
|
68
75
|
if payment && payment_intent['status'] == 'succeeded'
|
69
76
|
|
70
|
-
payment.update_attributes( status:
|
77
|
+
payment.update_attributes( status: Ish::Payment::STATUS_CONFIRMED )
|
71
78
|
n_unlocks = payment.profile.n_unlocks + 1 # @TODO: it's not always 5, adjust! herehere
|
72
79
|
|
73
80
|
payment.profile.update_attributes!( n_unlocks: n_unlocks, is_purchasing: false )
|