paypoint-blue 0.6.0 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 153e9ecd01ade6890bf456a002c4bbfa5caef74f
4
- data.tar.gz: 693db491d2aa3db825f10a2c81e2551e0da57137
2
+ SHA256:
3
+ metadata.gz: 202bbdd455262fba3598c8f415f3fbaece682ddce23867b15b3048e6516386fe
4
+ data.tar.gz: c3615ca75516a1dd1264a37a8adcf99bd85e97c4a2a04d7b0e88f0d29784e785
5
5
  SHA512:
6
- metadata.gz: 753f1ea2f28efcda32dbe6e6508640669774790794226850863f5d916aeae7b7c9ac4ce6f74883d6b70566be9f674e0f0957d0f8f142ae96623a2d84bf07fc2b
7
- data.tar.gz: aa1d5c4f2babeed4c25c05d9842db37dc3183401882563c88d07532a5fecda5a24c4acaeb7226c9b46ae8d0c8992d90fb452c28386a44485fbdd893bd719366b
6
+ metadata.gz: 736659c3996c73b5ebbc315494fc16cd25c83b27982b24296654825ee92357fb92b59bcf7565089348f0e27eb9fdc21f6a7e7c1440afec2f1306c960b7145c5a
7
+ data.tar.gz: e242de7b2c68db731d006724a7a100ee08bdca4a50f8466344e7c9799d854a56ea54ca84a6fbb74bec334ff5bcc20089962b7e1f0fd122e605ed068b48df2a1d
data/.rubocop.yml CHANGED
@@ -5,6 +5,7 @@ AllCops:
5
5
  - "bin/*"
6
6
  - "support/**/*"
7
7
  - "vendor/**/*"
8
+ TargetRubyVersion: 2.2
8
9
 
9
10
  ### Style ######################################################################
10
11
 
@@ -24,9 +25,15 @@ Style/BlockDelimiters:
24
25
  Style/IndentHash:
25
26
  EnforcedStyle: consistent
26
27
 
28
+ Style/MultilineMethodCallIndentation:
29
+ EnforcedStyle: indented
30
+
27
31
  Style/MultilineOperationIndentation:
28
32
  EnforcedStyle: indented
29
33
 
34
+ Style/SignalException:
35
+ EnforcedStyle: semantic
36
+
30
37
  Style/StringLiterals:
31
38
  EnforcedStyle: double_quotes
32
39
 
@@ -38,7 +45,10 @@ Style/StringLiteralsInInterpolation:
38
45
  Style/SymbolArray:
39
46
  Enabled: false
40
47
 
41
- Style/TrailingComma:
48
+ Style/TrailingCommaInArguments:
49
+ EnforcedStyleForMultiline: comma
50
+
51
+ Style/TrailingCommaInLiteral:
42
52
  EnforcedStyleForMultiline: comma
43
53
 
44
54
  Style/ClassAndModuleChildren:
@@ -3,8 +3,8 @@ require "paypoint/blue/base"
3
3
  # Client class for the API product.
4
4
  class PayPoint::Blue::API < PayPoint::Blue::Base
5
5
  ENDPOINTS = {
6
- test: "https://api.mite.paypoint.net:2443/acceptor/rest",
7
- live: "https://api.paypoint.net/acceptor/rest",
6
+ test: "https://api.mite.pay360.com/acceptor/rest",
7
+ live: "https://api.pay360.com/acceptor/rest",
8
8
  }.freeze
9
9
 
10
10
  shortcut :merchant_ref, "transaction.merchant_ref"
@@ -14,6 +14,7 @@ class PayPoint::Blue::API < PayPoint::Blue::Base
14
14
  shortcut :description, "transaction.description"
15
15
  shortcut :customer_ref, "customer.merchant_ref"
16
16
  shortcut :customer_name, "customer.display_name"
17
+ shortcut :customer_registration, "customer.registered"
17
18
 
18
19
  shortcut :pre_auth_callback, "callbacks.pre_auth_callback.url"
19
20
  shortcut :post_auth_callback, "callbacks.post_auth_callback.url"
@@ -46,7 +47,7 @@ class PayPoint::Blue::API < PayPoint::Blue::Base
46
47
  def make_payment(**payload)
47
48
  payload = build_payload payload, defaults: %i(
48
49
  currency commerce_type pre_auth_callback post_auth_callback
49
- transaction_notification expiry_notification
50
+ transaction_notification expiry_notification customer_registration
50
51
  )
51
52
  client.post "transactions/#{inst_id}/payment", payload
52
53
  end
@@ -52,9 +52,12 @@ module PayPoint
52
52
  # @option options [String] :runscope when used, all traffic will
53
53
  # pass through the provided {https://www.runscope.com/ Runscope}
54
54
  # bucket, including notification callbacks
55
+ # @option options [Integer] :timeout waiting for response in seconds
56
+ # @option options [Integer] :open_timeout waiting for opening a connection
57
+ # in seconds
55
58
  def initialize(endpoint:, inst_id: ENV["BLUE_API_INSTALLATION"],
56
- api_id: ENV["BLUE_API_ID"], api_password: ENV["BLUE_API_PASSWORD"],
57
- **options)
59
+ api_id: ENV["BLUE_API_ID"], api_password: ENV["BLUE_API_PASSWORD"],
60
+ **options)
58
61
 
59
62
  @endpoint = get_endpoint_or_override_with(endpoint)
60
63
  @inst_id = inst_id or fail ArgumentError, "missing inst_id"
@@ -63,7 +66,7 @@ module PayPoint
63
66
  api_password or fail ArgumentError, "missing api_password"
64
67
 
65
68
  self.defaults = options.delete(:defaults)
66
- @options = options.merge url: @endpoint
69
+ @options = options.merge(url: @endpoint, **request_timeouts(options))
67
70
  @client = build_client
68
71
  end
69
72
 
@@ -75,6 +78,15 @@ module PayPoint
75
78
  self.class.const_get("ENDPOINTS").fetch(endpoint, endpoint.to_s)
76
79
  end
77
80
 
81
+ def request_timeouts(timeout_options)
82
+ {
83
+ request: {
84
+ open_timeout: timeout_options[:open_timeout] || 2,
85
+ timeout: timeout_options[:timeout] || 5,
86
+ }
87
+ }
88
+ end
89
+
78
90
  def client_options
79
91
  options.select { |k, _| Faraday::ConnectionOptions.members.include?(k) }
80
92
  end
@@ -95,7 +107,7 @@ module PayPoint
95
107
  end
96
108
  f.response :json, content_type: /\bjson$/
97
109
  if options[:logger] || options[:log]
98
- f.response :logger, options[:logger]
110
+ f.response :logger, options[:logger], { headers: true, bodies: true }
99
111
  end
100
112
 
101
113
  # This sends all API traffic through Runscope, including
@@ -5,8 +5,8 @@ require "paypoint/blue/base"
5
5
  # Client class for the Hosted product.
6
6
  class PayPoint::Blue::Hosted < PayPoint::Blue::Base
7
7
  ENDPOINTS = {
8
- test: "https://hosted.mite.paypoint.net/hosted/rest",
9
- live: "https://hosted.paypoint.net/hosted/rest",
8
+ test: "https://api.mite.pay360.com/hosted/rest",
9
+ live: "https://api.pay360.com/hosted/rest",
10
10
  }.freeze
11
11
 
12
12
  shortcut :merchant_ref, "transaction.merchant_reference"
@@ -21,6 +21,7 @@ class PayPoint::Blue::Hosted < PayPoint::Blue::Base
21
21
  shortcut :restore_url, "session.restore_url.url"
22
22
  shortcut :skin, "session.skin"
23
23
  shortcut :payment_method_registration, "features.payment_method_registration"
24
+ shortcut :customer_registration, "customer.registered"
24
25
 
25
26
  shortcut :pre_auth_callback, "session.pre_auth_callback.url"
26
27
  shortcut :post_auth_callback, "session.post_auth_callback.url"
@@ -64,7 +65,7 @@ class PayPoint::Blue::Hosted < PayPoint::Blue::Base
64
65
  #
65
66
  # @applies_defaults
66
67
  # +:currency+, +:commerce_type+, +:return_url+, +:cancel_url+,
67
- # +:restore_url+, +:skin+, +:payment_method_registration+,
68
+ # +:restore_url+, +:skin+,
68
69
  # +:pre_auth_callback+, +:post_auth_callback+, +:transaction_notification+
69
70
  #
70
71
  # @param [Hash] payload the payload is made up of the keyword
@@ -74,8 +75,8 @@ class PayPoint::Blue::Hosted < PayPoint::Blue::Base
74
75
  def make_payment(**payload)
75
76
  payload = build_payload payload, defaults: %i(
76
77
  currency commerce_type return_url cancel_url restore_url skin
77
- payment_method_registration pre_auth_callback post_auth_callback
78
- transaction_notification
78
+ pre_auth_callback post_auth_callback
79
+ transaction_notification customer_registration
79
80
  )
80
81
  client.post "sessions/#{inst_id}/payments", build_payload(payload)
81
82
  end
@@ -132,4 +133,72 @@ class PayPoint::Blue::Hosted < PayPoint::Blue::Base
132
133
  payload = build_payload payload, defaults: %i(skin)
133
134
  client.post "sessions/#{inst_id}/cards", build_payload(payload)
134
135
  end
136
+
137
+ # Retrieve list of available skins
138
+ #
139
+ # @api_url https://paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
140
+ #
141
+ # @return the API response
142
+ def skins
143
+ client.get "skins/#{inst_id}/list"
144
+ end
145
+
146
+ # Download a skin
147
+ #
148
+ # @api_url https://paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
149
+ #
150
+ # @param [String] skin_id the id of the skin
151
+ # @param [String] path the path to download the skin (optional)
152
+ #
153
+ # @return a zip file
154
+ def download_skin(skin_id, path = nil)
155
+ path ||= "."
156
+ response = client.get "skins/#{skin_id}"
157
+ File.open("#{File.expand_path(path)}/#{skin_id}.zip", "wb") do |file|
158
+ file.write(Base64.decode64(response))
159
+ end
160
+ end
161
+
162
+ # Upload a new skin
163
+ #
164
+ # @api_url https://paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
165
+ #
166
+ # @param [String] file the zip file with path
167
+ # @param [Hash] params request parameters placed in the url,
168
+ # name: the name of the skin (required)
169
+ # description: description for the skin (optional)
170
+ #
171
+ # @return the API response
172
+ def upload_skin(file, name:, **params)
173
+ client.post do |request|
174
+ request.url "skins/#{inst_id}/create", params.merge(name: name)
175
+ request.headers["Content-Type"] = "application/zip"
176
+ request.body = File.read(file)
177
+ end
178
+ end
179
+
180
+ # Replace a skin
181
+ #
182
+ # Update the skin by uploading a new zip file.
183
+ # The method may also be used to update only the name and description of
184
+ # an existing skin.
185
+ #
186
+ # @api_url https://paymentdeveloperdocs.com/customise-_look_and_feel/manage-hosted-cashier-skins/
187
+ #
188
+ # @param [String] skin_id the id of the skin
189
+ # @param [Hash] arguments of the skin to update
190
+ # file: the zip file with path (optional)
191
+ # name: new name for the skin (optional)
192
+ # description: description for the skin (optional)
193
+ #
194
+ # @return the API response
195
+ def replace_skin(skin_id, file: nil, **params)
196
+ client.put do |request|
197
+ request.url "skins/#{skin_id}", params
198
+ if file
199
+ request.headers["Content-Type"] = "application/zip"
200
+ request.body = File.read(file)
201
+ end
202
+ end
203
+ end
135
204
  end
@@ -1,5 +1,5 @@
1
1
  module PayPoint
2
- module Blue # rubocop:disable Documentation
3
- VERSION = "0.6.0"
2
+ module Blue
3
+ VERSION = "1.0.3".freeze
4
4
  end
5
5
  end
@@ -23,8 +23,8 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency "faraday_middleware"
24
24
  spec.add_dependency "hashie"
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.8"
27
- spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "bundler", "~> 2.1"
27
+ spec.add_development_dependency "rake", "~> 13.0.3"
28
28
  spec.add_development_dependency "webmock"
29
29
  spec.add_development_dependency "guard"
30
30
  spec.add_development_dependency "guard-minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paypoint-blue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laszlo Bacsi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-15 00:00:00.000000000 Z
11
+ date: 2021-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.8'
61
+ version: '2.1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.8'
68
+ version: '2.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: 13.0.3
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: 13.0.3
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -202,10 +202,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
202
202
  - !ruby/object:Gem::Version
203
203
  version: '0'
204
204
  requirements: []
205
- rubyforge_project:
206
- rubygems_version: 2.4.5
205
+ rubygems_version: 3.1.3
207
206
  signing_key:
208
207
  specification_version: 4
209
208
  summary: API client for PayPoint Blue
210
209
  test_files: []
211
- has_rdoc: