bckbn 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.irbrc +63 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +16 -17
- data/lib/bckbn/connection.rb +25 -0
- data/lib/bckbn/resources/charge/api.rb +30 -0
- data/lib/bckbn/resources/charge/models/requests.rb +13 -0
- data/lib/bckbn/resources/charge/models/responses.rb +40 -0
- data/lib/bckbn/resources/transaction/api.rb +40 -46
- data/lib/bckbn/resources/transaction/models/payment.rb +24 -0
- data/lib/bckbn/version.rb +1 -1
- data/lib/bckbn.rb +6 -0
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17f59a2d0a76520c2ce364ef1bcfd8ca46e9a20f51026cb2613f9d66482ae278
|
4
|
+
data.tar.gz: 51458c020327baffec1803bb3dc0fe6b8e890c771a9dd4cd7d604940b26f0aed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63c67a32658b11f8b6f05cae841cf3feca56863a9528c158b29ec74e852f259f7fa0832112dbc0bdf611132d2207a7b9dcc8762ac972ab247194b1b4c5ac9dcd
|
7
|
+
data.tar.gz: f5fe4a59cd73013bef9277a4c3f5255a6a89e934fa25fe643d4f5747d8e310a06f1865ffcb80d71c97a8d7affdb4ec2fcb7b942197a22da581def1465063429d
|
data/.irbrc
CHANGED
@@ -76,3 +76,66 @@ Bckbn.merchant_id = "101"
|
|
76
76
|
"order_id": "5234234",
|
77
77
|
"order_source": "ecommerce"
|
78
78
|
}.freeze
|
79
|
+
|
80
|
+
@charge = {
|
81
|
+
amount: 500_000_000,
|
82
|
+
description: "JulyFees",
|
83
|
+
source: {
|
84
|
+
type: "bank",
|
85
|
+
bank: {
|
86
|
+
routing_number: "021200339",
|
87
|
+
account_number: "6546543213",
|
88
|
+
account_type: "Checking",
|
89
|
+
name: "Glenn Quagmire"
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
@payout = {
|
95
|
+
amount: 2500,
|
96
|
+
description: "JulyFees",
|
97
|
+
destination: {
|
98
|
+
type: "bank",
|
99
|
+
bank: {
|
100
|
+
routing_number: "021200339",
|
101
|
+
account_number: "6546543213",
|
102
|
+
account_type: "Checking",
|
103
|
+
name: "Glenn Quagmire"
|
104
|
+
}
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
# @originate_batch_body = {
|
109
|
+
# "payments": [{
|
110
|
+
# "account_number": "2654377916",
|
111
|
+
# "receiver": {
|
112
|
+
# "routing_number": "021200339",
|
113
|
+
# "account_number": "6546543213",
|
114
|
+
# "account_type": "Checking",
|
115
|
+
# "name": "Glenn Quagmire",
|
116
|
+
# "identification": "XYZ123"
|
117
|
+
# },
|
118
|
+
# "sec_code": "PPD",
|
119
|
+
# "description": "JulyFees",
|
120
|
+
# "transaction_type": "Push",
|
121
|
+
# "amount": 25_000,
|
122
|
+
# "purpose": "sample payment",
|
123
|
+
# "service_type": "Standard"
|
124
|
+
# },
|
125
|
+
# {
|
126
|
+
# "account_number": "2654377916",
|
127
|
+
# "receiver": {
|
128
|
+
# "routing_number": "021200339",
|
129
|
+
# "account_number": "6546543213",
|
130
|
+
# "account_type": "Checking",
|
131
|
+
# "name": "Pam Anderson",
|
132
|
+
# "identification": "ABCDEFG"
|
133
|
+
# },
|
134
|
+
# "sec_code": "PPD",
|
135
|
+
# "description": "JulyFees",
|
136
|
+
# "transaction_type": "Push",
|
137
|
+
# "amount": 33_333,
|
138
|
+
# "purpose": "sample payment",
|
139
|
+
# "service_type": "Standard"
|
140
|
+
# }]
|
141
|
+
# }
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,40 +1,40 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bckbn (2.
|
4
|
+
bckbn (2.1.1)
|
5
|
+
addressable (~> 2.8.5)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
|
-
addressable (2.8.
|
10
|
+
addressable (2.8.6)
|
10
11
|
public_suffix (>= 2.0.2, < 6.0)
|
11
12
|
ast (2.4.2)
|
12
|
-
base64 (0.1.1)
|
13
13
|
coderay (1.1.3)
|
14
14
|
concurrent-ruby (1.2.2)
|
15
15
|
crack (0.4.5)
|
16
16
|
rexml
|
17
17
|
diff-lcs (1.5.0)
|
18
|
-
faker (3.2.
|
18
|
+
faker (3.2.2)
|
19
19
|
i18n (>= 1.8.11, < 2)
|
20
|
-
hashdiff (1.0
|
20
|
+
hashdiff (1.1.0)
|
21
21
|
i18n (1.14.1)
|
22
22
|
concurrent-ruby (~> 1.0)
|
23
|
-
json (2.
|
23
|
+
json (2.7.1)
|
24
24
|
language_server-protocol (3.17.0.3)
|
25
25
|
method_source (1.0.0)
|
26
|
-
parallel (1.
|
27
|
-
parser (3.
|
26
|
+
parallel (1.24.0)
|
27
|
+
parser (3.3.0.2)
|
28
28
|
ast (~> 2.4.1)
|
29
29
|
racc
|
30
30
|
pry (0.14.2)
|
31
31
|
coderay (~> 1.1)
|
32
32
|
method_source (~> 1.0)
|
33
|
-
public_suffix (5.0.
|
34
|
-
racc (1.7.
|
33
|
+
public_suffix (5.0.4)
|
34
|
+
racc (1.7.3)
|
35
35
|
rainbow (3.1.1)
|
36
|
-
rake (13.0
|
37
|
-
regexp_parser (2.
|
36
|
+
rake (13.1.0)
|
37
|
+
regexp_parser (2.9.0)
|
38
38
|
rexml (3.2.6)
|
39
39
|
rspec (3.12.0)
|
40
40
|
rspec-core (~> 3.12.0)
|
@@ -49,19 +49,18 @@ GEM
|
|
49
49
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
50
|
rspec-support (~> 3.12.0)
|
51
51
|
rspec-support (3.12.1)
|
52
|
-
rubocop (1.
|
53
|
-
base64 (~> 0.1.1)
|
52
|
+
rubocop (1.59.0)
|
54
53
|
json (~> 2.3)
|
55
54
|
language_server-protocol (>= 3.17.0)
|
56
55
|
parallel (~> 1.10)
|
57
|
-
parser (>= 3.2.2.
|
56
|
+
parser (>= 3.2.2.4)
|
58
57
|
rainbow (>= 2.2.2, < 4.0)
|
59
58
|
regexp_parser (>= 1.8, < 3.0)
|
60
59
|
rexml (>= 3.2.5, < 4.0)
|
61
|
-
rubocop-ast (>= 1.
|
60
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
62
61
|
ruby-progressbar (~> 1.7)
|
63
62
|
unicode-display_width (>= 2.4.0, < 3.0)
|
64
|
-
rubocop-ast (1.
|
63
|
+
rubocop-ast (1.30.0)
|
65
64
|
parser (>= 3.2.1.0)
|
66
65
|
ruby-progressbar (1.13.0)
|
67
66
|
unicode-display_width (2.5.0)
|
data/lib/bckbn/connection.rb
CHANGED
@@ -41,6 +41,31 @@ module Bckbn
|
|
41
41
|
bckbn_headers.each { |k, v| request[k] = v }
|
42
42
|
request.body = body.to_json
|
43
43
|
|
44
|
+
response_handler(url, request) do |response, rbody|
|
45
|
+
case response
|
46
|
+
when Net::HTTPSuccess
|
47
|
+
data = rbody.fetch("data")
|
48
|
+
log(:debug, "\nResponse: #{data.to_json}")
|
49
|
+
klass.new(**data, logs: @logs)
|
50
|
+
else
|
51
|
+
err_klass = ERRORS[response.class]
|
52
|
+
message = "Error: #{rbody ? rbody["errors"] : "Unknown"}"
|
53
|
+
log(:error, message)
|
54
|
+
err = err_klass.new(message, @logs)
|
55
|
+
raise err
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_from_api(path, klass)
|
61
|
+
log(:debug, "GET #{path}\n")
|
62
|
+
|
63
|
+
url = URI.parse(config.api_base + path)
|
64
|
+
request = Net::HTTP::Get.new(url.path)
|
65
|
+
bckbn_headers = headers(config)
|
66
|
+
bckbn_headers.reject! { |_, v| v.nil? || v == "" }
|
67
|
+
bckbn_headers.each { |k, v| request[k] = v }
|
68
|
+
|
44
69
|
response_handler(url, request) do |response, rbody|
|
45
70
|
case response
|
46
71
|
when Net::HTTPSuccess
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bckbn
|
4
|
+
module Charge
|
5
|
+
ENDPOINTS = {
|
6
|
+
all: "/charges",
|
7
|
+
create: "/charges",
|
8
|
+
get: "/charges/{id}"
|
9
|
+
}.freeze
|
10
|
+
private_constant :ENDPOINTS
|
11
|
+
|
12
|
+
def self.all(config = {})
|
13
|
+
path = ENDPOINTS.fetch(__method__)
|
14
|
+
@conn = Bckbn::Connection.new(config)
|
15
|
+
@conn.get_from_api(path, ChargesResponse)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.create(body, config = {})
|
19
|
+
body = CreateChargeRequest.new(body)
|
20
|
+
@conn = Bckbn::Connection.new(config)
|
21
|
+
@conn.post_to_api(ENDPOINTS.fetch(__method__), body.to_h, ChargeResponse)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.get(id, config = {})
|
25
|
+
path = Addressable::Template.new(ENDPOINTS.fetch(__method__)).expand(id: id)
|
26
|
+
@conn = Bckbn::Connection.new(config)
|
27
|
+
@conn.get_from_api(path, ChargeResponse)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bckbn
|
4
|
+
module Charge
|
5
|
+
using Bckbn::CoreExt::StringExt
|
6
|
+
|
7
|
+
CHARGE_RESPONSE_MEMBERS = %i[
|
8
|
+
id
|
9
|
+
amount
|
10
|
+
direction
|
11
|
+
posting
|
12
|
+
posting_code
|
13
|
+
posting_type
|
14
|
+
status
|
15
|
+
transaction_type
|
16
|
+
logs
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
CHARGES_RESPONSE_MEMBERS = %i[
|
20
|
+
charges
|
21
|
+
page_number
|
22
|
+
page_size
|
23
|
+
has_previous_page
|
24
|
+
has_next_page
|
25
|
+
logs
|
26
|
+
].freeze
|
27
|
+
|
28
|
+
private_constant :CHARGE_RESPONSE_MEMBERS
|
29
|
+
|
30
|
+
ChargeResponse = Struct.new(*CHARGE_RESPONSE_MEMBERS, keyword_init: true)
|
31
|
+
|
32
|
+
ChargesResponse = Struct.new(*CHARGES_RESPONSE_MEMBERS, keyword_init: true) do
|
33
|
+
def initialize(**opts)
|
34
|
+
charges = opts.delete("charges")
|
35
|
+
super(opts)
|
36
|
+
self.charges = charges.map { |c| ChargeResponse.new(c) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -14,52 +14,46 @@ module Bckbn
|
|
14
14
|
}.freeze
|
15
15
|
private_constant :ENDPOINTS
|
16
16
|
|
17
|
-
|
18
|
-
body =
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
body =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
body =
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.echeck_void(body, config = {})
|
60
|
-
body = EcheckVoidRequest.new(body)
|
61
|
-
@conn = Bckbn::Connection.new(config)
|
62
|
-
@conn.post_to_api(ENDPOINTS.fetch(__method__), body.to_h, EcheckVoidResponse)
|
17
|
+
class << self
|
18
|
+
def authorization(body, config = {})
|
19
|
+
process_transaction(__method__, body, config, AuthorizationRequest, AuthorizationResponse)
|
20
|
+
end
|
21
|
+
|
22
|
+
def capture(body, config = {})
|
23
|
+
process_transaction(__method__, body, config, CaptureRequest, CaptureResponse)
|
24
|
+
end
|
25
|
+
|
26
|
+
def credit(body, config = {})
|
27
|
+
process_transaction(__method__, body, config, CreditRequest, CreditResponse)
|
28
|
+
end
|
29
|
+
|
30
|
+
def sale(body, config = {})
|
31
|
+
process_transaction(__method__, body, config, SaleRequest, SaleResponse)
|
32
|
+
end
|
33
|
+
|
34
|
+
def void(body, config = {})
|
35
|
+
process_transaction(__method__, body, config, VoidRequest, VoidResponse)
|
36
|
+
end
|
37
|
+
|
38
|
+
def echeck_credit(body, config = {})
|
39
|
+
process_transaction(__method__, body, config, EcheckCreditRequest, EcheckCreditResponse)
|
40
|
+
end
|
41
|
+
|
42
|
+
def echeck_sale(body, config = {})
|
43
|
+
process_transaction(__method__, body, config, EcheckSaleRequest, EcheckSaleResponse)
|
44
|
+
end
|
45
|
+
|
46
|
+
def echeck_void(body, config = {})
|
47
|
+
process_transaction(__method__, body, config, EcheckVoidRequest, EcheckVoidResponse)
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def process_transaction(method, body, config, request_klass, response_klass)
|
53
|
+
request = request_klass.new(body)
|
54
|
+
conn = Bckbn::Connection.new(config)
|
55
|
+
conn.post_to_api(ENDPOINTS.fetch(method), request.to_h, response_klass)
|
56
|
+
end
|
63
57
|
end
|
64
58
|
end
|
65
59
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bckbn
|
4
|
+
module Transaction
|
5
|
+
MEMBERS = %i[
|
6
|
+
account_number
|
7
|
+
receiver
|
8
|
+
sec_code
|
9
|
+
description
|
10
|
+
transaction_type
|
11
|
+
amount
|
12
|
+
service_type
|
13
|
+
purpose
|
14
|
+
client_identifier
|
15
|
+
].freeze
|
16
|
+
|
17
|
+
Payment = Struct.new(*MEMBERS, keyword_init: true) do
|
18
|
+
def initialize(opts)
|
19
|
+
valid_opts = opts.slice(*members)
|
20
|
+
valid_opts.each { |key, value| public_send("#{key}=", value) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/bckbn/version.rb
CHANGED
data/lib/bckbn.rb
CHANGED
@@ -4,6 +4,7 @@ require "json"
|
|
4
4
|
require "forwardable"
|
5
5
|
require "logger"
|
6
6
|
require "net/http"
|
7
|
+
require "addressable"
|
7
8
|
require "bckbn/version"
|
8
9
|
require "bckbn/configuration"
|
9
10
|
require "bckbn/core_ext"
|
@@ -14,6 +15,11 @@ require "bckbn/resources/transaction/models/echeck"
|
|
14
15
|
require "bckbn/resources/transaction/models/billing_address"
|
15
16
|
require "bckbn/resources/transaction/models/requests"
|
16
17
|
require "bckbn/resources/transaction/models/responses"
|
18
|
+
require "bckbn/resources/transaction/models/payment"
|
19
|
+
|
20
|
+
require "bckbn/resources/charge/api"
|
21
|
+
require "bckbn/resources/charge/models/requests"
|
22
|
+
require "bckbn/resources/charge/models/responses"
|
17
23
|
|
18
24
|
module Bckbn
|
19
25
|
@config = Bckbn::Configuration.setup
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bckbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nikkypx
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: addressable
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.5
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.5
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: faker
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,11 +114,15 @@ files:
|
|
100
114
|
- lib/bckbn/configuration.rb
|
101
115
|
- lib/bckbn/connection.rb
|
102
116
|
- lib/bckbn/core_ext.rb
|
117
|
+
- lib/bckbn/resources/charge/api.rb
|
118
|
+
- lib/bckbn/resources/charge/models/requests.rb
|
119
|
+
- lib/bckbn/resources/charge/models/responses.rb
|
103
120
|
- lib/bckbn/resources/transaction/api.rb
|
104
121
|
- lib/bckbn/resources/transaction/models/billing_address.rb
|
105
122
|
- lib/bckbn/resources/transaction/models/card.rb
|
106
123
|
- lib/bckbn/resources/transaction/models/cardholder_authentication.rb
|
107
124
|
- lib/bckbn/resources/transaction/models/echeck.rb
|
125
|
+
- lib/bckbn/resources/transaction/models/payment.rb
|
108
126
|
- lib/bckbn/resources/transaction/models/requests.rb
|
109
127
|
- lib/bckbn/resources/transaction/models/responses.rb
|
110
128
|
- lib/bckbn/version.rb
|