blockchyp 2.9.3 → 2.9.6
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/Makefile +8 -1
- data/README.md +2605 -477
- data/lib/blockchyp/version.rb +1 -1
- data/lib/blockchyp.rb +242 -3
- data/lib/blockchyp_client.rb +80 -0
- data/test/activate_terminal_test.rb +45 -0
- data/test/add_test_merchant_test.rb +56 -0
- data/test/batch_history_test.rb +10 -6
- data/test/boolean_prompt_test.rb +12 -6
- data/test/cancel_payment_link_test.rb +72 -0
- data/test/capture_signature_test.rb +12 -6
- data/test/deactivate_terminal_test.rb +42 -0
- data/test/delete_branding_asset_test.rb +50 -0
- data/test/delete_customer_test.rb +55 -0
- data/test/delete_media_asset_test.rb +53 -0
- data/test/delete_queued_transaction_test.rb +56 -0
- data/test/delete_slide_show_test.rb +50 -0
- data/test/delete_survey_question_test.rb +51 -0
- data/test/delete_test_merchant_test.rb +59 -0
- data/test/delete_token_test.rb +55 -0
- data/test/empty_branding_asset_test.rb +44 -0
- data/test/empty_slide_show_test.rb +45 -0
- data/test/gateway_timeout_test.rb +11 -4
- data/test/get_customer_test.rb +10 -6
- data/test/get_merchants_test.rb +52 -0
- data/test/invite_merchant_user_test.rb +45 -0
- data/test/link_token_test.rb +56 -0
- data/test/list_queued_transactions_test.rb +55 -0
- data/test/list_terminals_test.rb +42 -0
- data/test/media_asset_test.rb +57 -0
- data/test/media_test.rb +42 -0
- data/test/media_upload_test.rb +52 -0
- data/test/merchant_platforms_test.rb +59 -0
- data/test/merchant_profile_test.rb +10 -5
- data/test/merchant_users_test.rb +42 -0
- data/test/new_transaction_display_test.rb +12 -6
- data/test/pan_charge_test.rb +11 -5
- data/test/pan_enroll_test.rb +17 -6
- data/test/pan_preauth_test.rb +11 -5
- data/test/partial_refund_test.rb +11 -6
- data/test/search_customer_test.rb +10 -6
- data/test/send_payment_link_test.rb +11 -6
- data/test/simple_batch_close_test.rb +10 -6
- data/test/simple_capture_test.rb +10 -6
- data/test/simple_gift_activate_test.rb +12 -6
- data/test/simple_locate_test.rb +44 -0
- data/test/simple_message_test.rb +12 -6
- data/test/simple_ping_test.rb +12 -6
- data/test/simple_refund_test.rb +11 -6
- data/test/simple_reversal_test.rb +10 -6
- data/test/simple_void_test.rb +10 -6
- data/test/slide_show_test.rb +51 -0
- data/test/slide_shows_test.rb +49 -0
- data/test/survey_question_test.rb +48 -0
- data/test/survey_questions_test.rb +50 -0
- data/test/survey_results_test.rb +48 -0
- data/test/tc_delete_template_test.rb +51 -0
- data/test/tc_entry_test.rb +56 -0
- data/test/tc_log_test.rb +42 -0
- data/test/tc_template_test.rb +53 -0
- data/test/tc_template_update_test.rb +48 -0
- data/test/tc_templates_test.rb +42 -0
- data/test/terminal_branding_test.rb +42 -0
- data/test/terminal_charge_test.rb +12 -6
- data/test/terminal_clear_test.rb +12 -6
- data/test/terminal_ebt_balance_test.rb +12 -6
- data/test/terminal_ebt_charge_test.rb +12 -6
- data/test/terminal_enroll_test.rb +12 -6
- data/test/terminal_gift_card_balance_test.rb +12 -6
- data/test/terminal_keyed_charge_test.rb +12 -6
- data/test/terminal_manual_ebt_charge_test.rb +12 -6
- data/test/terminal_preauth_test.rb +12 -6
- data/test/terminal_queued_transaction_test.rb +51 -0
- data/test/terminal_status_test.rb +12 -6
- data/test/terminal_timeout_test.rb +12 -5
- data/test/terms_and_conditions_test.rb +12 -6
- data/test/test_helper.rb +2 -4
- data/test/testdata/aviato.png +0 -0
- data/test/text_prompt_test.rb +12 -6
- data/test/token_metadata_test.rb +55 -0
- data/test/transaction_history_test.rb +10 -6
- data/test/unlink_token_test.rb +56 -0
- data/test/update_branding_asset_test.rb +62 -0
- data/test/update_customer_test.rb +10 -5
- data/test/update_merchant_platforms_test.rb +61 -0
- data/test/update_merchant_test.rb +60 -0
- data/test/update_slide_show_test.rb +60 -0
- data/test/update_survey_question_test.rb +47 -0
- data/test/update_transaction_display_test.rb +12 -6
- data/test/upload_status_test.rb +53 -0
- metadata +49 -2
data/lib/blockchyp/version.rb
CHANGED
data/lib/blockchyp.rb
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
4
|
# governed by a license that can be found in the LICENSE file.
|
|
5
5
|
#
|
|
6
|
-
# This file was generated automatically
|
|
7
|
-
# every time the code is regenerated.
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
8
|
|
|
9
9
|
require_relative 'blockchyp_client'
|
|
10
10
|
|
|
@@ -13,6 +13,7 @@ module CardType
|
|
|
13
13
|
DEBIT = 1
|
|
14
14
|
EBT = 2
|
|
15
15
|
BLOCKCHAIN_GIFT = 3
|
|
16
|
+
HEALTHCARE = 4
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
module SignatureFormat
|
|
@@ -50,6 +51,14 @@ module CVMType
|
|
|
50
51
|
NO_CVM = 'No CVM'
|
|
51
52
|
end
|
|
52
53
|
|
|
54
|
+
module HealthcareType
|
|
55
|
+
HEALTHCARE = 'healthcare'
|
|
56
|
+
PRESCRIPTION = 'prescription'
|
|
57
|
+
VISION = 'vision'
|
|
58
|
+
CLINIC = 'clinic'
|
|
59
|
+
DENTAL = 'dental'
|
|
60
|
+
end
|
|
61
|
+
|
|
53
62
|
module BlockChyp
|
|
54
63
|
# the main autogenerated blockchyp client
|
|
55
64
|
class BlockChyp < BlockChypClient
|
|
@@ -139,7 +148,27 @@ module BlockChyp
|
|
|
139
148
|
def text_prompt(request)
|
|
140
149
|
route_terminal_request('POST', '/api/text-prompt', '/api/text-prompt', request)
|
|
141
150
|
end
|
|
151
|
+
|
|
152
|
+
# Returns a list of queued transactions on a terminal.
|
|
153
|
+
def list_queued_transactions(request)
|
|
154
|
+
route_terminal_request('POST', '/api/queue/list', '/api/queue/list', request)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Deletes a queued transaction from the terminal.
|
|
158
|
+
def delete_queued_transaction(request)
|
|
159
|
+
route_terminal_request('POST', '/api/queue/delete', '/api/queue/delete', request)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Reboot a payment terminal.
|
|
163
|
+
def reboot(request)
|
|
164
|
+
route_terminal_request('POST', '/api/reboot', '/api/terminal-reboot', request)
|
|
165
|
+
end
|
|
142
166
|
|
|
167
|
+
# Returns routing and location data for a payment terminal.
|
|
168
|
+
def locate(request)
|
|
169
|
+
gateway_request('POST', '/api/terminal-locate', request)
|
|
170
|
+
end
|
|
171
|
+
|
|
143
172
|
# Captures a preauthorization.
|
|
144
173
|
def capture(request)
|
|
145
174
|
gateway_request('POST', '/api/capture', request)
|
|
@@ -174,6 +203,11 @@ module BlockChyp
|
|
|
174
203
|
gateway_request('POST', '/api/send-payment-link', request)
|
|
175
204
|
end
|
|
176
205
|
|
|
206
|
+
# Cancels a payment link.
|
|
207
|
+
def cancel_payment_link(request)
|
|
208
|
+
gateway_request('POST', '/api/cancel-payment-link', request)
|
|
209
|
+
end
|
|
210
|
+
|
|
177
211
|
# Retrieves the current status of a transaction.
|
|
178
212
|
def transaction_status(request)
|
|
179
213
|
gateway_request('POST', '/api/tx-status', request)
|
|
@@ -219,5 +253,210 @@ module BlockChyp
|
|
|
219
253
|
gateway_request('POST', '/api/public-merchant-profile', request)
|
|
220
254
|
end
|
|
221
255
|
|
|
256
|
+
# Deletes a customer record.
|
|
257
|
+
def delete_customer(request)
|
|
258
|
+
gateway_request('DELETE', '/api/customer/' + request[:customerId], request)
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Retrieves payment token metadata.
|
|
262
|
+
def token_metadata(request)
|
|
263
|
+
gateway_request('GET', '/api/token/' + request[:token], request)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Links a token to a customer record.
|
|
267
|
+
def link_token(request)
|
|
268
|
+
gateway_request('POST', '/api/link-token', request)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
# Removes a link between a customer and a token.
|
|
272
|
+
def unlink_token(request)
|
|
273
|
+
gateway_request('POST', '/api/unlink-token', request)
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Deletes a payment token.
|
|
277
|
+
def delete_token(request)
|
|
278
|
+
gateway_request('DELETE', '/api/token/' + request[:token], request)
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
# Adds a test merchant account.
|
|
283
|
+
def get_merchants(request)
|
|
284
|
+
dashboard_request('POST', '/api/get-merchants', request)
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
# Adds or updates a merchant account. Can be used to create or update test
|
|
288
|
+
# merchants. Only gateway partners may create new live merchants.
|
|
289
|
+
def update_merchant(request)
|
|
290
|
+
dashboard_request('POST', '/api/update-merchant', request)
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
# List all active users and pending invites for a merchant account.
|
|
294
|
+
def merchant_users(request)
|
|
295
|
+
dashboard_request('POST', '/api/merchant-users', request)
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
# Invites a user to join a merchant account.
|
|
299
|
+
def invite_merchant_user(request)
|
|
300
|
+
dashboard_request('POST', '/api/invite-merchant-user', request)
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
# Adds a test merchant account.
|
|
304
|
+
def add_test_merchant(request)
|
|
305
|
+
dashboard_request('POST', '/api/add-test-merchant', request)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# Deletes a test merchant account. Supports partner scoped API credentials
|
|
309
|
+
# only. Live merchant accounts cannot be deleted.
|
|
310
|
+
def delete_test_merchant(request)
|
|
311
|
+
dashboard_request('DELETE', '/api/test-merchant/' + request[:merchantId], request)
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
# List all merchant platforms configured for a gateway merchant.
|
|
315
|
+
def merchant_platforms(request)
|
|
316
|
+
dashboard_request('GET', '/api/plugin-configs/' + request[:merchantId], request)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# List all merchant platforms configured for a gateway merchant.
|
|
320
|
+
def update_merchant_platforms(request)
|
|
321
|
+
dashboard_request('POST', '/api/plugin-configs', request)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
# Deletes a boarding platform configuration.
|
|
325
|
+
def delete_merchant_platforms(request)
|
|
326
|
+
dashboard_request('DELETE', '/api/plugin-config/' + request[:platformId], request)
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
# Returns all terminals associated with the merchant account.
|
|
330
|
+
def terminals(request)
|
|
331
|
+
dashboard_request('GET', '/api/terminals', request)
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# Deactivates a terminal.
|
|
335
|
+
def deactivate_terminal(request)
|
|
336
|
+
dashboard_request('DELETE', '/api/terminal/' + request[:terminalId], request)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Activates a terminal.
|
|
340
|
+
def activate_terminal(request)
|
|
341
|
+
dashboard_request('POST', '/api/terminal-activate', request)
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Returns a list of terms and conditions templates associated with a
|
|
345
|
+
# merchant account.
|
|
346
|
+
def tc_templates(request)
|
|
347
|
+
dashboard_request('GET', '/api/tc-templates', request)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
# Returns a single terms and conditions template.
|
|
351
|
+
def tc_template(request)
|
|
352
|
+
dashboard_request('GET', '/api/tc-templates/' + request[:templateId], request)
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Updates or creates a terms and conditions template.
|
|
356
|
+
def tc_update_template(request)
|
|
357
|
+
dashboard_request('POST', '/api/tc-templates', request)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Deletes a single terms and conditions template.
|
|
361
|
+
def tc_delete_template(request)
|
|
362
|
+
dashboard_request('DELETE', '/api/tc-templates/' + request[:templateId], request)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
# Returns up to 250 entries from the Terms and Conditions log.
|
|
366
|
+
def tc_log(request)
|
|
367
|
+
dashboard_request('POST', '/api/tc-log', request)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# Returns a single detailed Terms and Conditions entry.
|
|
371
|
+
def tc_entry(request)
|
|
372
|
+
dashboard_request('GET', '/api/tc-entry/' + request[:logEntryId], request)
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
# Returns all survey questions for a given merchant.
|
|
376
|
+
def survey_questions(request)
|
|
377
|
+
dashboard_request('GET', '/api/survey-questions', request)
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
# Returns a single survey question with response data.
|
|
381
|
+
def survey_question(request)
|
|
382
|
+
dashboard_request('GET', '/api/survey-questions/' + request[:questionId], request)
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# Updates or creates a survey question.
|
|
386
|
+
def update_survey_question(request)
|
|
387
|
+
dashboard_request('POST', '/api/survey-questions', request)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
# Deletes a survey question.
|
|
391
|
+
def delete_survey_question(request)
|
|
392
|
+
dashboard_request('DELETE', '/api/survey-questions/' + request[:questionId], request)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Returns results for a single survey question.
|
|
396
|
+
def survey_results(request)
|
|
397
|
+
dashboard_request('POST', '/api/survey-results', request)
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
# Returns the media library for a given partner, merchant, or
|
|
401
|
+
# organization.
|
|
402
|
+
def media(request)
|
|
403
|
+
dashboard_request('GET', '/api/media', request)
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
# Uploads a media asset to the media library.
|
|
407
|
+
def upload_media(request, file)
|
|
408
|
+
upload_request('/api/upload-media', request, file)
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
# Retrieves the current status of a file upload.
|
|
412
|
+
def upload_status(request)
|
|
413
|
+
dashboard_request('GET', '/api/media-upload/' + request[:uploadId], request)
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
# Returns the media details for a single media asset.
|
|
417
|
+
def media_asset(request)
|
|
418
|
+
dashboard_request('GET', '/api/media/' + request[:mediaId], request)
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
# Deletes a media asset.
|
|
422
|
+
def delete_media_asset(request)
|
|
423
|
+
dashboard_request('DELETE', '/api/media/' + request[:mediaId], request)
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
# Returns a collection of slide shows.
|
|
427
|
+
def slide_shows(request)
|
|
428
|
+
dashboard_request('GET', '/api/slide-shows', request)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
# Returns a single slide show with slides.
|
|
432
|
+
def slide_show(request)
|
|
433
|
+
dashboard_request('GET', '/api/slide-shows/' + request[:slideShowId], request)
|
|
434
|
+
end
|
|
435
|
+
|
|
436
|
+
# Updates or creates a slide show.
|
|
437
|
+
def update_slide_show(request)
|
|
438
|
+
dashboard_request('POST', '/api/slide-shows', request)
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
# Deletes a single slide show.
|
|
442
|
+
def delete_slide_show(request)
|
|
443
|
+
dashboard_request('DELETE', '/api/slide-shows/' + request[:slideShowId], request)
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
# Returns the terminal branding stack for a given set of API credentials.
|
|
447
|
+
def terminal_branding(request)
|
|
448
|
+
dashboard_request('GET', '/api/terminal-branding', request)
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
# Updates a branding asset.
|
|
452
|
+
def update_branding_asset(request)
|
|
453
|
+
dashboard_request('POST', '/api/terminal-branding', request)
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
# Deletes a branding asset.
|
|
457
|
+
def delete_branding_asset(request)
|
|
458
|
+
dashboard_request('DELETE', '/api/terminal-branding/' + request[:assetId], request)
|
|
459
|
+
end
|
|
460
|
+
|
|
222
461
|
end
|
|
223
462
|
end
|
data/lib/blockchyp_client.rb
CHANGED
|
@@ -21,6 +21,7 @@ module BlockChyp
|
|
|
21
21
|
@signing_key = signing_key
|
|
22
22
|
@gateway_host = 'https://api.blockchyp.com'
|
|
23
23
|
@test_gateway_host = 'https://test.blockchyp.com'
|
|
24
|
+
@dashboard_host = 'https://dashboard.blockchyp.com'
|
|
24
25
|
@https = false
|
|
25
26
|
@route_cache_location = File.join(Dir.tmpdir, '.blockchyp_route')
|
|
26
27
|
@route_cache_ttl = 60
|
|
@@ -38,6 +39,7 @@ module BlockChyp
|
|
|
38
39
|
attr_reader :offline_fixed_key
|
|
39
40
|
attr_accessor :gateway_host
|
|
40
41
|
attr_accessor :test_gateway_host
|
|
42
|
+
attr_accessor :dashboard_host
|
|
41
43
|
attr_accessor :https
|
|
42
44
|
attr_accessor :route_cache_ttl
|
|
43
45
|
attr_accessor :gateway_timeout
|
|
@@ -72,6 +74,10 @@ module BlockChyp
|
|
|
72
74
|
URI.parse(path.nil? ? url : url + path)
|
|
73
75
|
end
|
|
74
76
|
|
|
77
|
+
def resolve_dashboard_uri(path, request)
|
|
78
|
+
URI.parse(dashboard_host + path)
|
|
79
|
+
end
|
|
80
|
+
|
|
75
81
|
def generate_error_response(msg)
|
|
76
82
|
{
|
|
77
83
|
success: false,
|
|
@@ -145,6 +151,8 @@ module BlockChyp
|
|
|
145
151
|
Net::HTTP::Put.new(uri.request_uri)
|
|
146
152
|
when 'POST'
|
|
147
153
|
Net::HTTP::Post.new(uri.request_uri)
|
|
154
|
+
when 'DELETE'
|
|
155
|
+
Net::HTTP::Delete.new(uri.request_uri)
|
|
148
156
|
end
|
|
149
157
|
end
|
|
150
158
|
|
|
@@ -163,6 +171,78 @@ module BlockChyp
|
|
|
163
171
|
URI.parse(url + port + path)
|
|
164
172
|
end
|
|
165
173
|
|
|
174
|
+
def dashboard_request(method, path, request = nil)
|
|
175
|
+
uri = resolve_dashboard_uri(path, request)
|
|
176
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
177
|
+
http.use_ssl = uri.instance_of?(URI::HTTPS)
|
|
178
|
+
timeout = get_timeout(request, gateway_timeout)
|
|
179
|
+
http.open_timeout = timeout
|
|
180
|
+
http.read_timeout = timeout
|
|
181
|
+
|
|
182
|
+
req = get_http_request(method, uri)
|
|
183
|
+
|
|
184
|
+
req['User-Agent'] = user_agent
|
|
185
|
+
unless request.nil?
|
|
186
|
+
json = request.to_json
|
|
187
|
+
req['Content-Type'] = 'application/json'
|
|
188
|
+
req['Content-Length'] = json.length
|
|
189
|
+
req.body = json
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
headers = generate_gateway_headers
|
|
193
|
+
headers.each do |key, value|
|
|
194
|
+
req[key] = value
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
response = http.request(req)
|
|
198
|
+
|
|
199
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
200
|
+
JSON.parse(response.body, symbolize_names: true)
|
|
201
|
+
else
|
|
202
|
+
raise response.message
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def upload_request(path, request, content)
|
|
207
|
+
uri = resolve_dashboard_uri(path, request)
|
|
208
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
209
|
+
http.use_ssl = uri.instance_of?(URI::HTTPS)
|
|
210
|
+
timeout = get_timeout(request, gateway_timeout)
|
|
211
|
+
http.open_timeout = timeout
|
|
212
|
+
http.read_timeout = timeout
|
|
213
|
+
|
|
214
|
+
req = get_http_request("POST", uri)
|
|
215
|
+
req.body = content
|
|
216
|
+
req['User-Agent'] = user_agent
|
|
217
|
+
req['Content-Type'] = 'application/octet-stream'
|
|
218
|
+
|
|
219
|
+
if request[:fileName]
|
|
220
|
+
req['X-Upload-File-Name'] = request[:fileName]
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
if request[:uploadId]
|
|
224
|
+
req['X-Upload-ID'] = request[:uploadId]
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
if request[:fileSize]
|
|
228
|
+
req['X-File-Size'] = request[:fileSize]
|
|
229
|
+
req['Content-Length'] = request[:fileSize]
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
headers = generate_gateway_headers
|
|
233
|
+
headers.each do |key, value|
|
|
234
|
+
req[key] = value
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
response = http.request(req)
|
|
238
|
+
|
|
239
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
240
|
+
JSON.parse(response.body, symbolize_names: true)
|
|
241
|
+
else
|
|
242
|
+
raise response.message
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
|
|
166
246
|
def gateway_request(method, path, request = nil, relay = false)
|
|
167
247
|
uri = resolve_gateway_uri(path, request)
|
|
168
248
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
|
+
# governed by a license that can be found in the LICENSE file.
|
|
5
|
+
#
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
|
+
|
|
9
|
+
require ::File.expand_path('test_helper', __dir__)
|
|
10
|
+
|
|
11
|
+
module BlockChyp
|
|
12
|
+
class ActivateTerminalTest < TestCase
|
|
13
|
+
def test_activate_terminal
|
|
14
|
+
|
|
15
|
+
puts "Running test_activate_terminal..."
|
|
16
|
+
|
|
17
|
+
config = load_test_config
|
|
18
|
+
|
|
19
|
+
blockchyp = BlockChyp.new(
|
|
20
|
+
config[:apiKey],
|
|
21
|
+
config[:bearerToken],
|
|
22
|
+
config[:signingKey]
|
|
23
|
+
)
|
|
24
|
+
blockchyp.gateway_host = config[:gatewayHost]
|
|
25
|
+
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
26
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Set request parameters
|
|
33
|
+
request = {
|
|
34
|
+
terminalName: 'Bad Terminal Code',
|
|
35
|
+
activationCode: 'XXXXXX'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
response = blockchyp.activate_terminal(request)
|
|
39
|
+
assert_not_nil(response)
|
|
40
|
+
# response assertions
|
|
41
|
+
assert(!response[:success])
|
|
42
|
+
assert_equal('Invalid Activation Code', response[:error])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
|
+
# governed by a license that can be found in the LICENSE file.
|
|
5
|
+
#
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
|
+
|
|
9
|
+
require ::File.expand_path('test_helper', __dir__)
|
|
10
|
+
|
|
11
|
+
module BlockChyp
|
|
12
|
+
class AddTestMerchantTest < TestCase
|
|
13
|
+
def test_add_test_merchant
|
|
14
|
+
|
|
15
|
+
puts "Running test_add_test_merchant..."
|
|
16
|
+
|
|
17
|
+
config = load_test_config
|
|
18
|
+
|
|
19
|
+
blockchyp = BlockChyp.new(
|
|
20
|
+
config[:apiKey],
|
|
21
|
+
config[:bearerToken],
|
|
22
|
+
config[:signingKey]
|
|
23
|
+
)
|
|
24
|
+
blockchyp.gateway_host = config[:gatewayHost]
|
|
25
|
+
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
26
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
profile = config[:profiles][:partner]
|
|
30
|
+
blockchyp = BlockChyp.new(
|
|
31
|
+
profile[:apiKey],
|
|
32
|
+
profile[:bearerToken],
|
|
33
|
+
profile[:signingKey]
|
|
34
|
+
)
|
|
35
|
+
blockchyp.gateway_host = config[:gatewayHost]
|
|
36
|
+
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
37
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# Set request parameters
|
|
42
|
+
request = {
|
|
43
|
+
dbaName: 'Test Merchant',
|
|
44
|
+
companyName: 'Test Merchant'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
response = blockchyp.add_test_merchant(request)
|
|
48
|
+
assert_not_nil(response)
|
|
49
|
+
# response assertions
|
|
50
|
+
assert(response[:success])
|
|
51
|
+
assert_equal('Test Merchant', response[:dbaName])
|
|
52
|
+
assert_equal('Test Merchant', response[:companyName])
|
|
53
|
+
assert(response[:visa])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
data/test/batch_history_test.rb
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
4
|
# governed by a license that can be found in the LICENSE file.
|
|
5
5
|
#
|
|
6
|
-
# This file was generated automatically
|
|
7
|
-
# every time the code is regenerated.
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
8
|
|
|
9
9
|
require ::File.expand_path('test_helper', __dir__)
|
|
10
10
|
|
|
11
11
|
module BlockChyp
|
|
12
12
|
class BatchHistoryTest < TestCase
|
|
13
13
|
def test_batch_history
|
|
14
|
+
|
|
15
|
+
puts "Running test_batch_history..."
|
|
16
|
+
|
|
14
17
|
config = load_test_config
|
|
15
18
|
|
|
16
19
|
blockchyp = BlockChyp.new(
|
|
@@ -20,8 +23,11 @@ module BlockChyp
|
|
|
20
23
|
)
|
|
21
24
|
blockchyp.gateway_host = config[:gatewayHost]
|
|
22
25
|
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
26
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
23
30
|
|
|
24
|
-
test_delay(blockchyp, 'batch_history_test')
|
|
25
31
|
|
|
26
32
|
# Set request parameters
|
|
27
33
|
setup_request = {
|
|
@@ -32,7 +38,6 @@ module BlockChyp
|
|
|
32
38
|
test: true,
|
|
33
39
|
transactionRef: uuid
|
|
34
40
|
}
|
|
35
|
-
|
|
36
41
|
response = blockchyp.charge(setup_request)
|
|
37
42
|
|
|
38
43
|
# Set request parameters
|
|
@@ -41,7 +46,6 @@ module BlockChyp
|
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
response = blockchyp.batch_history(request)
|
|
44
|
-
|
|
45
49
|
assert_not_nil(response)
|
|
46
50
|
# response assertions
|
|
47
51
|
assert(response[:success])
|
data/test/boolean_prompt_test.rb
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright 2019 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
4
|
# governed by a license that can be found in the LICENSE file.
|
|
5
5
|
#
|
|
6
|
-
# This file was generated automatically
|
|
7
|
-
# every time the code is regenerated.
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
8
|
|
|
9
9
|
require ::File.expand_path('test_helper', __dir__)
|
|
10
10
|
|
|
11
11
|
module BlockChyp
|
|
12
12
|
class BooleanPromptTest < TestCase
|
|
13
13
|
def test_boolean_prompt
|
|
14
|
+
|
|
15
|
+
puts "Running test_boolean_prompt..."
|
|
16
|
+
|
|
14
17
|
config = load_test_config
|
|
15
18
|
|
|
16
19
|
blockchyp = BlockChyp.new(
|
|
@@ -20,20 +23,23 @@ module BlockChyp
|
|
|
20
23
|
)
|
|
21
24
|
blockchyp.gateway_host = config[:gatewayHost]
|
|
22
25
|
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
26
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
27
|
+
|
|
28
|
+
test_delay(blockchyp, 'boolean_prompt_test', config[:defaultTerminalName])
|
|
29
|
+
|
|
30
|
+
|
|
23
31
|
|
|
24
|
-
test_delay(blockchyp, 'boolean_prompt_test')
|
|
25
32
|
|
|
26
33
|
# Set request parameters
|
|
27
34
|
request = {
|
|
28
35
|
test: true,
|
|
29
|
-
terminalName:
|
|
36
|
+
terminalName: config[:defaultTerminalName],
|
|
30
37
|
prompt: 'Would you like to become a member?',
|
|
31
38
|
yesCaption: 'Yes',
|
|
32
39
|
noCaption: 'No'
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
response = blockchyp.boolean_prompt(request)
|
|
36
|
-
|
|
37
43
|
assert_not_nil(response)
|
|
38
44
|
# response assertions
|
|
39
45
|
assert(response[:success])
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright 2019-2022 BlockChyp, Inc. All rights reserved. Use of this code is
|
|
4
|
+
# governed by a license that can be found in the LICENSE file.
|
|
5
|
+
#
|
|
6
|
+
# This file was generated automatically by the BlockChyp SDK Generator.
|
|
7
|
+
# Changes to this file will be lost every time the code is regenerated.
|
|
8
|
+
|
|
9
|
+
require ::File.expand_path('test_helper', __dir__)
|
|
10
|
+
|
|
11
|
+
module BlockChyp
|
|
12
|
+
class CancelPaymentLinkTest < TestCase
|
|
13
|
+
def test_cancel_payment_link
|
|
14
|
+
|
|
15
|
+
puts "Running test_cancel_payment_link..."
|
|
16
|
+
|
|
17
|
+
config = load_test_config
|
|
18
|
+
|
|
19
|
+
blockchyp = BlockChyp.new(
|
|
20
|
+
config[:apiKey],
|
|
21
|
+
config[:bearerToken],
|
|
22
|
+
config[:signingKey]
|
|
23
|
+
)
|
|
24
|
+
blockchyp.gateway_host = config[:gatewayHost]
|
|
25
|
+
blockchyp.test_gateway_host = config[:testGatewayHost]
|
|
26
|
+
blockchyp.dashboard_host = config[:dashboardHost]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Set request parameters
|
|
33
|
+
setup_request = {
|
|
34
|
+
amount: '199.99',
|
|
35
|
+
description: 'Widget',
|
|
36
|
+
subject: 'Widget invoice',
|
|
37
|
+
transaction: {
|
|
38
|
+
subtotal: '195.00',
|
|
39
|
+
tax: '4.99',
|
|
40
|
+
total: '199.99',
|
|
41
|
+
items: [
|
|
42
|
+
{
|
|
43
|
+
description: 'Widget',
|
|
44
|
+
price: '195.00',
|
|
45
|
+
quantity: 1
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
autoSend: true,
|
|
50
|
+
customer: {
|
|
51
|
+
customerRef: 'Customer reference string',
|
|
52
|
+
firstName: 'FirstName',
|
|
53
|
+
lastName: 'LastName',
|
|
54
|
+
companyName: 'Company Name',
|
|
55
|
+
emailAddress: 'notifications@blockchypteam.m8r.co',
|
|
56
|
+
smsNumber: '(123) 123-1231'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
response = blockchyp.send_payment_link(setup_request)
|
|
60
|
+
|
|
61
|
+
# Set request parameters
|
|
62
|
+
request = {
|
|
63
|
+
linkCode: response[:linkCode]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
response = blockchyp.cancel_payment_link(request)
|
|
67
|
+
assert_not_nil(response)
|
|
68
|
+
# response assertions
|
|
69
|
+
assert(response[:success])
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|