checkout_sdk 0.1.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -20
- data/LICENSE +21 -0
- data/README.md +122 -35
- data/checkout_sdk.gemspec +4 -3
- data/documentation/.gitignore +20 -0
- data/documentation/docs/environment.md +26 -0
- data/documentation/docs/getting_started.md +48 -0
- data/documentation/docs/initialize.md +19 -0
- data/documentation/docs/install.md +21 -0
- data/documentation/docs/payments.md +200 -0
- data/documentation/docs/sources.md +53 -0
- data/documentation/docs/tokens.md +88 -0
- data/documentation/docusaurus.config.js +60 -0
- data/documentation/package-lock.json +13511 -0
- data/documentation/package.json +32 -0
- data/documentation/sidebars.js +10 -0
- data/documentation/src/css/custom.css +103 -0
- data/documentation/src/pages/index.js +10 -0
- data/documentation/src/pages/styles.module.css +37 -0
- data/documentation/static/img/favicon.png +0 -0
- data/documentation/static/img/logo.png +0 -0
- data/documentation/static/img/undraw_docusaurus_mountain.svg +170 -0
- data/documentation/static/img/undraw_docusaurus_react.svg +169 -0
- data/documentation/static/img/undraw_docusaurus_tree.svg +1 -0
- data/documentation/yarn.lock +9369 -0
- data/lib/checkout_sdk/api_resource.rb +23 -6
- data/lib/checkout_sdk/configuration.rb +2 -1
- data/lib/checkout_sdk/data/payment_request_source.rb +2 -1
- data/lib/checkout_sdk/version.rb +1 -1
- data/spec/checkout_sdk/api_resource_spec.rb +8 -8
- data/spec/checkout_sdk_spec.rb +14 -0
- metadata +41 -12
@@ -5,10 +5,13 @@ class CheckoutSdk::ApiResource
|
|
5
5
|
attr_reader :checkout_connection
|
6
6
|
|
7
7
|
def initialize
|
8
|
-
@checkout_connection = Excon.new(
|
8
|
+
@checkout_connection = Excon.new(
|
9
|
+
"#{CheckoutSdk.configuration.base_url}",
|
10
|
+
persistent: CheckoutSdk.configuration.persistent
|
11
|
+
)
|
9
12
|
end
|
10
13
|
|
11
|
-
def
|
14
|
+
def request_payment(data_object)
|
12
15
|
post_request("/payments", data_object.data)
|
13
16
|
end
|
14
17
|
|
@@ -42,19 +45,33 @@ class CheckoutSdk::ApiResource
|
|
42
45
|
|
43
46
|
private
|
44
47
|
|
45
|
-
def post_request(path,
|
48
|
+
def post_request(path, data)
|
46
49
|
checkout_connection.post(
|
47
50
|
path: path,
|
48
|
-
body: MultiJson.dump(
|
51
|
+
body: MultiJson.dump(delete_blank(data)),
|
49
52
|
headers: { "Content-Type" => "application/json",
|
50
|
-
"Authorization" =>
|
53
|
+
"Authorization" => key(path) }
|
51
54
|
)
|
52
55
|
end
|
53
56
|
|
54
57
|
def get(path)
|
55
58
|
checkout_connection.get(
|
56
59
|
path: path,
|
57
|
-
headers: { "Authorization" =>
|
60
|
+
headers: { "Authorization" => CheckoutSdk.configuration.secret_key }
|
58
61
|
)
|
59
62
|
end
|
63
|
+
|
64
|
+
def key(path)
|
65
|
+
if path == "/tokens"
|
66
|
+
CheckoutSdk.configuration.public_key
|
67
|
+
else
|
68
|
+
CheckoutSdk.configuration.secret_key
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def delete_blank(data_hash)
|
73
|
+
data_hash.delete_if do |k, v|
|
74
|
+
(v.respond_to?(:empty?) ? v.empty? : v.nil?) or v.instance_of?(Hash) && delete_blank(v).empty?
|
75
|
+
end
|
76
|
+
end
|
60
77
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class CheckoutSdk::Configuration
|
2
|
-
attr_accessor :secret_key, :public_key, :base_url
|
2
|
+
attr_accessor :secret_key, :public_key, :base_url, :persistent
|
3
3
|
|
4
4
|
def initialize
|
5
5
|
@secret_key = nil
|
6
6
|
@public_key = nil
|
7
7
|
@base_url = nil
|
8
|
+
@persistent = true
|
8
9
|
end
|
9
10
|
end
|
@@ -10,13 +10,14 @@ class CheckoutSdk::PaymentRequestSource
|
|
10
10
|
:success_url, :failure_url, :payment_ip, :recipient_dob, :recipient_account_number,
|
11
11
|
:recipient_zip, :recipient_last_name, :processing_mid, :metadata, :cvv, :id, :card_number,
|
12
12
|
:card_expiry_month, :card_expiry_year, :card_name, :card_cvv, :card_stored, :customer_id,
|
13
|
-
:customer_email
|
13
|
+
:customer_email, :merchant_initiated
|
14
14
|
|
15
15
|
def data
|
16
16
|
{ source: source(type),
|
17
17
|
amount: amount,
|
18
18
|
currency: currency,
|
19
19
|
payment_type: payment_type,
|
20
|
+
merchant_initiated: merchant_initiated,
|
20
21
|
reference: reference,
|
21
22
|
description: description,
|
22
23
|
capture: capture,
|
data/lib/checkout_sdk/version.rb
CHANGED
@@ -7,19 +7,19 @@ RSpec.describe CheckoutSdk::ApiResource do
|
|
7
7
|
expect(api_resource.checkout_connection.data[:host]).to eql("test.com")
|
8
8
|
end
|
9
9
|
|
10
|
-
describe "#
|
10
|
+
describe "#request_payment" do
|
11
11
|
let(:payment_request_source) { CheckoutSdk::PaymentRequestSource.new }
|
12
|
-
let(:data) { { mock: true } }
|
12
|
+
let(:data) { { mock: true, mockfalse: false, mockzero: 0, mocknil: nil, mockempty: "" } }
|
13
13
|
|
14
14
|
it "sends a POST request with correct params" do
|
15
15
|
allow(payment_request_source).to receive(:data).and_return(data)
|
16
16
|
|
17
17
|
expect(api_resource.checkout_connection).to receive(:post)
|
18
|
-
.with({ body:"{\"mock\":true}",
|
18
|
+
.with({ body:"{\"mock\":true,\"mockfalse\":false,\"mockzero\":0}",
|
19
19
|
headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
|
20
20
|
path:"/payments" })
|
21
21
|
|
22
|
-
api_resource.
|
22
|
+
api_resource.request_payment(payment_request_source)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -30,7 +30,7 @@ RSpec.describe CheckoutSdk::ApiResource do
|
|
30
30
|
capture_payment.id = 1
|
31
31
|
|
32
32
|
expect(api_resource.checkout_connection).to receive(:post)
|
33
|
-
.with({ body:"{
|
33
|
+
.with({ body:"{}",
|
34
34
|
headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
|
35
35
|
path:"/payments/1/captures" })
|
36
36
|
|
@@ -45,7 +45,7 @@ RSpec.describe CheckoutSdk::ApiResource do
|
|
45
45
|
refund_payment.id = 1
|
46
46
|
|
47
47
|
expect(api_resource.checkout_connection).to receive(:post)
|
48
|
-
.with({ body:"{
|
48
|
+
.with({ body:"{}",
|
49
49
|
headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
|
50
50
|
path:"/payments/1/refunds" })
|
51
51
|
|
@@ -60,7 +60,7 @@ RSpec.describe CheckoutSdk::ApiResource do
|
|
60
60
|
void_payment.id = 1
|
61
61
|
|
62
62
|
expect(api_resource.checkout_connection).to receive(:post)
|
63
|
-
.with({ body:"{
|
63
|
+
.with({ body:"{}",
|
64
64
|
headers:{"Authorization"=>"sk_test", "Content-Type"=>"application/json"},
|
65
65
|
path:"/payments/1/voids" })
|
66
66
|
|
@@ -93,7 +93,7 @@ RSpec.describe CheckoutSdk::ApiResource do
|
|
93
93
|
|
94
94
|
expect(api_resource.checkout_connection).to receive(:post)
|
95
95
|
.with({ body:"{\"mock\":true}",
|
96
|
-
headers:{"Authorization"=>"
|
96
|
+
headers:{"Authorization"=>"pk_test", "Content-Type"=>"application/json"},
|
97
97
|
path:"/tokens" })
|
98
98
|
|
99
99
|
api_resource.request_token(request_token)
|
data/spec/checkout_sdk_spec.rb
CHANGED
@@ -4,4 +4,18 @@ RSpec.describe CheckoutSdk do
|
|
4
4
|
it "has a version number" do
|
5
5
|
expect(CheckoutSdk::VERSION).not_to be nil
|
6
6
|
end
|
7
|
+
|
8
|
+
describe "Config persistent" do
|
9
|
+
it "has a default persistent option" do
|
10
|
+
expect(CheckoutSdk.configuration.persistent).to be_truthy
|
11
|
+
end
|
12
|
+
|
13
|
+
it "allows you to change the persistent option" do
|
14
|
+
CheckoutSdk.configure do |config|
|
15
|
+
config.persistent = false
|
16
|
+
end
|
17
|
+
|
18
|
+
expect(CheckoutSdk.configuration.persistent).to be_falsy
|
19
|
+
end
|
20
|
+
end
|
7
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkout_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Khalid Jazaerly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
47
|
+
version: '3.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '3.
|
54
|
+
version: '3.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,22 @@ dependencies:
|
|
84
84
|
name: excon
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.66'
|
90
|
+
- - "<="
|
88
91
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
92
|
+
version: 0.88.0
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
|
-
- - "
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0.66'
|
100
|
+
- - "<="
|
95
101
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
102
|
+
version: 0.88.0
|
97
103
|
description: A Ruby API wrapper for checkout.com.
|
98
104
|
email:
|
99
105
|
- khalid.jaz@gmail.com
|
@@ -106,11 +112,33 @@ files:
|
|
106
112
|
- ".travis.yml"
|
107
113
|
- Gemfile
|
108
114
|
- Gemfile.lock
|
115
|
+
- LICENSE
|
109
116
|
- README.md
|
110
117
|
- Rakefile
|
111
118
|
- bin/console
|
112
119
|
- bin/setup
|
113
120
|
- checkout_sdk.gemspec
|
121
|
+
- documentation/.gitignore
|
122
|
+
- documentation/docs/environment.md
|
123
|
+
- documentation/docs/getting_started.md
|
124
|
+
- documentation/docs/initialize.md
|
125
|
+
- documentation/docs/install.md
|
126
|
+
- documentation/docs/payments.md
|
127
|
+
- documentation/docs/sources.md
|
128
|
+
- documentation/docs/tokens.md
|
129
|
+
- documentation/docusaurus.config.js
|
130
|
+
- documentation/package-lock.json
|
131
|
+
- documentation/package.json
|
132
|
+
- documentation/sidebars.js
|
133
|
+
- documentation/src/css/custom.css
|
134
|
+
- documentation/src/pages/index.js
|
135
|
+
- documentation/src/pages/styles.module.css
|
136
|
+
- documentation/static/img/favicon.png
|
137
|
+
- documentation/static/img/logo.png
|
138
|
+
- documentation/static/img/undraw_docusaurus_mountain.svg
|
139
|
+
- documentation/static/img/undraw_docusaurus_react.svg
|
140
|
+
- documentation/static/img/undraw_docusaurus_tree.svg
|
141
|
+
- documentation/yarn.lock
|
114
142
|
- lib/checkout_sdk.rb
|
115
143
|
- lib/checkout_sdk/api_resource.rb
|
116
144
|
- lib/checkout_sdk/configuration.rb
|
@@ -127,7 +155,8 @@ files:
|
|
127
155
|
- spec/checkout_sdk_spec.rb
|
128
156
|
- spec/spec_helper.rb
|
129
157
|
homepage: http://checkout.com
|
130
|
-
licenses:
|
158
|
+
licenses:
|
159
|
+
- MIT
|
131
160
|
metadata: {}
|
132
161
|
post_install_message:
|
133
162
|
rdoc_options: []
|
@@ -144,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
173
|
- !ruby/object:Gem::Version
|
145
174
|
version: '0'
|
146
175
|
requirements: []
|
147
|
-
rubygems_version: 3.0.
|
176
|
+
rubygems_version: 3.0.3
|
148
177
|
signing_key:
|
149
178
|
specification_version: 4
|
150
179
|
summary: A Ruby API wrapper for checkout.com.
|