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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7be7e944fe040f6d8c8b41e7b8c8ee95e9cd1452ee29f07684fc92b4dc29f31
4
- data.tar.gz: 9d04f5e48774f18bb31cc32d266613c10ca826ed9c4003d71d788d8cf0ab684a
3
+ metadata.gz: 2b2b1dfb4bd9597b2d12c84d53282ee8574c15ef652c4beafbe9238b382c49f3
4
+ data.tar.gz: c845cd0828bc8316ca4884bd8484637dc04bcc42990cad24b9ea63bafa705ea5
5
5
  SHA512:
6
- metadata.gz: d2a0be8652485efcc2625054083ee810acd62f37a01aeaa3375702becf22059cc4ab4181851cdf621cb8189d3b7d26d6f8b12553b4a7e933097510bdcf4f7cb7
7
- data.tar.gz: e02625e042f046018d03e13b78073fcc4cc9a9d7ab50591b602c733daff563851213c137dc72a3b5d4c5a0140e1a29602ae8c15becaa1ed8a470f601a3bad3bf
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
- ## Hmmm, ishapi does not verify authenticity token.
7
- # skip_before_action :verify_authenticity_token, only: %i| create stripe_confirm |
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, ::Ish::Payment
20
+ authorize! :create, Ish::Payment.new
20
21
 
21
22
  @current_profile.update_attributes({ is_purchasing: true })
22
23
 
23
- begin
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
- payment = Ish::Payment.create!(
34
- client_secret: intent.client_secret,
35
- email: @current_profile.email,
36
- payment_intent_id: intent.id,
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: :confirmed )
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ishapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8.256
4
+ version: 0.1.8.259
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox