bambora-client 0.1.1 → 0.4.0
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/.github/workflows/gempush.yml +31 -0
- data/.github/workflows/linter.yml +16 -3
- data/.github/workflows/ruby.yml +2 -2
- data/.gitignore +4 -0
- data/.rubocop.yml +0 -3
- data/CHANGELOG.md +20 -0
- data/README.md +25 -0
- data/lib/bambora/bank/batch_report_resource.rb +14 -3
- data/lib/bambora/client/version.rb +1 -1
- data/lib/bambora/rest/client.rb +4 -0
- data/lib/bambora/rest/json_client.rb +49 -0
- data/lib/bambora/v1/payment_resource.rb +16 -0
- data/lib/bambora/v1/profile_resource.rb +88 -2
- metadata +4 -5
- data/Gemfile.lock +0 -93
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfbb5f16d08f5d325effaf6e1f63c6b685f994d24205a8dccf7bcc53da3d2cbd
|
4
|
+
data.tar.gz: 8c29fc34d18356b8f0890a65976e0351ba2686d64181464729753087d85bd892
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fd38771757b08b4c5effbbf9c43b3dbdc894478b76f3c8f896d2e4b6152a28045eb32d9641218d33add77ba29d4be81c38bf381c64d088c33cd69c96c9f990b
|
7
|
+
data.tar.gz: cd04925aa02ec74f09ac4e50b13ba718b8a5ad1d746914b96c8a18d276985233e8ab791361927eeb4e9eeac9fe89ed9bb624b5a7ca0bfcced090392c072dfaef
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- v* # Only run when we carve a new tag
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
build:
|
10
|
+
name: Build + Publish
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Set up Ruby 2.6
|
16
|
+
uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: 2.6
|
19
|
+
|
20
|
+
- name: Publish to RubyGems
|
21
|
+
run: |
|
22
|
+
mkdir -p $HOME/.gem
|
23
|
+
touch $HOME/.gem/credentials
|
24
|
+
chmod 0600 $HOME/.gem/credentials
|
25
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
26
|
+
gem build *.gemspec
|
27
|
+
gem push *.gem
|
28
|
+
env:
|
29
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
30
|
+
|
31
|
+
|
@@ -7,7 +7,20 @@ jobs:
|
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
steps:
|
9
9
|
- uses: actions/checkout@v2
|
10
|
+
with:
|
11
|
+
ref: ${{ github.ref }}
|
12
|
+
- name: Cache Gems
|
13
|
+
uses: actions/cache@v1
|
14
|
+
with:
|
15
|
+
path: vendor/bundle
|
16
|
+
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
|
17
|
+
restore-keys: |
|
18
|
+
${{ runner.os }}-gem-
|
19
|
+
- name: Setup ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
- run: |
|
22
|
+
gem install bundler
|
23
|
+
bundle config path vendor/bundle
|
24
|
+
bundle install --jobs 4 --retry 3
|
10
25
|
- name: Rubocop checks
|
11
|
-
|
12
|
-
env:
|
13
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
26
|
+
run: bundle exec rubocop
|
data/.github/workflows/ruby.yml
CHANGED
@@ -8,7 +8,7 @@ jobs:
|
|
8
8
|
runs-on: ubuntu-latest
|
9
9
|
strategy:
|
10
10
|
matrix:
|
11
|
-
ruby: [
|
11
|
+
ruby: ['2.4', '2.5', '2.6']
|
12
12
|
name: Ruby ${{ matrix.ruby }} Test
|
13
13
|
steps:
|
14
14
|
- uses: actions/checkout@master
|
@@ -22,7 +22,7 @@ jobs:
|
|
22
22
|
restore-keys: |
|
23
23
|
${{ runner.os }}-gem-
|
24
24
|
- name: Setup ruby
|
25
|
-
uses:
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
26
|
with:
|
27
27
|
ruby-version: ${{ matrix.ruby }}
|
28
28
|
- run: |
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## 0.4.0 (2021-05-31)
|
2
|
+
|
3
|
+
- Add `Bambora::V1::PaymentResource#get` method
|
4
|
+
|
5
|
+
## 0.3.0 (2020-05-27)
|
6
|
+
|
7
|
+
- Add `Bambora::V1::ProfileResource#update` method
|
8
|
+
|
9
|
+
## 0.2.0 (2020-05-11)
|
10
|
+
|
11
|
+
- Add `Bambora::V1::ProfileResource#get` method
|
12
|
+
|
13
|
+
## 0.1.3 (2020-04-30)
|
14
|
+
|
15
|
+
- Ensure Batch Report returns empty array `:record` in response at the very least
|
16
|
+
|
17
|
+
## 0.1.2 (2020-04-14)
|
18
|
+
|
19
|
+
- Fix nil record with Bank Batch Report returns
|
20
|
+
|
1
21
|
## 0.1.1 (2020-03-04)
|
2
22
|
|
3
23
|
- Upgrade `rake` to `13.0.1`
|
data/README.md
CHANGED
@@ -92,6 +92,31 @@ profiles.delete(customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A')
|
|
92
92
|
# }
|
93
93
|
```
|
94
94
|
|
95
|
+
### Update a Profile
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
profiles.update(
|
99
|
+
customer_code: '02355E2e58Bf488EAB4EaFAD7083dB6A',
|
100
|
+
payment_profile_data: {
|
101
|
+
language: 'en',
|
102
|
+
comments: 'hello',
|
103
|
+
card: {
|
104
|
+
name: 'Hup Podling',
|
105
|
+
number: '4030000010001234',
|
106
|
+
expiry_month: '12',
|
107
|
+
expiry_year: '23',
|
108
|
+
cvd: '123',
|
109
|
+
},
|
110
|
+
},
|
111
|
+
)
|
112
|
+
|
113
|
+
# => {
|
114
|
+
# :code => 1,
|
115
|
+
# :message => "Operation Successful",
|
116
|
+
# :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
|
117
|
+
# }
|
118
|
+
```
|
119
|
+
|
95
120
|
### Payments
|
96
121
|
|
97
122
|
*Summary*: Process payments using Credit Card, Payment Profile, Legato Token, Cash, Cheque, Interac, Apple Pay, or
|
@@ -53,17 +53,28 @@ module Bambora
|
|
53
53
|
#
|
54
54
|
# @params profile_data [Hash] with values as noted in the example.
|
55
55
|
def show(report_data)
|
56
|
-
|
57
|
-
|
58
|
-
)
|
56
|
+
response = client.post(path: sub_path, body: batch_report_body(report_data))
|
57
|
+
|
58
|
+
response = ensure_record_key_exists(response)
|
59
|
+
response = add_messages_to_response(response)
|
60
|
+
|
61
|
+
response
|
59
62
|
end
|
60
63
|
|
61
64
|
private
|
62
65
|
|
66
|
+
def ensure_record_key_exists(response)
|
67
|
+
# bambora can return null or empty record results, fill it in for consistency
|
68
|
+
response.dig(:response)[:record] = [] if response.dig(:response, :record).nil?
|
69
|
+
|
70
|
+
response
|
71
|
+
end
|
72
|
+
|
63
73
|
def add_messages_to_response(response)
|
64
74
|
response.dig(:response, :record).map! do |record|
|
65
75
|
record.merge!(messages: record[:messageId].split(',').map { |id| MESSAGES[id] })
|
66
76
|
end
|
77
|
+
|
67
78
|
response
|
68
79
|
end
|
69
80
|
|
data/lib/bambora/rest/client.rb
CHANGED
@@ -99,6 +99,55 @@ module Bambora
|
|
99
99
|
).to_h
|
100
100
|
end
|
101
101
|
|
102
|
+
# Make a PUT Request.
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
#
|
106
|
+
# client = Bambora::Rest::JSONClient(base_url: '...', merchant_id: '...')
|
107
|
+
#
|
108
|
+
# data = {
|
109
|
+
# billing: {
|
110
|
+
# name: "joh doe",
|
111
|
+
# address_line1: "123 main st",
|
112
|
+
# address_line2: "111",
|
113
|
+
# city: "victoria",
|
114
|
+
# province: "bc",
|
115
|
+
# country: "ca",
|
116
|
+
# postal_code: "V8T4M3",
|
117
|
+
# phone_number: "25012312345",
|
118
|
+
# email_address: "bill@smith.com"
|
119
|
+
# },
|
120
|
+
# card: {
|
121
|
+
# name: 'Hup Podling',
|
122
|
+
# number: '4030000010001234',
|
123
|
+
# expiry_month: '12',
|
124
|
+
# expiry_year: '23',
|
125
|
+
# cvd: '123',
|
126
|
+
# },
|
127
|
+
# }
|
128
|
+
#
|
129
|
+
# client.put(
|
130
|
+
# path: 'v1/profiles',
|
131
|
+
# body: data,
|
132
|
+
# api_key: '...'
|
133
|
+
# )
|
134
|
+
# # => {
|
135
|
+
# # :code => 1,
|
136
|
+
# # :message => "Operation Successful",
|
137
|
+
# # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
|
138
|
+
# # }
|
139
|
+
#
|
140
|
+
# @param path [String] Indicating request path.
|
141
|
+
# @param body [Hash] Data to be sent in the body of the request.
|
142
|
+
# @param api_key [String] Indicating the API Key to be used with the request.
|
143
|
+
#
|
144
|
+
# @return [Hash] Indicating success or failure of the operation.
|
145
|
+
def put(path:, body:, api_key:)
|
146
|
+
parse_response_body(
|
147
|
+
super(path: path, body: body.to_json.to_s, headers: build_headers(api_key: api_key)),
|
148
|
+
).to_h
|
149
|
+
end
|
150
|
+
|
102
151
|
private
|
103
152
|
|
104
153
|
def build_headers(api_key:)
|
@@ -77,6 +77,22 @@ module Bambora
|
|
77
77
|
end
|
78
78
|
|
79
79
|
alias make_payment_with_payment_profile create_with_payment_profile
|
80
|
+
|
81
|
+
# Retrieve the details of a previously attempted payment.
|
82
|
+
#
|
83
|
+
#
|
84
|
+
# @example
|
85
|
+
#
|
86
|
+
# client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
|
87
|
+
# payments = Bambora::V1::PaymentResource(client: client)
|
88
|
+
# payments.get(transaction_id: 1000341)
|
89
|
+
#
|
90
|
+
# @param transaction_id [Integer] An integer identifier for the associated transaction.
|
91
|
+
#
|
92
|
+
# @return [Hash] Transaction details.
|
93
|
+
def get(transaction_id:)
|
94
|
+
client.get(path: "#{sub_path}/#{transaction_id}", api_key: api_key)
|
95
|
+
end
|
80
96
|
end
|
81
97
|
end
|
82
98
|
end
|
@@ -54,8 +54,94 @@ module Bambora
|
|
54
54
|
# @see https://dev.na.bambora.com/docs/guides/payment_profiles
|
55
55
|
#
|
56
56
|
# @return [Hash] Indicating success or failure of the operation.
|
57
|
-
def create(
|
58
|
-
client.post(path: sub_path, body:
|
57
|
+
def create(payment_profile_data)
|
58
|
+
client.post(path: sub_path, body: payment_profile_data, api_key: api_key)
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Get a Bambora payment profile given a customer code.
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
#
|
66
|
+
# client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
|
67
|
+
# profiles = Bambora::V1::ProfileResource(client: client)
|
68
|
+
# customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'
|
69
|
+
#
|
70
|
+
# profiles.get(customer_code: customer_code)
|
71
|
+
# # => {
|
72
|
+
# # :code => 1,
|
73
|
+
# # :message => "Operation Successful",
|
74
|
+
# # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
|
75
|
+
# # :status => "A",
|
76
|
+
# # :last_transaction => "1900-01-01T00:00:00",
|
77
|
+
# # :modified_date => "1900-01-01T00:00:00",
|
78
|
+
# # :card => { :name => "", :number => "", :card_type => "" },
|
79
|
+
# # :language => "en",
|
80
|
+
# # :velocity_group => "",
|
81
|
+
# # :profile_group => "",
|
82
|
+
# # :account_ref => "",
|
83
|
+
# # :billing =>
|
84
|
+
# # {
|
85
|
+
# # :name => "Harry Lewis",
|
86
|
+
# # :address_line1 => "",
|
87
|
+
# # :address_line2 => "",
|
88
|
+
# # :city => "",
|
89
|
+
# # :province => "",
|
90
|
+
# # :country => "",
|
91
|
+
# # :postal_code => "",
|
92
|
+
# # :phone_number => "",
|
93
|
+
# # :email_address => ""},
|
94
|
+
# # :custom => { :ref1 => "", :ref2 => "", :ref3 => "", :ref4 => "", :ref5 => "" }}
|
95
|
+
#
|
96
|
+
# @param customer_code [String] A unique identifier for the associated payment profile.
|
97
|
+
#
|
98
|
+
# @return [Hash] Payment profile details.
|
99
|
+
def get(customer_code:)
|
100
|
+
client.get(path: "#{sub_path}/#{customer_code}", api_key: api_key)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Make a PUT Request.
|
104
|
+
#
|
105
|
+
# @example
|
106
|
+
#
|
107
|
+
# client = Bambora::Rest::JSONClient(base_url: '...', api_key: '...', merchant_id: '...')
|
108
|
+
# profiles = Bambora::V1::ProfileResource(client: client)
|
109
|
+
# customer_code = '02355E2e58Bf488EAB4EaFAD7083dB6A'
|
110
|
+
#
|
111
|
+
# data = {
|
112
|
+
# billing: {
|
113
|
+
# name: "joh doe",
|
114
|
+
# address_line1: "123 main st",
|
115
|
+
# address_line2: "111",
|
116
|
+
# city: "victoria",
|
117
|
+
# province: "bc",
|
118
|
+
# country: "ca",
|
119
|
+
# postal_code: "V8T4M3",
|
120
|
+
# phone_number: "25012312345",
|
121
|
+
# email_address: "bill@smith.com"
|
122
|
+
# },
|
123
|
+
# card: {
|
124
|
+
# name: 'Hup Podling',
|
125
|
+
# number: '4030000010001234',
|
126
|
+
# expiry_month: '12',
|
127
|
+
# expiry_year: '23',
|
128
|
+
# cvd: '123',
|
129
|
+
# },
|
130
|
+
# }
|
131
|
+
#
|
132
|
+
# profiles.update(customer_code: customer_code, payment_profile_data: data)
|
133
|
+
# # => {
|
134
|
+
# # :code => 1,
|
135
|
+
# # :message => "Operation Successful",
|
136
|
+
# # :customer_code => "02355E2e58Bf488EAB4EaFAD7083dB6A",
|
137
|
+
# # }
|
138
|
+
#
|
139
|
+
# @param customer_code [String] A unique identifier for the associated payment profile.
|
140
|
+
# @param data [Hash] Payment profile data to be sent in the body of the request.
|
141
|
+
#
|
142
|
+
# @return [Hash] Indicating success or failure of the operation.
|
143
|
+
def update(customer_code:, payment_profile_data:)
|
144
|
+
client.put(path: "#{@sub_path}/#{customer_code}", body: payment_profile_data, api_key: api_key)
|
59
145
|
end
|
60
146
|
|
61
147
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bambora-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cassidy K
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -187,6 +187,7 @@ executables: []
|
|
187
187
|
extensions: []
|
188
188
|
extra_rdoc_files: []
|
189
189
|
files:
|
190
|
+
- ".github/workflows/gempush.yml"
|
190
191
|
- ".github/workflows/linter.yml"
|
191
192
|
- ".github/workflows/ruby.yml"
|
192
193
|
- ".gitignore"
|
@@ -196,7 +197,6 @@ files:
|
|
196
197
|
- CHANGELOG.md
|
197
198
|
- CODE_OF_CONDUCT.md
|
198
199
|
- Gemfile
|
199
|
-
- Gemfile.lock
|
200
200
|
- LICENSE.txt
|
201
201
|
- README.md
|
202
202
|
- Rakefile
|
@@ -250,8 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
250
250
|
- !ruby/object:Gem::Version
|
251
251
|
version: '0'
|
252
252
|
requirements: []
|
253
|
-
|
254
|
-
rubygems_version: 2.7.6.2
|
253
|
+
rubygems_version: 3.0.3.1
|
255
254
|
signing_key:
|
256
255
|
specification_version: 4
|
257
256
|
summary: A thread-safe client for the Bambora/Beanstream API.
|
data/Gemfile.lock
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
bambora-client (0.1.0)
|
5
|
-
excon (< 1.0)
|
6
|
-
faraday (< 1.0)
|
7
|
-
gyoku (~> 1.0)
|
8
|
-
multiparty (~> 0)
|
9
|
-
|
10
|
-
GEM
|
11
|
-
remote: https://rubygems.org/
|
12
|
-
specs:
|
13
|
-
addressable (2.7.0)
|
14
|
-
public_suffix (>= 2.0.2, < 5.0)
|
15
|
-
ast (2.4.0)
|
16
|
-
builder (3.2.4)
|
17
|
-
byebug (11.0.1)
|
18
|
-
coderay (1.1.2)
|
19
|
-
crack (0.4.3)
|
20
|
-
safe_yaml (~> 1.0.0)
|
21
|
-
diff-lcs (1.3)
|
22
|
-
excon (0.71.0)
|
23
|
-
faraday (0.17.1)
|
24
|
-
multipart-post (>= 1.2, < 3)
|
25
|
-
gyoku (1.3.1)
|
26
|
-
builder (>= 2.1.2)
|
27
|
-
hashdiff (1.0.0)
|
28
|
-
jaro_winkler (1.5.3)
|
29
|
-
method_source (0.9.2)
|
30
|
-
mime-types (3.3)
|
31
|
-
mime-types-data (~> 3.2015)
|
32
|
-
mime-types-data (3.2019.1009)
|
33
|
-
multipart-post (2.1.1)
|
34
|
-
multiparty (0.2.0)
|
35
|
-
mime-types
|
36
|
-
parallel (1.18.0)
|
37
|
-
parser (2.6.5.0)
|
38
|
-
ast (~> 2.4.0)
|
39
|
-
pry (0.12.2)
|
40
|
-
coderay (~> 1.1.0)
|
41
|
-
method_source (~> 0.9.0)
|
42
|
-
pry-byebug (3.7.0)
|
43
|
-
byebug (~> 11.0)
|
44
|
-
pry (~> 0.10)
|
45
|
-
public_suffix (4.0.1)
|
46
|
-
rainbow (3.0.0)
|
47
|
-
rake (13.0.1)
|
48
|
-
rspec (3.9.0)
|
49
|
-
rspec-core (~> 3.9.0)
|
50
|
-
rspec-expectations (~> 3.9.0)
|
51
|
-
rspec-mocks (~> 3.9.0)
|
52
|
-
rspec-core (3.9.0)
|
53
|
-
rspec-support (~> 3.9.0)
|
54
|
-
rspec-expectations (3.9.0)
|
55
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
-
rspec-support (~> 3.9.0)
|
57
|
-
rspec-mocks (3.9.0)
|
58
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
59
|
-
rspec-support (~> 3.9.0)
|
60
|
-
rspec-support (3.9.0)
|
61
|
-
rspec_junit_formatter (0.4.1)
|
62
|
-
rspec-core (>= 2, < 4, != 2.12.0)
|
63
|
-
rubocop (0.74.0)
|
64
|
-
jaro_winkler (~> 1.5.1)
|
65
|
-
parallel (~> 1.10)
|
66
|
-
parser (>= 2.6)
|
67
|
-
rainbow (>= 2.2.2, < 4.0)
|
68
|
-
ruby-progressbar (~> 1.7)
|
69
|
-
unicode-display_width (>= 1.4.0, < 1.7)
|
70
|
-
ruby-progressbar (1.10.1)
|
71
|
-
safe_yaml (1.0.5)
|
72
|
-
unicode-display_width (1.6.0)
|
73
|
-
webmock (3.7.6)
|
74
|
-
addressable (>= 2.3.6)
|
75
|
-
crack (>= 0.3.2)
|
76
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
77
|
-
|
78
|
-
PLATFORMS
|
79
|
-
ruby
|
80
|
-
|
81
|
-
DEPENDENCIES
|
82
|
-
bambora-client!
|
83
|
-
bundler (~> 2)
|
84
|
-
pry (~> 0.12.0)
|
85
|
-
pry-byebug (~> 3.7)
|
86
|
-
rake (~> 13.0)
|
87
|
-
rspec (~> 3.0)
|
88
|
-
rspec_junit_formatter (~> 0.4.1)
|
89
|
-
rubocop (~> 0.74.0)
|
90
|
-
webmock (~> 3.7)
|
91
|
-
|
92
|
-
BUNDLED WITH
|
93
|
-
2.1.0
|