TagoStripe 0.1.0.8 → 0.1.0.10
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/lib/TagoStripe/CheckoutSession.rb +56 -0
- data/lib/TagoStripe/Customer.rb +15 -1
- data/lib/TagoStripe/Price.rb +14 -1
- data/lib/TagoStripe/Product.rb +7 -2
- data/lib/TagoStripe/Subscription.rb +87 -0
- data/lib/TagoStripe/version.rb +1 -1
- data/lib/TagoStripe.rb +2 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b2ee04c8aae9e4473a8ff4e30a237a7e525ca6268ba4e2b6f5f3176e4dbc80f
|
4
|
+
data.tar.gz: e60c3058b54725e10ec145cc56635d303373bf1def05d2216b288bf17f66abb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 065df6999b703f4fee1ae1ae6d1846d83f3d4861da107b8eddc72fe7c20c34df7f99cea6fca5273eec1b02bea7358d255b2e5ef35814c918ab3046dec17cb860
|
7
|
+
data.tar.gz: 922cbc0e588ee4e059176c7297e24fe4d2504b8a347f44996905d28ef6cfda13fb0722681472ee63a3c88bb5885000e5cb0079cb30aee28cb4cd4187909bfe15
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'stripe'
|
2
|
+
module TagoStripe
|
3
|
+
class CheckoutSession
|
4
|
+
def set_api_key
|
5
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
set_api_key
|
10
|
+
checkout_sessions = Stripe::Checkout::Session.list()
|
11
|
+
return checkout_sessions.data
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.getOne(checkout_session_id)
|
15
|
+
set_api_key
|
16
|
+
checkout_session = Stripe::Checkout::Session.retrieve(checkout_session_id)
|
17
|
+
return checkout_session
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.create(customer_id, success_url, cancel_url, payment_method_types, line_items)
|
21
|
+
set_api_key
|
22
|
+
checkout_session = Stripe::Checkout::Session.create({
|
23
|
+
customer: customer_id,
|
24
|
+
success_url: success_url,
|
25
|
+
cancel_url: cancel_url,
|
26
|
+
payment_method_types: payment_method_types,
|
27
|
+
line_items: line_items
|
28
|
+
})
|
29
|
+
return checkout_session
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.update(checkout_session_id, customer_id, success_url, cancel_url, payment_method_types, line_items)
|
33
|
+
set_api_key
|
34
|
+
checkout_session = Stripe::Checkout::Session.update(checkout_session_id, {
|
35
|
+
customer: customer_id,
|
36
|
+
success_url: success_url,
|
37
|
+
cancel_url: cancel_url,
|
38
|
+
payment_method_types: payment_method_types,
|
39
|
+
line_items: line_items
|
40
|
+
})
|
41
|
+
return checkout_session
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.delete(checkout_session_id)
|
45
|
+
set_api_key
|
46
|
+
checkout_session = Stripe::Checkout::Session.delete(checkout_session_id)
|
47
|
+
return checkout_session
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.listByCustomer(customer_id)
|
51
|
+
set_api_key
|
52
|
+
checkout_sessions = Stripe::Checkout::Session.list({customer: customer_id})
|
53
|
+
return checkout_sessions.data
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/TagoStripe/Customer.rb
CHANGED
@@ -1,21 +1,24 @@
|
|
1
1
|
require 'stripe'
|
2
2
|
module TagoStripe
|
3
3
|
class Customer
|
4
|
-
def
|
4
|
+
def set_api_key
|
5
5
|
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.list
|
9
|
+
set_api_key
|
9
10
|
customers = Stripe::Customer.list()
|
10
11
|
return customers.data
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.getOne(customer_id)
|
15
|
+
set_api_key
|
14
16
|
customer = Stripe::Customer.retrieve(customer_id)
|
15
17
|
return customer
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.create(email, name , metaData={})
|
21
|
+
set_api_key
|
19
22
|
customer = Stripe::Customer.create({
|
20
23
|
email: email,
|
21
24
|
name: name,
|
@@ -25,6 +28,7 @@ module TagoStripe
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def self.update(customer_id, email, name, metaData={})
|
31
|
+
set_api_key
|
28
32
|
customer = Stripe::Customer.update(customer_id, {
|
29
33
|
email: email,
|
30
34
|
name: name,
|
@@ -34,9 +38,19 @@ module TagoStripe
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def self.delete(customer_id)
|
41
|
+
set_api_key
|
37
42
|
customer = Stripe::Customer.delete(customer_id)
|
38
43
|
return customer
|
39
44
|
end
|
40
45
|
|
46
|
+
def self.createCustomerSession(customer_id)
|
47
|
+
set_api_key
|
48
|
+
Stripe::CustomerSession.create({
|
49
|
+
customer: customer_id
|
50
|
+
components: {buy_button: {enabled: true}}
|
51
|
+
})
|
52
|
+
|
53
|
+
end
|
54
|
+
|
41
55
|
end
|
42
56
|
end
|
data/lib/TagoStripe/Price.rb
CHANGED
@@ -1,26 +1,30 @@
|
|
1
1
|
require 'stripe'
|
2
2
|
module TagoStripe
|
3
3
|
class Price
|
4
|
-
def
|
4
|
+
def set_api_key
|
5
5
|
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
6
6
|
end
|
7
7
|
|
8
8
|
def self.list
|
9
|
+
set_api_key
|
9
10
|
prices = Stripe::Price.list()
|
10
11
|
return prices.data
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.activeList
|
15
|
+
set_api_key
|
14
16
|
prices = Stripe::Price.list({active: true})
|
15
17
|
return prices.data
|
16
18
|
end
|
17
19
|
|
18
20
|
def self.getOne(price_id)
|
21
|
+
set_api_key
|
19
22
|
price = Stripe::Price.retrieve(price_id)
|
20
23
|
return price
|
21
24
|
end
|
22
25
|
|
23
26
|
def self.create(product_id, unit_amount, currency, recurring_interval, recurring_interval_count)
|
27
|
+
set_api_key
|
24
28
|
price = Stripe::Price.create({
|
25
29
|
product: product_id,
|
26
30
|
unit_amount: unit_amount,
|
@@ -34,6 +38,7 @@ module TagoStripe
|
|
34
38
|
end
|
35
39
|
|
36
40
|
def self.update(price_id, unit_amount, currency, recurring_interval, recurring_interval_count)
|
41
|
+
set_api_key
|
37
42
|
price = Stripe::Price.update(price_id, {
|
38
43
|
unit_amount: unit_amount,
|
39
44
|
currency: currency,
|
@@ -46,9 +51,17 @@ module TagoStripe
|
|
46
51
|
end
|
47
52
|
|
48
53
|
def self.delete(price_id)
|
54
|
+
set_api_key
|
49
55
|
price = Stripe::Price.delete(price_id)
|
50
56
|
return price
|
51
57
|
end
|
52
58
|
|
59
|
+
def self.listByProduct(product_id)
|
60
|
+
set_api_key
|
61
|
+
prices = Stripe::Price.list({product: product_id})
|
62
|
+
return prices.data
|
63
|
+
end
|
64
|
+
|
65
|
+
|
53
66
|
end
|
54
67
|
end
|
data/lib/TagoStripe/Product.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'stripe'
|
2
2
|
module TagoStripe
|
3
3
|
class Product
|
4
|
-
def
|
4
|
+
def set_api_key
|
5
5
|
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
6
6
|
end
|
7
7
|
|
@@ -11,17 +11,20 @@ module TagoStripe
|
|
11
11
|
return products.data
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.activeList
|
14
|
+
def self.activeList
|
15
|
+
set_api_key
|
15
16
|
products = Stripe::Product.list({active: true})
|
16
17
|
return products.data
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.getOne(product_id)
|
21
|
+
set_api_key
|
20
22
|
product = Stripe::Product.retrieve(product_id)
|
21
23
|
return product
|
22
24
|
end
|
23
25
|
|
24
26
|
def self.create(name, description, unit_label)
|
27
|
+
set_api_key
|
25
28
|
product = Stripe::Product.create({
|
26
29
|
name: name,
|
27
30
|
description: description,
|
@@ -31,6 +34,7 @@ module TagoStripe
|
|
31
34
|
end
|
32
35
|
|
33
36
|
def self.update(product_id, name, description, unit_label)
|
37
|
+
set_api_key
|
34
38
|
product = Stripe::Product.update(product_id, {
|
35
39
|
name: name,
|
36
40
|
description: description,
|
@@ -40,6 +44,7 @@ module TagoStripe
|
|
40
44
|
end
|
41
45
|
|
42
46
|
def self.delete(product_id)
|
47
|
+
set_api_key
|
43
48
|
product = Stripe::Product.delete(product_id)
|
44
49
|
return product
|
45
50
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'stripe'
|
2
|
+
module TagoStripe
|
3
|
+
class Subscription
|
4
|
+
def set_api_key
|
5
|
+
Stripe.api_key = ENV['STRIPE_SECRET_KEY']
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.list
|
9
|
+
set_api_key
|
10
|
+
subscriptions = Stripe::Subscription.list()
|
11
|
+
return subscriptions.data
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.activeList
|
15
|
+
set_api_key
|
16
|
+
subscriptions = Stripe::Subscription.list({status: 'active'})
|
17
|
+
return subscriptions.data
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.getOne(subscription_id)
|
21
|
+
set_api_key
|
22
|
+
subscription = Stripe::Subscription.retrieve(subscription_id)
|
23
|
+
return subscription
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.create(customer_id, price_id)
|
27
|
+
set_api_key
|
28
|
+
subscription = Stripe::Subscription.create({
|
29
|
+
customer: customer_id,
|
30
|
+
items: [{price: price_id}]
|
31
|
+
})
|
32
|
+
return subscription
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.update(subscription_id, price_id)
|
36
|
+
set_api_key
|
37
|
+
subscription = Stripe::Subscription.update(subscription_id, {
|
38
|
+
items: [{price: price_id}]
|
39
|
+
})
|
40
|
+
return subscription
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.cancel(subscription_id)
|
44
|
+
set_api_key
|
45
|
+
subscription = Stripe::Subscription.delete(subscription_id)
|
46
|
+
return subscription
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.listByCustomer(customer_id)
|
50
|
+
set_api_key
|
51
|
+
subscriptions = Stripe::Subscription.list({customer: customer_id})
|
52
|
+
return subscriptions.data
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.listByPrice(price_id)
|
56
|
+
set_api_key
|
57
|
+
subscriptions = Stripe::Subscription.list({price: price_id})
|
58
|
+
return subscriptions.data
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.listByProduct(product_id)
|
62
|
+
set_api_key
|
63
|
+
subscriptions = Stripe::Subscription.list({product: product_id})
|
64
|
+
return subscriptions.data
|
65
|
+
end
|
66
|
+
|
67
|
+
def activeListByCustomer(customer_id)
|
68
|
+
set_api_key
|
69
|
+
subscriptions = Stripe::Subscription.list({customer: customer_id, status: 'active'})
|
70
|
+
return subscriptions.data
|
71
|
+
end
|
72
|
+
|
73
|
+
def activeListByPrice(price_id)
|
74
|
+
set_api_key
|
75
|
+
subscriptions = Stripe::Subscription.list({price: price_id, status: 'active'})
|
76
|
+
return subscriptions.data
|
77
|
+
end
|
78
|
+
|
79
|
+
def activeListByProduct(product_id)
|
80
|
+
set_api_key
|
81
|
+
subscriptions = Stripe::Subscription.list({product: product_id, status: 'active'})
|
82
|
+
return subscriptions.data
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
data/lib/TagoStripe/version.rb
CHANGED
data/lib/TagoStripe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: TagoStripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- manatago
|
@@ -34,10 +34,12 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- Rakefile
|
36
36
|
- lib/TagoStripe.rb
|
37
|
+
- lib/TagoStripe/CheckoutSession.rb
|
37
38
|
- lib/TagoStripe/Common.rb
|
38
39
|
- lib/TagoStripe/Customer.rb
|
39
40
|
- lib/TagoStripe/Price.rb
|
40
41
|
- lib/TagoStripe/Product.rb
|
42
|
+
- lib/TagoStripe/Subscription.rb
|
41
43
|
- lib/TagoStripe/version.rb
|
42
44
|
- sig/TagoStripe.rbs
|
43
45
|
homepage: https://github.com/manatago/TagoStripe
|