ishapi 0.1.8.256 → 0.1.8.260
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 +35 -28
- 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: 2f58c5232757d9e074129c27d84e3de4b92801e288e671dcef7a74e2f54e2c3f
|
4
|
+
data.tar.gz: 157f9b1fd63bc62de5f8933f72d0ef8cf8f241027ce99051813a5a9d056c1ded
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 451f50e42eae3975b0d3dc65d8473df70d770d43e8828f4fb08fa32b9622dbc6bea438bcdfeb1d882b6124cbda4caf83c7900a52c15ff9bdb79eee78f6e64276
|
7
|
+
data.tar.gz: bda97e81f1b6b5e1f7126a631da0f3b2e4948bc819b4d186aa868c6a536656aa37fed38cd3971360f9cd2ce91ed8a0c680fffd4abbf6bfb497ff46a4dcf11929
|
@@ -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 )
|
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.260
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|