rhino_project_subscriptions 0.21.0.beta.20 → 0.21.0.beta.22

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: 19dfe5e5159f5d038e9f7e47ef3b61d1315d377e3a0f3cf772d3e644cba3a5c8
4
- data.tar.gz: 8b0c535f091abd1266dbb707f926807812aa6418bd0831321bf7242eacae5a45
3
+ metadata.gz: c8ad6075c0c68ed176dc2120efa881bb145cc50f603ba7daff61472853aa194b
4
+ data.tar.gz: d2d6dc2d8e7ac10c0d423794ac0bc67f1a821d1730d5fd20ca7d560a3daf6fbc
5
5
  SHA512:
6
- metadata.gz: 96310132712ccbb705cb65e847c3a54b6e88d12ceaaf4b33f70edf33dd68a37beea22d7afa7a0a8ee9170cc2bc6f9586b97101e1af5a29e8dc5ed979def30d72
7
- data.tar.gz: 2107b0268ebb2289c9973ef007bce14043eb8b35bd1848594dfab19c2c6d200151ec7a376a1869eb47c2b0402f91cbda05ac642a3159638843a854d1ac39160f
6
+ metadata.gz: c35b0e8decbce2df00426c73536ef48c236a6549ae5d5b83f78ad2fda23e64568b2d2ea3db910128246a72d2d93e7899a460f9423fe9ed386f554b0212ed6ec2
7
+ data.tar.gz: 2cf044126c94f90e6d09453819b804f85fdf338629c8b7487f3750e90f47836c4e0a50cc3417cb7dff1182fbf74d03f953c4ea6f164ab4b790cd287c5a2d41e2
@@ -25,6 +25,18 @@ module Rhino
25
25
  }
26
26
  end
27
27
 
28
+ def cancel
29
+ stripe_customer = Rhino::StripeCustomer.find_by(base_owner_id: params["base_owner_id"])
30
+ return render json: {} unless stripe_customer
31
+
32
+ subscriptions = ::Stripe::Subscription.list({ customer: stripe_customer["customer_id"] })
33
+ subscriptions.each do |subscription|
34
+ ::Stripe::Subscription.delete(subscription.id)
35
+ end
36
+
37
+ render json: {}
38
+ end
39
+
28
40
  def customer
29
41
  stripe_customer = Rhino::StripeCustomer.find_by(base_owner_id: params["base_owner_id"])
30
42
  if stripe_customer
@@ -63,6 +75,7 @@ module Rhino
63
75
  success_url: args["success_url"],
64
76
  cancel_url: args["cancel_url"],
65
77
  mode: "subscription",
78
+ allow_promotion_codes: true,
66
79
  line_items: [{
67
80
  quantity: 1,
68
81
  price: args["price"]
data/config/routes.rb CHANGED
@@ -6,6 +6,7 @@ Rails.application.routes.draw do
6
6
  post 'subscription/customer' ,to: 'rhino/stripe#customer'
7
7
  get 'subscription/subscriptions' ,to: 'rhino/stripe#subscriptions'
8
8
  post 'subscription/create-checkout-session' ,to: 'rhino/stripe#create_checkout_session'
9
+ post 'subscription/cancel' ,to: 'rhino/stripe#cancel'
9
10
  get 'subscription/check_session_id' ,to: 'rhino/stripe#check_session_id'
10
11
 
11
12
  end
@@ -10,7 +10,7 @@ module RhinoSubscriptions
10
10
  MAJOR = 0
11
11
  MINOR = 21
12
12
  TINY = 0
13
- PRE = "beta.20"
13
+ PRE = "beta.22"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhino_project_subscriptions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.0.beta.20
4
+ version: 0.21.0.beta.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Rosevear
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.21.0.beta.20
39
+ version: 0.21.0.beta.22
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: 0.21.0.beta.20
46
+ version: 0.21.0.beta.22
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: stripe
49
49
  requirement: !ruby/object:Gem::Requirement