paddle_pay 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/lib/paddle_pay.rb +23 -23
- data/lib/paddle_pay/configuration.rb +19 -6
- data/lib/paddle_pay/connection.rb +11 -11
- data/lib/paddle_pay/errors/paddle_pay_error.rb +4 -1
- data/lib/paddle_pay/models/alert/webhook.rb +2 -2
- data/lib/paddle_pay/models/product/coupon.rb +12 -12
- data/lib/paddle_pay/models/product/license.rb +2 -2
- data/lib/paddle_pay/models/product/pay_link.rb +2 -2
- data/lib/paddle_pay/models/product/payment.rb +4 -4
- data/lib/paddle_pay/models/product/product.rb +2 -2
- data/lib/paddle_pay/models/subscription/charge.rb +1 -1
- data/lib/paddle_pay/models/subscription/modifier.rb +6 -6
- data/lib/paddle_pay/models/subscription/payment.rb +7 -7
- data/lib/paddle_pay/models/subscription/plan.rb +4 -4
- data/lib/paddle_pay/models/subscription/user.rb +10 -10
- data/lib/paddle_pay/util.rb +6 -6
- data/lib/paddle_pay/version.rb +1 -1
- data/test/spec/paddle_pay/configuration_spec.rb +35 -7
- data/test/spec/paddle_pay/connection_spec.rb +38 -38
- data/test/spec/paddle_pay/models/alert/webhook_spec.rb +9 -13
- data/test/spec/paddle_pay/models/product/coupon_spec.rb +29 -33
- data/test/spec/paddle_pay/models/product/license_spec.rb +8 -8
- data/test/spec/paddle_pay/models/product/pay_link_spec.rb +8 -8
- data/test/spec/paddle_pay/models/product/payment_spec.rb +7 -7
- data/test/spec/paddle_pay/models/product/product_spec.rb +9 -13
- data/test/spec/paddle_pay/models/subscription/charge_spec.rb +8 -8
- data/test/spec/paddle_pay/models/subscription/modifier_spec.rb +17 -21
- data/test/spec/paddle_pay/models/subscription/payment_spec.rb +17 -21
- data/test/spec/paddle_pay/models/subscription/plan_spec.rb +14 -18
- data/test/spec/paddle_pay/models/subscription/user_spec.rb +20 -24
- data/test/spec/paddle_pay/models/transaction/checkout_spec.rb +10 -14
- data/test/spec/paddle_pay/models/transaction/order_spec.rb +10 -14
- data/test/spec/paddle_pay/models/transaction/product_spec.rb +9 -13
- data/test/spec/paddle_pay/models/transaction/subscription_spec.rb +9 -13
- data/test/spec/paddle_pay/models/transaction/user_spec.rb +9 -13
- data/test/spec/paddle_pay/util_spec.rb +19 -19
- data/test/spec/paddle_pay/version_spec.rb +2 -2
- data/test/test_helper.rb +10 -10
- metadata +35 -7
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Transaction::Checkout do
|
6
6
|
before do
|
7
|
-
PaddlePay.config.vendor_id = ENV[
|
8
|
-
PaddlePay.config.vendor_auth_code = ENV[
|
7
|
+
PaddlePay.config.vendor_id = ENV["PADDLE_VENDOR_ID"]
|
8
|
+
PaddlePay.config.vendor_auth_code = ENV["PADDLE_VENDOR_AUTH_CODE"]
|
9
9
|
@checkout = PaddlePay::Transaction::Checkout
|
10
10
|
path = PaddlePay::Util.convert_class_to_path(@checkout.name) + "/#{name}"
|
11
11
|
VCR.insert_cassette(path)
|
@@ -15,26 +15,22 @@ describe PaddlePay::Transaction::Checkout do
|
|
15
15
|
VCR.eject_cassette
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
list = @checkout.list(
|
18
|
+
describe "when checkouts are requested" do
|
19
|
+
it "should list all checkouts" do
|
20
|
+
list = @checkout.list("57064784-chrec5910826421-58f0e94797")
|
21
21
|
assert_instance_of Array, list
|
22
22
|
refute_nil list.first[:checkout_id] if list.count > 0
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should raise an error if no vendor id is present" do
|
26
26
|
PaddlePay.config.vendor_id = nil
|
27
|
-
exception = assert_raises
|
28
|
-
@checkout.list('57064784-chrec5910826421-58f0e94797')
|
29
|
-
end
|
27
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @checkout.list("57064784-chrec5910826421-58f0e94797") }
|
30
28
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it "should raise an error if no vendor auth code is present" do
|
34
32
|
PaddlePay.config.vendor_auth_code = nil
|
35
|
-
exception = assert_raises
|
36
|
-
@checkout.list('57064784-chrec5910826421-58f0e94797')
|
37
|
-
end
|
33
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @checkout.list("57064784-chrec5910826421-58f0e94797") }
|
38
34
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
39
35
|
end
|
40
36
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Transaction::Order do
|
6
6
|
before do
|
7
|
-
PaddlePay.config.vendor_id = ENV[
|
8
|
-
PaddlePay.config.vendor_auth_code = ENV[
|
7
|
+
PaddlePay.config.vendor_id = ENV["PADDLE_VENDOR_ID"]
|
8
|
+
PaddlePay.config.vendor_auth_code = ENV["PADDLE_VENDOR_AUTH_CODE"]
|
9
9
|
@order = PaddlePay::Transaction::Order
|
10
10
|
path = PaddlePay::Util.convert_class_to_path(@order.name) + "/#{name}"
|
11
11
|
VCR.insert_cassette(path)
|
@@ -15,26 +15,22 @@ describe PaddlePay::Transaction::Order do
|
|
15
15
|
VCR.eject_cassette
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
20
|
-
list = @order.list(
|
18
|
+
describe "when orders are requested" do
|
19
|
+
it "should list all orders" do
|
20
|
+
list = @order.list("14854225-10710435")
|
21
21
|
assert_instance_of Array, list
|
22
22
|
refute_nil list.first[:order_id] if list.count > 0
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should raise an error if no vendor id is present" do
|
26
26
|
PaddlePay.config.vendor_id = nil
|
27
|
-
exception = assert_raises
|
28
|
-
@order.list('14854225-10710435')
|
29
|
-
end
|
27
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @order.list("14854225-10710435") }
|
30
28
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it "should raise an error if no vendor auth code is present" do
|
34
32
|
PaddlePay.config.vendor_auth_code = nil
|
35
|
-
exception = assert_raises
|
36
|
-
@order.list('14854225-10710435')
|
37
|
-
end
|
33
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @order.list("14854225-10710435") }
|
38
34
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
39
35
|
end
|
40
36
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Transaction::Product do
|
6
6
|
before do
|
7
|
-
PaddlePay.config.vendor_id = ENV[
|
8
|
-
PaddlePay.config.vendor_auth_code = ENV[
|
7
|
+
PaddlePay.config.vendor_id = ENV["PADDLE_VENDOR_ID"]
|
8
|
+
PaddlePay.config.vendor_auth_code = ENV["PADDLE_VENDOR_AUTH_CODE"]
|
9
9
|
@product = PaddlePay::Transaction::Product
|
10
10
|
path = PaddlePay::Util.convert_class_to_path(@product.name) + "/#{name}"
|
11
11
|
VCR.insert_cassette(path)
|
@@ -15,26 +15,22 @@ describe PaddlePay::Transaction::Product do
|
|
15
15
|
VCR.eject_cassette
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
18
|
+
describe "when products are requested" do
|
19
|
+
it "should list all products" do
|
20
20
|
list = @product.list(594_469)
|
21
21
|
assert_instance_of Array, list
|
22
22
|
refute_nil list.first[:product_id] if list.count > 0
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should raise an error if no vendor id is present" do
|
26
26
|
PaddlePay.config.vendor_id = nil
|
27
|
-
exception = assert_raises
|
28
|
-
@product.list(594_469)
|
29
|
-
end
|
27
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @product.list(594_469) }
|
30
28
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it "should raise an error if no vendor auth code is present" do
|
34
32
|
PaddlePay.config.vendor_auth_code = nil
|
35
|
-
exception = assert_raises
|
36
|
-
@product.list(594_469)
|
37
|
-
end
|
33
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @product.list(594_469) }
|
38
34
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
39
35
|
end
|
40
36
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Transaction::Subscription do
|
6
6
|
before do
|
7
|
-
PaddlePay.config.vendor_id = ENV[
|
8
|
-
PaddlePay.config.vendor_auth_code = ENV[
|
7
|
+
PaddlePay.config.vendor_id = ENV["PADDLE_VENDOR_ID"]
|
8
|
+
PaddlePay.config.vendor_auth_code = ENV["PADDLE_VENDOR_AUTH_CODE"]
|
9
9
|
@subscription = PaddlePay::Transaction::Subscription
|
10
10
|
path = PaddlePay::Util.convert_class_to_path(@subscription.name) + "/#{name}"
|
11
11
|
VCR.insert_cassette(path)
|
@@ -15,26 +15,22 @@ describe PaddlePay::Transaction::Subscription do
|
|
15
15
|
VCR.eject_cassette
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
18
|
+
describe "when subscriptions are requested" do
|
19
|
+
it "should list all subscriptions" do
|
20
20
|
list = @subscription.list(3_484_448)
|
21
21
|
assert_instance_of Array, list
|
22
22
|
refute_nil list.first[:subscription] if list.count > 0
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should raise an error if no vendor id is present" do
|
26
26
|
PaddlePay.config.vendor_id = nil
|
27
|
-
exception = assert_raises
|
28
|
-
@subscription.list(3_484_448)
|
29
|
-
end
|
27
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @subscription.list(3_484_448) }
|
30
28
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it "should raise an error if no vendor auth code is present" do
|
34
32
|
PaddlePay.config.vendor_auth_code = nil
|
35
|
-
exception = assert_raises
|
36
|
-
@subscription.list(3_484_448)
|
37
|
-
end
|
33
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @subscription.list(3_484_448) }
|
38
34
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
39
35
|
end
|
40
36
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Transaction::User do
|
6
6
|
before do
|
7
|
-
PaddlePay.config.vendor_id = ENV[
|
8
|
-
PaddlePay.config.vendor_auth_code = ENV[
|
7
|
+
PaddlePay.config.vendor_id = ENV["PADDLE_VENDOR_ID"]
|
8
|
+
PaddlePay.config.vendor_auth_code = ENV["PADDLE_VENDOR_AUTH_CODE"]
|
9
9
|
@user = PaddlePay::Transaction::User
|
10
10
|
path = PaddlePay::Util.convert_class_to_path(@user.name) + "/#{name}"
|
11
11
|
VCR.insert_cassette(path)
|
@@ -15,26 +15,22 @@ describe PaddlePay::Transaction::User do
|
|
15
15
|
VCR.eject_cassette
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it
|
18
|
+
describe "when users are requested" do
|
19
|
+
it "should list all users" do
|
20
20
|
list = @user.list(17_368_056)
|
21
21
|
assert_instance_of Array, list
|
22
22
|
refute_nil list.first[:user] if list.count > 0
|
23
23
|
end
|
24
24
|
|
25
|
-
it
|
25
|
+
it "should raise an error if no vendor id is present" do
|
26
26
|
PaddlePay.config.vendor_id = nil
|
27
|
-
exception = assert_raises
|
28
|
-
@user.list(17_368_056)
|
29
|
-
end
|
27
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @user.list(17_368_056) }
|
30
28
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
31
29
|
end
|
32
30
|
|
33
|
-
it
|
31
|
+
it "should raise an error if no vendor auth code is present" do
|
34
32
|
PaddlePay.config.vendor_auth_code = nil
|
35
|
-
exception = assert_raises
|
36
|
-
@user.list(17_368_056)
|
37
|
-
end
|
33
|
+
exception = assert_raises(PaddlePay::PaddlePayError) { @user.list(17_368_056) }
|
38
34
|
assert_equal exception.code, 107 # You don't have permission to access this resource
|
39
35
|
end
|
40
36
|
end
|
@@ -1,41 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "test_helper"
|
4
4
|
|
5
5
|
describe PaddlePay::Util do
|
6
|
-
describe
|
7
|
-
it
|
8
|
-
assert_equal PaddlePay::Util.convert_hash_keys(
|
6
|
+
describe "when convert hash keys" do
|
7
|
+
it "should not convert strings" do
|
8
|
+
assert_equal PaddlePay::Util.convert_hash_keys("string"), "string"
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
assert_equal PaddlePay::Util.convert_hash_keys({
|
11
|
+
it "should convert hash keys to snake case" do
|
12
|
+
assert_equal PaddlePay::Util.convert_hash_keys({"testKey": "test"}), {test_key: "test"}
|
13
13
|
end
|
14
14
|
|
15
|
-
it
|
16
|
-
assert_equal PaddlePay::Util.convert_hash_keys({
|
15
|
+
it "should convert multiple hash keys to snake case" do
|
16
|
+
assert_equal PaddlePay::Util.convert_hash_keys({"testKey": "test", "secondKey": "test"}), {test_key: "test", second_key: "test"}
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
assert_equal PaddlePay::Util.convert_hash_keys([{
|
19
|
+
it "should convert hash keys in arrays to snake case" do
|
20
|
+
assert_equal PaddlePay::Util.convert_hash_keys([{"testKey": "test"}]), [{test_key: "test"}]
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
24
|
-
assert_equal PaddlePay::Util.convert_hash_keys({
|
23
|
+
it "should convert abbreviations to lowercase keys" do
|
24
|
+
assert_equal PaddlePay::Util.convert_hash_keys({"USD": "test"}), {usd: "test"}
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
28
|
-
assert_equal PaddlePay::Util.convert_hash_keys({
|
27
|
+
it "should convert multidimensional hashes" do
|
28
|
+
assert_equal PaddlePay::Util.convert_hash_keys({"testKey": {"multiKey": "test"}}), {test_key: {multi_key: "test"}}
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it
|
34
|
-
assert_equal PaddlePay::Util.convert_class_to_path(
|
32
|
+
describe "when convert simple class names" do
|
33
|
+
it "should convert class names to snake case" do
|
34
|
+
assert_equal PaddlePay::Util.convert_class_to_path("PaddlePay"), "paddle_pay"
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
38
|
-
assert_equal PaddlePay::Util.convert_class_to_path(
|
37
|
+
it "should convert modules to path" do
|
38
|
+
assert_equal PaddlePay::Util.convert_class_to_path("PaddlePay::Util"), "paddle_pay/util"
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
3
|
+
require "dotenv/load"
|
4
|
+
require "minitest/autorun"
|
5
|
+
require "minitest/spec"
|
6
|
+
require "minitest/reporters"
|
7
|
+
require "webmock/minitest"
|
8
|
+
require "vcr"
|
9
|
+
require "paddle_pay"
|
10
10
|
|
11
11
|
Minitest::Reporters.use!
|
12
12
|
|
13
13
|
VCR.configure do |config|
|
14
|
-
config.cassette_library_dir =
|
14
|
+
config.cassette_library_dir = "test/vcr_cassettes"
|
15
15
|
config.hook_into :webmock
|
16
|
-
config.filter_sensitive_data(
|
17
|
-
config.filter_sensitive_data(
|
16
|
+
config.filter_sensitive_data("<VENDOR_ID>") { ENV["PADDLE_VENDOR_ID"] }
|
17
|
+
config.filter_sensitive_data("<VENDOR_AUTH_CODE>") { ENV["PADDLE_VENDOR_AUTH_CODE"] }
|
18
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paddle_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Metzger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,34 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '13.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '13.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: standardrb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: vcr
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +151,7 @@ dependencies:
|
|
123
151
|
- !ruby/object:Gem::Version
|
124
152
|
version: '2.0'
|
125
153
|
description: A Ruby wrapper for the paddle.com API
|
126
|
-
email:
|
154
|
+
email:
|
127
155
|
executables: []
|
128
156
|
extensions: []
|
129
157
|
extra_rdoc_files: []
|
@@ -246,7 +274,7 @@ homepage: https://github.com/devmindo/paddle_pay
|
|
246
274
|
licenses:
|
247
275
|
- MIT
|
248
276
|
metadata: {}
|
249
|
-
post_install_message:
|
277
|
+
post_install_message:
|
250
278
|
rdoc_options: []
|
251
279
|
require_paths:
|
252
280
|
- lib
|
@@ -261,8 +289,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
289
|
- !ruby/object:Gem::Version
|
262
290
|
version: '0'
|
263
291
|
requirements: []
|
264
|
-
rubygems_version: 3.1.
|
265
|
-
signing_key:
|
292
|
+
rubygems_version: 3.1.4
|
293
|
+
signing_key:
|
266
294
|
specification_version: 4
|
267
295
|
summary: A Ruby wrapper for the paddle.com API
|
268
296
|
test_files:
|