checkout_sdk 0.1.4 → 0.3.2
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/README.md +96 -22
- data/checkout_sdk.gemspec +3 -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 +16 -5
- 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 +5 -5
- data/spec/checkout_sdk_spec.rb +14 -0
- metadata +38 -11
@@ -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
|
|
@@ -47,20 +50,28 @@ class CheckoutSdk::ApiResource
|
|
47
50
|
path: path,
|
48
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
|
60
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
|
+
|
61
72
|
def delete_blank(data_hash)
|
62
73
|
data_hash.delete_if do |k, v|
|
63
|
-
(v.respond_to?(:empty?) ? v.empty? :
|
74
|
+
(v.respond_to?(:empty?) ? v.empty? : v.nil?) or v.instance_of?(Hash) && delete_blank(v).empty?
|
64
75
|
end
|
65
76
|
end
|
66
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
|
|
@@ -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.2
|
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
|
@@ -112,6 +118,27 @@ files:
|
|
112
118
|
- bin/console
|
113
119
|
- bin/setup
|
114
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
|
115
142
|
- lib/checkout_sdk.rb
|
116
143
|
- lib/checkout_sdk/api_resource.rb
|
117
144
|
- lib/checkout_sdk/configuration.rb
|
@@ -146,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
173
|
- !ruby/object:Gem::Version
|
147
174
|
version: '0'
|
148
175
|
requirements: []
|
149
|
-
rubygems_version: 3.0.
|
176
|
+
rubygems_version: 3.0.3
|
150
177
|
signing_key:
|
151
178
|
specification_version: 4
|
152
179
|
summary: A Ruby API wrapper for checkout.com.
|