blockchyp 1.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/Makefile +78 -0
  3. data/README.md +4023 -0
  4. data/Rakefile +39 -0
  5. data/lib/blockchyp/version.rb +5 -0
  6. data/lib/blockchyp.rb +478 -0
  7. data/lib/blockchyp_client.rb +416 -0
  8. data/lib/crypto_utils.rb +25 -0
  9. data/test/activate_terminal_test.rb +45 -0
  10. data/test/add_test_merchant_test.rb +56 -0
  11. data/test/batch_history_test.rb +54 -0
  12. data/test/boolean_prompt_test.rb +49 -0
  13. data/test/cancel_payment_link_test.rb +72 -0
  14. data/test/capture_signature_test.rb +46 -0
  15. data/test/deactivate_terminal_test.rb +42 -0
  16. data/test/delete_branding_asset_test.rb +50 -0
  17. data/test/delete_customer_test.rb +55 -0
  18. data/test/delete_media_asset_test.rb +53 -0
  19. data/test/delete_queued_transaction_test.rb +56 -0
  20. data/test/delete_slide_show_test.rb +50 -0
  21. data/test/delete_survey_question_test.rb +51 -0
  22. data/test/delete_test_merchant_test.rb +59 -0
  23. data/test/delete_token_test.rb +55 -0
  24. data/test/empty_branding_asset_test.rb +44 -0
  25. data/test/empty_slide_show_test.rb +45 -0
  26. data/test/gateway_timeout_test.rb +49 -0
  27. data/test/get_customer_test.rb +55 -0
  28. data/test/get_merchants_test.rb +52 -0
  29. data/test/heartbeat_test.rb +27 -0
  30. data/test/invite_merchant_user_test.rb +45 -0
  31. data/test/link_token_test.rb +56 -0
  32. data/test/list_queued_transactions_test.rb +55 -0
  33. data/test/list_terminals_test.rb +42 -0
  34. data/test/media_asset_test.rb +57 -0
  35. data/test/media_test.rb +42 -0
  36. data/test/media_upload_test.rb +52 -0
  37. data/test/merchant_platforms_test.rb +59 -0
  38. data/test/merchant_profile_test.rb +43 -0
  39. data/test/merchant_users_test.rb +42 -0
  40. data/test/new_transaction_display_test.rb +64 -0
  41. data/test/pan_charge_test.rb +61 -0
  42. data/test/pan_enroll_test.rb +62 -0
  43. data/test/pan_preauth_test.rb +60 -0
  44. data/test/partial_refund_test.rb +58 -0
  45. data/test/payment_link_status_test.rb +72 -0
  46. data/test/resend_payment_link_test.rb +49 -0
  47. data/test/search_customer_test.rb +55 -0
  48. data/test/send_payment_link_test.rb +67 -0
  49. data/test/simple_batch_close_test.rb +54 -0
  50. data/test/simple_capture_test.rb +55 -0
  51. data/test/simple_gift_activate_test.rb +48 -0
  52. data/test/simple_locate_test.rb +44 -0
  53. data/test/simple_message_test.rb +46 -0
  54. data/test/simple_ping_test.rb +45 -0
  55. data/test/simple_refund_test.rb +57 -0
  56. data/test/simple_reversal_test.rb +56 -0
  57. data/test/simple_void_test.rb +56 -0
  58. data/test/slide_show_test.rb +51 -0
  59. data/test/slide_shows_test.rb +49 -0
  60. data/test/survey_question_test.rb +48 -0
  61. data/test/survey_questions_test.rb +50 -0
  62. data/test/survey_results_test.rb +48 -0
  63. data/test/tc_delete_template_test.rb +51 -0
  64. data/test/tc_entry_test.rb +56 -0
  65. data/test/tc_log_test.rb +42 -0
  66. data/test/tc_template_test.rb +53 -0
  67. data/test/tc_template_update_test.rb +48 -0
  68. data/test/tc_templates_test.rb +42 -0
  69. data/test/terminal_branding_test.rb +42 -0
  70. data/test/terminal_charge_test.rb +57 -0
  71. data/test/terminal_clear_test.rb +45 -0
  72. data/test/terminal_ebt_balance_test.rb +47 -0
  73. data/test/terminal_ebt_charge_test.rb +59 -0
  74. data/test/terminal_enroll_test.rb +56 -0
  75. data/test/terminal_gift_card_balance_test.rb +46 -0
  76. data/test/terminal_keyed_charge_test.rb +58 -0
  77. data/test/terminal_manual_ebt_charge_test.rb +60 -0
  78. data/test/terminal_preauth_test.rb +57 -0
  79. data/test/terminal_queued_transaction_test.rb +51 -0
  80. data/test/terminal_status_test.rb +45 -0
  81. data/test/terminal_timeout_test.rb +46 -0
  82. data/test/terms_and_conditions_test.rb +50 -0
  83. data/test/test_helper.rb +64 -0
  84. data/test/testdata/aviato.png +0 -0
  85. data/test/text_prompt_test.rb +47 -0
  86. data/test/token_metadata_test.rb +55 -0
  87. data/test/transaction_history_test.rb +54 -0
  88. data/test/unlink_token_test.rb +56 -0
  89. data/test/update_branding_asset_test.rb +62 -0
  90. data/test/update_customer_test.rb +49 -0
  91. data/test/update_merchant_platforms_test.rb +61 -0
  92. data/test/update_merchant_test.rb +60 -0
  93. data/test/update_slide_show_test.rb +60 -0
  94. data/test/update_survey_question_test.rb +47 -0
  95. data/test/update_transaction_display_test.rb +64 -0
  96. data/test/upload_status_test.rb +53 -0
  97. metadata +138 -0
data/README.md ADDED
@@ -0,0 +1,4023 @@
1
+ # BlockChyp Ruby SDK
2
+
3
+ [![Build Status](https://github.com/blockchyp/blockchyp-ruby/actions/workflows/main.yml/badge.svg)](https://github.com/blockchyp/blockchyp-ruby/actions/workflows/main.yml)
4
+ [![Gem](https://img.shields.io/gem/v/blockchyp)](https://rubygems.org/gems/blockchyp)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/blockchyp/blockchyp-ruby/blob/master/LICENSE)
6
+
7
+ This is the SDK for Ruby. Like all BlockChyp SDKs, it provides a full client
8
+ for the BlockChyp gateway and BlockChyp payment terminals.
9
+
10
+ ## Installation
11
+
12
+ This SDK is best consumed as a Ruby Gem. Type the following command to install
13
+ the BlockChyp Gem in your project.
14
+
15
+ ```
16
+ gem install blockchyp
17
+ ```
18
+
19
+ ## A Simple Example
20
+
21
+ Running your first transaction is easy. Make sure you have a BlockChyp terminal,
22
+ activate it, and generate a set of API keys. The sample code below show how
23
+ to run a basic terminal transaction.
24
+
25
+ ```ruby
26
+ require 'blockchyp'
27
+
28
+ blockchyp = BlockChyp.new(
29
+ "SPBXTSDAQVFFX5MGQMUMIRINVI",
30
+ "7BXBTBUPSL3BP7I6Z2CFU6H3WQ",
31
+ "bcae3708938cb8004ab1278e6c0fcd68f9d815e1c3c86228d028242b147af58e"
32
+ )
33
+
34
+ # Set request parameters
35
+ request = {
36
+ "test": true,
37
+ "terminalName": "Test Terminal",
38
+ "amount": "55.00"
39
+ }
40
+
41
+ response = blockchyp.charge(request)
42
+
43
+ if (response["approved"])
44
+ puts "Approved"
45
+ puts "authCode:" + response["authCode"]
46
+ puts "authorizedAmount:" + response["authorizedAmount"]
47
+ end
48
+ ```
49
+
50
+
51
+
52
+ ## Additional Documentation
53
+
54
+ Complete documentation can be found on our [Developer Documentation Portal].
55
+
56
+ [Developer Documentation Portal]: https://docs.blockchyp.com/
57
+
58
+ ## Getting a Developer Kit
59
+
60
+ In order to test your integration with real terminals, you'll need a BlockChyp
61
+ Developer Kit. Our kits include a fully functioning payment terminal with
62
+ test pin encryption keys. Every kit includes a comprehensive set of test
63
+ cards with test cards for every major card brand and entry method, including
64
+ Contactless and Contact EMV and mag stripe cards. Each kit also includes
65
+ test gift cards for our blockchain gift card system.
66
+
67
+ Access to BlockChyp's developer program is currently invite only, but you
68
+ can request an invitation by contacting our engineering team at **nerds@blockchyp.com**.
69
+
70
+ You can also view a number of long form demos and learn more about us on our [YouTube Channel](https://www.youtube.com/channel/UCE-iIVlJic_XArs_U65ZcJg).
71
+
72
+ ## Transaction Code Examples
73
+
74
+ You don't want to read words. You want examples. Here's a quick rundown of the
75
+ stuff you can do with the BlockChyp Ruby SDK and a few basic examples.
76
+
77
+ ### Payment Endpoints
78
+
79
+
80
+ These are the core payment APIs used to execute and work with payment transactions in BlockChyp.
81
+
82
+
83
+
84
+ #### Charge
85
+
86
+
87
+
88
+ * **API Credential Types:** Merchant
89
+ * **Required Role:** Payment API Access
90
+
91
+ Our most popular transaction executes a standard authorization and capture.
92
+ This is the most basic of
93
+ basic payment transactions, typically used in conventional retail.
94
+
95
+ Charge transactions can use a payment terminal to capture a payment or
96
+ use a previously enrolled payment token.
97
+
98
+ **Terminal Transactions**
99
+
100
+ For terminal transactions, make sure you pass in the terminal name using the `terminalName` property.
101
+
102
+ **Token Transactions**
103
+
104
+ If you have a payment token, omit the `terminalName` property and pass in the token with the `token`
105
+ property instead.
106
+
107
+ **Card Numbers and Mag Stripes**
108
+
109
+ You can also pass in PANs and Mag Stripes, but you probably shouldn't, as this will
110
+ put you in PCI scope and the most common vector for POS breaches is keylogging.
111
+ If you use terminals for manual card entry, you'll bypass any keyloggers that
112
+ might be maliciously running on the point-of-sale system.
113
+
114
+ **Common Variations**
115
+
116
+ * **Gift Card Redemption**: There's no special API for gift card redemption in BlockChyp. Simply execute a plain charge transaction and if the customer swipes a gift card, our terminals will identify the gift card and run a gift card redemption. Also note that if for some reason the gift card's original purchase transaction is associated with fraud or a chargeback, the transaction will be rejected.
117
+ * **EBT**: Set the `CardType` field to `CardType::EBT` to process an EBT SNAP transaction. Note that test EBT transactions always assume a balance of $100.00, so test EBT transactions over that amount may be declined.
118
+ * **Cash Back**: To enable cash back for debit transactions, set the `CashBack` field. If the card presented isn't a debit card, the `CashBack` field will be ignored.
119
+ * **Manual Card Entry**: Set the `ManualEntry` field to enable manual card entry. Good as a backup when chips and MSR's don't work or for more secure phone orders. You can even combine the `ManualEntry` field with the `CardType` field set to `CardType::EBT` for manual EBT card entry.
120
+ * **Inline Tokenization**: You can enroll the payment method in the token vault inline with a charge transaction by setting the `Enroll` field. You'll get a token back in the response. You can even bind the token to a customer record if you also pass in customer data.
121
+ * **Prompting for Tips**: Set the `PromptForTip` field if you'd like to prompt the customer for a tip before authorization. Good for pay-at-the-table and other service related scenarios.
122
+ * **Cash Discounting and Surcharging**: The `Surcharge` and `CashDiscount` fields can be used together to support cash discounting or surcharge problems. Consult the Cash Discount documentation for more details.
123
+ * **Cryptocurrency** The `Cryptocurrency` field can be used to switch the standard present card screen to a cryptocurrency screen. The field value can be `ANY` to enable any supported cryptocurrency or a single currency code such as `BTC` for Bitcoin.
124
+
125
+
126
+
127
+ ```ruby
128
+ # frozen_string_literal: true
129
+
130
+ require 'blockchyp'
131
+
132
+ blockchyp = BlockChyp::BlockChyp.new(
133
+ ENV['BC_API_KEY'],
134
+ ENV['BC_BEARER_TOKEN'],
135
+ ENV['BC_SIGNING_KEY']
136
+ )
137
+
138
+ # Set request parameters
139
+ request = {
140
+ test: true,
141
+ terminalName: 'Test Terminal',
142
+ amount: '55.00'
143
+ }
144
+
145
+ response = blockchyp.charge(request)
146
+
147
+ puts "Response: #{response.inspect}"
148
+
149
+
150
+ ```
151
+
152
+ #### Preauthorization
153
+
154
+
155
+
156
+ * **API Credential Types:** Merchant
157
+ * **Required Role:** Payment API Access
158
+
159
+ A preauthorization puts a hold on funds and must be captured later. This is used
160
+ in scenarios where the final transaction amount might change. A common example is
161
+ fine dining, where a tip adjustment is required before final settlement.
162
+
163
+ Another use case for preauthorization is e-commerce. Typically, an online order
164
+ is preauthorized at the time of the order and then captured when the order ships.
165
+
166
+ Preauthorizations can use a payment terminal to capture a payment or
167
+ use a previously enrolled payment token.
168
+
169
+ **Terminal Transactions**
170
+
171
+ For terminal transactions, make sure you pass in the terminal name using the `terminalName` property.
172
+
173
+ **Token Transactions**
174
+
175
+ If you have a payment token, omit the `terminalName` property and pass in the token with the `token`
176
+ property instead.
177
+
178
+ **Card Numbers and Mag Stripes**
179
+
180
+ You can also pass in PANs and Mag Stripes, but you probably shouldn't, as this will
181
+ put you in PCI scope and the most common vector for POS breaches is key logging.
182
+ If you use terminals for manual card entry, you'll bypass any key loggers that
183
+ might be maliciously running on the point-of-sale system.
184
+
185
+ **Cryptocurrency**
186
+
187
+ Note that preauths are not supported for cryptocurrency.
188
+
189
+ **Common Variations**
190
+
191
+ * **Manual Card Entry**: Set the `ManualEntry` field to enable manual card entry. Good as a backup when chips and MSR's don't work or for more secure phone orders. You can even combine the `ManualEntry` field with `CardType` set to `CardType::EBT` for manual EBT card entry.
192
+ * **Inline Tokenization**: You can enroll the payment method in the token vault in line with a charge transaction by setting the `Enroll` field. You'll get a token back in the response. You can even bind the token to a customer record if you also pass in customer data.
193
+ * **Prompting for Tips**: Set the `PromptForTip` field if you'd like to prompt the customer for a tip before authorization. You can prompt for tips as part of a preauthorization, although it's not a very common approach.
194
+ * **Cash Discounting and Surcharging**: The `Surcharge` and `CashDiscount` fields can be used together to support cash discounting or surcharge problems. Consult the Cash Discount documentation for more details.
195
+
196
+
197
+
198
+
199
+ ```ruby
200
+ # frozen_string_literal: true
201
+
202
+ require 'blockchyp'
203
+
204
+ blockchyp = BlockChyp::BlockChyp.new(
205
+ ENV['BC_API_KEY'],
206
+ ENV['BC_BEARER_TOKEN'],
207
+ ENV['BC_SIGNING_KEY']
208
+ )
209
+
210
+ # Set request parameters
211
+ request = {
212
+ test: true,
213
+ terminalName: 'Test Terminal',
214
+ amount: '27.00'
215
+ }
216
+
217
+ response = blockchyp.preauth(request)
218
+
219
+ puts "Response: #{response.inspect}"
220
+
221
+
222
+ ```
223
+
224
+ #### Capture Preauthorization
225
+
226
+
227
+
228
+ * **API Credential Types:** Merchant
229
+ * **Required Role:** Payment API Access
230
+
231
+ This API allows you to capture a previously approved preauthorization.
232
+
233
+ You'll need to make sure you pass in the Transaction ID returned by the original preauth transaction
234
+ so we know which transaction we're capturing. If you want to capture the transaction for the
235
+ exact amount of the preauth, the Transaction ID is all you need to pass in.
236
+
237
+ You can adjust the total if you need to by passing in a new `amount`. We
238
+ also recommend you pass in updated amounts for `tax` and `tip` as it can
239
+ sometimes reduce your interchange fees. (Level II Processing, for example.)
240
+
241
+
242
+
243
+
244
+ ```ruby
245
+ # frozen_string_literal: true
246
+
247
+ require 'blockchyp'
248
+
249
+ blockchyp = BlockChyp::BlockChyp.new(
250
+ ENV['BC_API_KEY'],
251
+ ENV['BC_BEARER_TOKEN'],
252
+ ENV['BC_SIGNING_KEY']
253
+ )
254
+
255
+ # Set request parameters
256
+ request = {
257
+ test: true,
258
+ transactionId: '<ORIGINAL TRANSACTION ID>',
259
+ amount: '32.00'
260
+ }
261
+
262
+ response = blockchyp.capture(request)
263
+
264
+ puts "Response: #{response.inspect}"
265
+
266
+
267
+ ```
268
+
269
+ #### Refund
270
+
271
+
272
+
273
+ * **API Credential Types:** Merchant
274
+ * **Required Role:** Payment API Access
275
+
276
+ It's not ideal, but sometimes customers want their money back.
277
+
278
+ Our refund API allows you to confront this unpleasant reality by executing refunds in a few different scenarios.
279
+
280
+ The most fraud resistent method is to execute refunds in the context of a previous transaction. You should always keep track of the Transaction ID
281
+ returned in a BlockChyp response. To refund the full amount of the previous transaction, just pass in the original Transaction ID with the refund requests.
282
+
283
+ **Partial Refunds**
284
+
285
+ For a partial refund, just pass in an amount along with the Transaction ID.
286
+ The only rule is that the amount must be equal to or less than the original
287
+ transaction. You can execute multiple partial refunds against the same
288
+ original transaction as long as the total refunded amount doesn't exceed the original amount.
289
+
290
+ **Tokenized Refunds**
291
+
292
+ You can also use a token to execute a refund. Pass in a token instead
293
+ of the Transaction ID and the desired refund amount.
294
+
295
+ **Free Range Refunds**
296
+
297
+ When you execute a refund without referencing a previous transaction, we
298
+ call this a *free range refund*.
299
+
300
+ We don't recommend this type of refund, but it is permitted. If you absolutely insist on
301
+ doing it, pass in a Terminal Name and an amount.
302
+
303
+ You can execute a manual or keyed refund by passing the `ManualEntry` field
304
+ to a free range refund request.
305
+
306
+ **Gift Card Refunds**
307
+
308
+ Gift card refunds are allowed in the context of a previous transaction, but
309
+ free range gift card refunds are not allowed. Use the gift card activation
310
+ API if you need to add more funds to a gift card.
311
+
312
+ **Store and Forward Support**
313
+
314
+ Refunds are not permitted when a terminal falls back to store and forward mode.
315
+
316
+ **Auto Voids**
317
+
318
+ If a refund referencing a previous transaction is executed for the full amount
319
+ before the original transaction's batch is closed, the refund is automatically
320
+ converted to a void. This saves the merchant a little bit of money.
321
+
322
+ **Cryptocurrency**
323
+
324
+ Note that refunds are not supported for cryptocurrency. You must refund crypto transactions
325
+ manually from your cryptocurrency wallet.
326
+
327
+
328
+
329
+
330
+ ```ruby
331
+ # frozen_string_literal: true
332
+
333
+ require 'blockchyp'
334
+
335
+ blockchyp = BlockChyp::BlockChyp.new(
336
+ ENV['BC_API_KEY'],
337
+ ENV['BC_BEARER_TOKEN'],
338
+ ENV['BC_SIGNING_KEY']
339
+ )
340
+
341
+ # Set request parameters
342
+ request = {
343
+ transactionId: '<PREVIOUS TRANSACTION ID>',
344
+
345
+ # Optional amount for partial refunds.
346
+ amount: '5.00'
347
+ }
348
+
349
+ response = blockchyp.refund(request)
350
+
351
+ puts "Response: #{response.inspect}"
352
+
353
+
354
+ ```
355
+
356
+ #### Void
357
+
358
+
359
+
360
+ * **API Credential Types:** Merchant
361
+ * **Required Role:** Payment API Access
362
+
363
+ Mistakes happen. If a transaction is made by mistake, you can void it
364
+ with this API. All that's needed is to pass in a Transaction ID and execute
365
+ the void before the original transaction's batch closes.
366
+
367
+ Voids work with EBT and gift card transactions with no additional parameters.
368
+
369
+ **Cryptocurrency**
370
+
371
+ Note that voids are not supported for cryptocurrency. You must refund crypto transactions
372
+ manually from your cryptocurrency wallet.
373
+
374
+
375
+
376
+
377
+ ```ruby
378
+ # frozen_string_literal: true
379
+
380
+ require 'blockchyp'
381
+
382
+ blockchyp = BlockChyp::BlockChyp.new(
383
+ ENV['BC_API_KEY'],
384
+ ENV['BC_BEARER_TOKEN'],
385
+ ENV['BC_SIGNING_KEY']
386
+ )
387
+
388
+ # Set request parameters
389
+ request = {
390
+ test: true,
391
+ transactionId: '<PREVIOUS TRANSACTION ID>'
392
+ }
393
+
394
+ response = blockchyp.void(request)
395
+
396
+ puts "Response: #{response.inspect}"
397
+
398
+
399
+ ```
400
+
401
+ #### Time Out Reversal
402
+
403
+
404
+
405
+ * **API Credential Types:** Merchant
406
+ * **Required Role:** Payment API Access
407
+
408
+ Payment transactions require a stable network to function correctly and
409
+ no network is stable all the time. Time out reversals are a great line
410
+ of defense against accidentally double charging consumers when payments
411
+ are retried during shaky network conditions.
412
+
413
+ We highly recommend developers use this API whenever a charge, preauth, or refund transaction times out. If you don't receive a definitive response
414
+ from BlockChyp, you can't be certain about whether or not the transaction went through.
415
+
416
+ The best practice in this situation is to send a time out reversal request. Time out reversals check for a transaction and void it if it exists.
417
+
418
+ The only caveat is that developers must use the `transactionRef` property (`txRef` for the CLI) when executing charge, preauth, and refund transactions.
419
+
420
+ The reason for this requirement is that if a system never receives a definitive
421
+ response for a transaction, the system would never have received the BlockChyp
422
+ generated Transaction ID. We have to fall back to Transaction Ref to identify
423
+ a transaction.
424
+
425
+ **Cryptocurrency**
426
+
427
+ Note that refunds are not supported for cryptocurrency. You must refund crypto transactions
428
+ manually from your cryptocurrency wallet.
429
+
430
+
431
+
432
+
433
+ ```ruby
434
+ # frozen_string_literal: true
435
+
436
+ require 'blockchyp'
437
+
438
+ blockchyp = BlockChyp::BlockChyp.new(
439
+ ENV['BC_API_KEY'],
440
+ ENV['BC_BEARER_TOKEN'],
441
+ ENV['BC_SIGNING_KEY']
442
+ )
443
+
444
+ # Set request parameters
445
+ request = {
446
+ transactionRef: '<LAST TRANSACTION REF>'
447
+ }
448
+
449
+ response = blockchyp.reverse(request)
450
+
451
+ puts "Response: #{response.inspect}"
452
+
453
+
454
+ ```
455
+
456
+ #### Gift Card Activation
457
+
458
+
459
+
460
+ * **API Credential Types:** Merchant
461
+ * **Required Role:** Payment API Access
462
+
463
+ This API activates or adds value to BlockChyp gift cards.
464
+ Just pass in the terminal name and the amount to add to the card.
465
+ Once the customer swipes their card, the terminal will use keys
466
+ on the mag stripe to add value to the card.
467
+
468
+ You don't need to handle a new gift card activation or a gift card recharge any
469
+ differently. The terminal firmware will figure out what to do on its
470
+ own while also returning the new balance for the gift card.
471
+
472
+ This is the part of the system where BlockChyp's blockchain DNA comes
473
+ closest to the surface. The BlockChyp gift card system doesn't really
474
+ use gift card numbers. This means they can't be stolen.
475
+
476
+ BlockChyp identifies cards with an elliptic curve public key instead.
477
+ Gift card transactions are actually blocks signed with those keys.
478
+ This means there are no shared secrets sent over the network.
479
+ To keep track of a BlockChyp gift card, hang on to the **public key** returned
480
+ during gift card activation. That's the gift card's elliptic curve public key.
481
+
482
+ We sometimes print numbers on our gift cards, but these are actually
483
+ decimal encoded hashes of a portion of the public key to make our gift
484
+ cards seem *normal* to *normies*. They can be used
485
+ for balance checks and play a lookup role in online gift card
486
+ authorization, but are of little use beyond that.
487
+
488
+ **Voids and Reversals**
489
+
490
+ Gift card activations can be voided and reversed just like any other
491
+ BlockChyp transaction. Use the Transaction ID or Transaction Ref
492
+ to identify the gift activation transaction as you normally would for
493
+ voiding or reversing a conventional payment transaction.
494
+
495
+ **Importing Gift Cards**
496
+
497
+ BlockChyp does have the ability to import gift card liability from
498
+ conventional gift card platforms. Unfortunately, BlockChyp does not
499
+ support activating cards on third party systems. However, you can import
500
+ your outstanding gift cards and customers can swipe them on the
501
+ terminals like BlockChyp's standard gift cards.
502
+
503
+ No special coding is required to access this feature. The gateway and
504
+ terminal firmware handle everything for you.
505
+
506
+ **Third Party Gift Card Networks**
507
+
508
+ BlockChyp does not currently provide any native support for other gift card
509
+ platforms beyond importing gift card liability. We do have a white listing system
510
+ that can be used to support your own custom gift card implementations. We have a security review
511
+ process before we can allow a BIN range to be white listed, so contact
512
+ support@blockchyp.com if you need to white list a BIN range.
513
+
514
+
515
+
516
+
517
+ ```ruby
518
+ # frozen_string_literal: true
519
+
520
+ require 'blockchyp'
521
+
522
+ blockchyp = BlockChyp::BlockChyp.new(
523
+ ENV['BC_API_KEY'],
524
+ ENV['BC_BEARER_TOKEN'],
525
+ ENV['BC_SIGNING_KEY']
526
+ )
527
+
528
+ # Set request parameters
529
+ request = {
530
+ test: true,
531
+ terminalName: 'Test Terminal',
532
+ amount: '50.00'
533
+ }
534
+
535
+ response = blockchyp.giftActivate(request)
536
+
537
+ puts "Response: #{response.inspect}"
538
+
539
+
540
+ ```
541
+
542
+ #### Balance
543
+
544
+
545
+
546
+ * **API Credential Types:** Merchant
547
+ * **Required Role:** Payment API Access
548
+
549
+ This API checks a gift or EBT card balance.
550
+
551
+ **Gift Card Balance Checks**
552
+
553
+ For gift cards, pass in a terminal name and the customer will be prompted
554
+ to swipe a card on that terminal. The remaining balance will be displayed
555
+ briefly on the terminal screen and the API response will include the gift card's public key and the remaining balance.
556
+
557
+ **EBT Balance Checks**
558
+
559
+ All EBT transactions require a PIN, so to check an EBT card balance,
560
+ you need to pass in the `ebt` flag just like you would for a normal EBT
561
+ charge transaction. The customer will be prompted to swipe their card and
562
+ enter a PIN code. If everything checks out, the remaining balance on the
563
+ card will be displayed on the terminal for the customer and returned with the API response.
564
+
565
+ **Testing Gift Card Balance Checks**
566
+
567
+ Test gift card balance checks work no differently than live gift cards. You
568
+ must activate a test gift card first to test balance checks. Test
569
+ gift cards are real blockchain cards that live on our parallel test blockchain.
570
+
571
+ **Testing EBT Gift Card Balance Checks**
572
+
573
+ All test EBT transactions assume a starting balance of $100.00. As a result,
574
+ test EBT balance checks always return a balance of $100.00.
575
+
576
+
577
+
578
+
579
+ ```ruby
580
+ # frozen_string_literal: true
581
+
582
+ require 'blockchyp'
583
+
584
+ blockchyp = BlockChyp::BlockChyp.new(
585
+ ENV['BC_API_KEY'],
586
+ ENV['BC_BEARER_TOKEN'],
587
+ ENV['BC_SIGNING_KEY']
588
+ )
589
+
590
+ # Set request parameters
591
+ request = {
592
+ test: true,
593
+ terminalName: 'Test Terminal',
594
+ cardType: CardType::EBT
595
+ }
596
+
597
+ response = blockchyp.balance(request)
598
+
599
+ puts "Response: #{response.inspect}"
600
+
601
+
602
+ ```
603
+
604
+ #### Close Batch
605
+
606
+
607
+
608
+ * **API Credential Types:** Merchant
609
+ * **Required Role:** Payment API Access
610
+
611
+ This API will close the merchant's batch if it's currently open.
612
+
613
+ By default, merchant batches will close automatically at 3 AM in their
614
+ local time zone. The automatic batch closure time can be changed
615
+ in the Merchant Profile or disabled completely.
616
+
617
+ If automatic batch closure is disabled, you'll need to use this API to
618
+ close the batch manually.
619
+
620
+
621
+
622
+ ```ruby
623
+ # frozen_string_literal: true
624
+
625
+ require 'blockchyp'
626
+
627
+ blockchyp = BlockChyp::BlockChyp.new(
628
+ ENV['BC_API_KEY'],
629
+ ENV['BC_BEARER_TOKEN'],
630
+ ENV['BC_SIGNING_KEY']
631
+ )
632
+
633
+ # Set request parameters
634
+ request = {
635
+ test: true
636
+ }
637
+
638
+ response = blockchyp.closeBatch(request)
639
+
640
+ puts "Response: #{response.inspect}"
641
+
642
+
643
+ ```
644
+
645
+ #### Send Payment Link
646
+
647
+
648
+
649
+ * **API Credential Types:** Merchant
650
+ * **Required Role:** Payment API Access
651
+
652
+ This API allows you to send an invoice to a customer and capture payment
653
+ via a BlockChyp hosted payment page.
654
+
655
+ If you set the `autoSend` flag, BlockChyp will send a basic invoice email
656
+ to the customer for you that includes the payment link. If you'd rather have
657
+ more control over the look of the email message, you can omit the `autoSend`
658
+ flag and send the customer email yourself.
659
+
660
+ There are a lot of optional parameters for this API, but at a minimum
661
+ you'll need to pass in a total, customer name, and email address. (Unless
662
+ you use the `cashier` flag.)
663
+
664
+ **Customer Info**
665
+
666
+ Unless you're using the `cashier` flag, you must specify a customer; either by
667
+ creating a new customer record inline or passing in an existing Customer ID or Customer Ref.
668
+
669
+ **Line Item Level Data**
670
+
671
+ It's not strictly required, but we strongly recommend sending line item level
672
+ detail with every request. It will make the invoice look more complete
673
+ and the data format for line item level data is the exact same format used
674
+ for terminal line item display, so the same code can be used to support both areas.
675
+
676
+ **Descriptions**
677
+
678
+ You can also provide a free form description or message to display near
679
+ the bottom of the invoice. Usually this is some kind of thank you note
680
+ or instruction.
681
+
682
+ **Terms and Conditions**
683
+
684
+ You can include long form contract language with a request and capture
685
+ terms and conditions accepted at the same time payment is captured.
686
+
687
+ The interface is identical to that used for the terminal based Terms and
688
+ Conditions API in that you can pass in content directly via `tcContent` or via
689
+ a preconfigured template via `tcAlias`. The Terms and Conditions log will also be updated when
690
+ agreement acceptance is incorporated into a send link request.
691
+
692
+ **Auto Send**
693
+
694
+ BlockChyp does not send the email notification automatically. This safeguard prevents real
695
+ emails from going out when you may not expect them If you want BlockChyp to send the email
696
+ for you, just add the `autoSend` flag with all requests.
697
+
698
+ **Cryptocurrency**
699
+
700
+ If the merchant is configured to support cryptocurrency transactions, the payment page will
701
+ display additional UI widgets that allowing customers to switch to a crypto payment method.
702
+
703
+ **Tokenization**
704
+
705
+ Add the `enroll` flag to a send link request to enroll the payment method
706
+ in the token vault.
707
+
708
+ Add the `enrollOnly` flag to enroll the payment method in the token vault without any immediate payment taking place. The payment link will ask the user for their payment information and inform them that they will not be charged immediately, but that their payment may be used for future transactions.
709
+
710
+ **Cashier Facing Card Entry**
711
+
712
+ BlockChyp can be used to generate internal/cashier facing card entry pages as well. This is
713
+ designed for situations where you might need to take a phone order and don't
714
+ have an available terminal.
715
+
716
+ If you pass in the `cashier` flag, no email will be sent and you'll be able to
717
+ load the link in a browser or iframe for payment entry. When the `cashier` flag
718
+ is used, the `autoSend` flag will be ignored.
719
+
720
+ Note that cryptocurrency is not supported for cashier facing payment entry.
721
+
722
+ **Payment Notifications**
723
+
724
+ When a customer successfully submits payment, the merchant will receive an email
725
+ notifying them that the payment was received.
726
+
727
+ **Real Time Callback Notifications**
728
+
729
+ Email notifications are fine, but you may want your system to be informed
730
+ immediately whenever a payment event occurs. By using the optional `callbackUrl` request
731
+ property, you can specify a URL to which the Authorization Response will be posted
732
+ every time the user submits a payment, whether approved or otherwise.
733
+
734
+ The response will be sent as a JSON encoded POST request and will be the exact
735
+ same format as all BlockChyp charge and preauth transaction responses.
736
+
737
+ **Status Polling**
738
+
739
+ If real time callbacks aren't practical or necessary in your environment, you can
740
+ always use the Payment Link Status API described futher on.
741
+
742
+ A common use case for the send link API with status polling is curbside pickup.
743
+ You could have your system check the Payment Link Status when a customer arrives to
744
+ ensure it's been paid without necessarily needing to create background threads
745
+ to constantly poll for status updates.
746
+
747
+
748
+
749
+
750
+ ```ruby
751
+ # frozen_string_literal: true
752
+
753
+ require 'blockchyp'
754
+
755
+ blockchyp = BlockChyp::BlockChyp.new(
756
+ ENV['BC_API_KEY'],
757
+ ENV['BC_BEARER_TOKEN'],
758
+ ENV['BC_SIGNING_KEY']
759
+ )
760
+
761
+ # Set request parameters
762
+ request = {
763
+ transactionRef: '<TX REF>',
764
+ amount: '199.99',
765
+ description: 'Widget',
766
+ subject: 'Widget invoice',
767
+ transaction: {
768
+ subtotal: '195.00',
769
+ tax: '4.99',
770
+ total: '199.99',
771
+ items: [
772
+ {
773
+ description: 'Widget',
774
+ price: '195.00',
775
+ quantity: 1
776
+ }
777
+ ]
778
+ },
779
+ autoSend: true,
780
+ customer: {
781
+ customerRef: 'Customer reference string',
782
+ firstName: 'FirstName',
783
+ lastName: 'LastName',
784
+ companyName: 'Company Name',
785
+ emailAddress: 'notifications@blockchypteam.m8r.co',
786
+ smsNumber: '(123) 123-1231'
787
+ }
788
+ }
789
+
790
+ response = blockchyp.sendPaymentLink(request)
791
+
792
+ puts "Response: #{response.inspect}"
793
+
794
+
795
+ ```
796
+
797
+ #### Resend Payment Link
798
+
799
+
800
+
801
+ * **API Credential Types:** Merchant
802
+ * **Required Role:** Payment API Access
803
+
804
+ This API will resend a previously created payment link. An error is returned if the payment link is expired, has been
805
+ cancelled, or has already been paid.
806
+
807
+
808
+
809
+
810
+ ```ruby
811
+ # frozen_string_literal: true
812
+
813
+ require 'blockchyp'
814
+
815
+ blockchyp = BlockChyp::BlockChyp.new(
816
+ ENV['BC_API_KEY'],
817
+ ENV['BC_BEARER_TOKEN'],
818
+ ENV['BC_SIGNING_KEY']
819
+ )
820
+
821
+ # Set request parameters
822
+ request = {
823
+ linkCode: '<PAYMENT LINK CODE>'
824
+ }
825
+
826
+ response = blockchyp.resendPaymentLink(request)
827
+
828
+ puts "Response: #{response.inspect}"
829
+
830
+
831
+ ```
832
+
833
+ #### Cancel Payment Link
834
+
835
+
836
+
837
+ * **API Credential Types:** Merchant
838
+ * **Required Role:** Payment API Access
839
+
840
+ This API cancels a payment link.
841
+
842
+
843
+
844
+
845
+ ```ruby
846
+ # frozen_string_literal: true
847
+
848
+ require 'blockchyp'
849
+
850
+ blockchyp = BlockChyp::BlockChyp.new(
851
+ ENV['BC_API_KEY'],
852
+ ENV['BC_BEARER_TOKEN'],
853
+ ENV['BC_SIGNING_KEY']
854
+ )
855
+
856
+ # Set request parameters
857
+ request = {
858
+ linkCode: '<PAYMENT LINK CODE>'
859
+ }
860
+
861
+ response = blockchyp.cancelPaymentLink(request)
862
+
863
+ puts "Response: #{response.inspect}"
864
+
865
+
866
+ ```
867
+
868
+ #### Payment Link Status
869
+
870
+
871
+
872
+ * **API Credential Types:** Merchant
873
+ * **Required Role:** Payment API Access
874
+
875
+ This API allows you to check on the status of a payment link, including transaction data
876
+ and the full history of attempted transactions.
877
+
878
+ This API is the preferred source of truth and best practice when you want to check on the
879
+ status of a payment link (as opposed to Transaction Status). The Transaction Status API is not
880
+ ideal because of ambiguity when there are multiple transactions associated with a single
881
+ payment link.
882
+
883
+ You must pass the `linkCode` value associated with the payment link. It is included in the response from BlockChyp when the payment link is originally created.
884
+
885
+
886
+
887
+
888
+
889
+
890
+ ```ruby
891
+ # frozen_string_literal: true
892
+
893
+ require 'blockchyp'
894
+
895
+ blockchyp = BlockChyp::BlockChyp.new(
896
+ ENV['BC_API_KEY'],
897
+ ENV['BC_BEARER_TOKEN'],
898
+ ENV['BC_SIGNING_KEY']
899
+ )
900
+
901
+ # Set request parameters
902
+ request = {
903
+ linkCode: response[:linkCode]
904
+ }
905
+
906
+ response = blockchyp.paymentLinkStatus(request)
907
+
908
+ puts "Response: #{response.inspect}"
909
+
910
+
911
+ ```
912
+
913
+ #### Transaction Status
914
+
915
+
916
+
917
+ * **API Credential Types:** Merchant
918
+ * **Required Role:** Payment API Access
919
+
920
+ This API returns the current status for any transaction. You can lookup a transaction
921
+ by its BlockChyp assigned Transaction ID or your own Transaction Ref.
922
+
923
+ You should always use globally unique Transaction Ref values, but in the event
924
+ that you duplicate Transaction Refs, the most recent transaction matching your
925
+ Transaction Ref is returned.
926
+
927
+
928
+
929
+
930
+ ```ruby
931
+ # frozen_string_literal: true
932
+
933
+ require 'blockchyp'
934
+
935
+ blockchyp = BlockChyp::BlockChyp.new(
936
+ ENV['BC_API_KEY'],
937
+ ENV['BC_BEARER_TOKEN'],
938
+ ENV['BC_SIGNING_KEY']
939
+ )
940
+
941
+ # Set request parameters
942
+ request = {
943
+ transactionId: '<TRANSACTION ID>'
944
+ }
945
+
946
+ response = blockchyp.transactionStatus(request)
947
+
948
+ puts "Response: #{response.inspect}"
949
+
950
+
951
+ ```
952
+
953
+ #### Cash Discount
954
+
955
+
956
+
957
+ * **API Credential Types:** Merchant
958
+ * **Required Role:** Payment API Access
959
+
960
+ This API calculates the surcharge, cash discount, and total amounts for cash transactions.
961
+
962
+ If you're using BlockChyp's cash discounting features, you can use this endpoint
963
+ to ensure the numbers and receipts for true cash transactions are consistent
964
+ with transactions processed by BlockChyp.
965
+
966
+
967
+
968
+
969
+ ```ruby
970
+ # frozen_string_literal: true
971
+
972
+ require 'blockchyp'
973
+
974
+ blockchyp = BlockChyp::BlockChyp.new(
975
+ ENV['BC_API_KEY'],
976
+ ENV['BC_BEARER_TOKEN'],
977
+ ENV['BC_SIGNING_KEY']
978
+ )
979
+
980
+ # Set request parameters
981
+ request = {
982
+ amount: '100.00',
983
+ cashDiscount: true,
984
+ surcharge: true
985
+ }
986
+
987
+ response = blockchyp.cashDiscount(request)
988
+
989
+ puts "Response: #{response.inspect}"
990
+
991
+
992
+ ```
993
+
994
+ #### Batch History
995
+
996
+
997
+
998
+ * **API Credential Types:** Merchant
999
+ * **Required Role:** Payment API Access
1000
+
1001
+ This endpoint allows developers to query the gateway for the merchant's batch history.
1002
+ The data will be returned in descending order of open date with the most recent
1003
+ batch returned first. The results will include basic information about the batch.
1004
+ Consider using the Batch Details API for more detail about a specific batch.
1005
+
1006
+ **Limiting Results**
1007
+
1008
+ This API will return a maximum of 250 results. Use the `maxResults` property to
1009
+ limit maximum results even further and use the `startIndex` property to
1010
+ page through results that span multiple queries.
1011
+
1012
+ For example, if you want the ten most recent batches, pass in a value of
1013
+ `10` for `maxResults`. Also note that `startIndex` is zero based. Use a value of `0` to
1014
+ get the first batch in the dataset.
1015
+
1016
+ **Filtering by Date Range**
1017
+
1018
+ You can also filter results by date. Use the `startDate` and `endDate`
1019
+ properties to return only those batches opened between those dates.
1020
+ You can use either `startDate` and `endDate` and you can use date filters
1021
+ in conjunction with `maxResults` and `startIndex`
1022
+
1023
+
1024
+
1025
+
1026
+ ```ruby
1027
+ # frozen_string_literal: true
1028
+
1029
+ require 'blockchyp'
1030
+
1031
+ blockchyp = BlockChyp::BlockChyp.new(
1032
+ ENV['BC_API_KEY'],
1033
+ ENV['BC_BEARER_TOKEN'],
1034
+ ENV['BC_SIGNING_KEY']
1035
+ )
1036
+
1037
+ # Set request parameters
1038
+ request = {
1039
+ maxResults: 250,
1040
+ startIndex: 0
1041
+ }
1042
+
1043
+ response = blockchyp.batchHistory(request)
1044
+
1045
+ puts "Response: #{response.inspect}"
1046
+
1047
+
1048
+ ```
1049
+
1050
+ #### Batch Details
1051
+
1052
+
1053
+
1054
+ * **API Credential Types:** Merchant
1055
+ * **Required Role:** Payment API Access
1056
+
1057
+ This API allows developers to pull down details for a specific batch,
1058
+ including captured volume, gift card activity, expected deposit, and
1059
+ captured volume broken down by terminal.
1060
+
1061
+ The only required request parameter is `batchId`. Batch IDs are returned
1062
+ with every transaction response and can be discovered using the Batch
1063
+ History API.
1064
+
1065
+
1066
+
1067
+
1068
+ ```ruby
1069
+ # frozen_string_literal: true
1070
+
1071
+ require 'blockchyp'
1072
+
1073
+ blockchyp = BlockChyp::BlockChyp.new(
1074
+ ENV['BC_API_KEY'],
1075
+ ENV['BC_BEARER_TOKEN'],
1076
+ ENV['BC_SIGNING_KEY']
1077
+ )
1078
+
1079
+ # Set request parameters
1080
+ request = {
1081
+ batchId: '<BATCH ID>'
1082
+ }
1083
+
1084
+ response = blockchyp.batchDetails(request)
1085
+
1086
+ puts "Response: #{response.inspect}"
1087
+
1088
+
1089
+ ```
1090
+
1091
+ #### Transaction History
1092
+
1093
+
1094
+
1095
+ * **API Credential Types:** Merchant
1096
+ * **Required Role:** Payment API Access
1097
+
1098
+ This endpoint provides several different methods to sift through
1099
+ transaction history.
1100
+
1101
+ By default with no filtering properties, this endpoint will return the 250
1102
+ most recent transactions.
1103
+
1104
+ **Limiting Results**
1105
+
1106
+ This API will return a maximum of 50 results in a single query. Use the `maxResults` property
1107
+ to limit maximum results even further and use the `startIndex` property to
1108
+ page through results that span multiple queries.
1109
+
1110
+ For example, if you want the ten most recent batches, pass in a value of
1111
+ `10` for `maxResults`. Also note that `startIndex` is zero based. Use a value of `0` to
1112
+ get the first transaction in the dataset.
1113
+
1114
+ **Filtering By Date Range**
1115
+
1116
+ You can also filter results by date. Use the `startDate` and `endDate`
1117
+ properties to return only transactions run between those dates.
1118
+ You can use either `startDate` or `endDate` and you can use date filters
1119
+ in conjunction with `maxResults` and `startIndex`
1120
+
1121
+ **Filtering By Batch**
1122
+
1123
+ To restrict results to a single batch, pass in the `batchId` parameter.
1124
+
1125
+ **Filtering By Terminal**
1126
+
1127
+ To restrict results to those executed on a single terminal, pass in the terminal name.
1128
+
1129
+ **Combining Filters**
1130
+
1131
+ None of the above filters are mutually exclusive. You can combine any of the
1132
+ above properties in a single request to restrict transaction results to a
1133
+ narrower set of results.
1134
+
1135
+ **Searching Transaction History**
1136
+
1137
+ You can search transaction history by passing in search criteria with the
1138
+ `query` option. The search system will match the amount (requested and authorized),
1139
+ last four of the card number, cardholder name, and the auth code.
1140
+
1141
+ Note that when search queries are used, terminalName or
1142
+ batch id filters are not supported.
1143
+
1144
+
1145
+
1146
+
1147
+ ```ruby
1148
+ # frozen_string_literal: true
1149
+
1150
+ require 'blockchyp'
1151
+
1152
+ blockchyp = BlockChyp::BlockChyp.new(
1153
+ ENV['BC_API_KEY'],
1154
+ ENV['BC_BEARER_TOKEN'],
1155
+ ENV['BC_SIGNING_KEY']
1156
+ )
1157
+
1158
+ # Set request parameters
1159
+ request = {
1160
+ maxResults: 10,
1161
+ batchId: '<BATCH ID>'
1162
+ }
1163
+
1164
+ response = blockchyp.transactionHistory(request)
1165
+
1166
+ puts "Response: #{response.inspect}"
1167
+
1168
+
1169
+ ```
1170
+
1171
+ #### List Queued Transactions
1172
+
1173
+
1174
+
1175
+ * **API Credential Types:** Merchant
1176
+ * **Required Role:** Payment API Access
1177
+
1178
+ Returns a list of transaction refs of transactions queued on a terminal.
1179
+ Details about the transactions can be retrieved using the Transaction Status
1180
+ API.
1181
+
1182
+
1183
+
1184
+
1185
+ ```ruby
1186
+ # frozen_string_literal: true
1187
+
1188
+ require 'blockchyp'
1189
+
1190
+ blockchyp = BlockChyp::BlockChyp.new(
1191
+ ENV['BC_API_KEY'],
1192
+ ENV['BC_BEARER_TOKEN'],
1193
+ ENV['BC_SIGNING_KEY']
1194
+ )
1195
+
1196
+ # Set request parameters
1197
+ request = {
1198
+ terminalName: 'Test Terminal'
1199
+ }
1200
+
1201
+ response = blockchyp.listQueuedTransactions(request)
1202
+
1203
+ puts "Response: #{response.inspect}"
1204
+
1205
+
1206
+ ```
1207
+
1208
+ #### Delete Queued Transaction
1209
+
1210
+
1211
+
1212
+ * **API Credential Types:** Merchant
1213
+ * **Required Role:** Payment API Access
1214
+
1215
+ Deletes one or all queued transactions from a terminal. If `*` is passed as
1216
+ a transaction ref, then the entire terminal queue will be cleared. An error is
1217
+ returned if the passed transaction ref is not queued on the terminal.
1218
+
1219
+
1220
+
1221
+
1222
+ ```ruby
1223
+ # frozen_string_literal: true
1224
+
1225
+ require 'blockchyp'
1226
+
1227
+ blockchyp = BlockChyp::BlockChyp.new(
1228
+ ENV['BC_API_KEY'],
1229
+ ENV['BC_BEARER_TOKEN'],
1230
+ ENV['BC_SIGNING_KEY']
1231
+ )
1232
+
1233
+ # Set request parameters
1234
+ request = {
1235
+ terminalName: 'Test Terminal',
1236
+ transactionRef: '*'
1237
+ }
1238
+
1239
+ response = blockchyp.deleteQueuedTransaction(request)
1240
+
1241
+ puts "Response: #{response.inspect}"
1242
+
1243
+
1244
+ ```
1245
+
1246
+ ### Terminal Management Endpoints
1247
+
1248
+
1249
+ These APIs support terminal management functions and additional terminal
1250
+ features such as line item display, messages, and interactive prompts.
1251
+ These features can be used to extend a point of sale system's functionality.
1252
+
1253
+
1254
+
1255
+ #### Terminal Ping
1256
+
1257
+
1258
+
1259
+ * **API Credential Types:** Merchant
1260
+ * **Required Role:** Payment API Access
1261
+
1262
+ This simple test transaction helps ensure good communication with a payment terminal
1263
+ and is usually the first test you'll run in development.
1264
+
1265
+ It tests communication with the terminal and returns a positive response if everything
1266
+ is okay. It works the same way in local or cloud relay mode.
1267
+
1268
+ If you get a positive response, you've successfully verified all of the following:
1269
+
1270
+ * The terminal is online.
1271
+ * There is a valid route to the terminal.
1272
+ * The API Credentials are valid.
1273
+
1274
+
1275
+
1276
+
1277
+ ```ruby
1278
+ # frozen_string_literal: true
1279
+
1280
+ require 'blockchyp'
1281
+
1282
+ blockchyp = BlockChyp::BlockChyp.new(
1283
+ ENV['BC_API_KEY'],
1284
+ ENV['BC_BEARER_TOKEN'],
1285
+ ENV['BC_SIGNING_KEY']
1286
+ )
1287
+
1288
+ # Set request parameters
1289
+ request = {
1290
+ terminalName: 'Test Terminal'
1291
+ }
1292
+
1293
+ response = blockchyp.ping(request)
1294
+
1295
+ puts "Response: #{response.inspect}"
1296
+
1297
+
1298
+ ```
1299
+
1300
+ #### Terminal Locate
1301
+
1302
+
1303
+
1304
+ * **API Credential Types:** Merchant
1305
+ * **Required Role:** Payment API Access
1306
+
1307
+ This endpoint returns a terminal's routing and location information.
1308
+
1309
+ The result will indicate whether or not the terminal is in cloud relay mode and will
1310
+ return the local IP address if the terminal is in local mode.
1311
+
1312
+ The terminal will also return the public key for the terminal.
1313
+
1314
+
1315
+
1316
+
1317
+ ```ruby
1318
+ # frozen_string_literal: true
1319
+
1320
+ require 'blockchyp'
1321
+
1322
+ blockchyp = BlockChyp::BlockChyp.new(
1323
+ ENV['BC_API_KEY'],
1324
+ ENV['BC_BEARER_TOKEN'],
1325
+ ENV['BC_SIGNING_KEY']
1326
+ )
1327
+
1328
+ # Set request parameters
1329
+ request = {
1330
+ terminalName: 'Test Terminal'
1331
+ }
1332
+
1333
+ response = blockchyp.locate(request)
1334
+
1335
+ puts "Response: #{response.inspect}"
1336
+
1337
+
1338
+ ```
1339
+
1340
+ #### Terminal Clear
1341
+
1342
+
1343
+
1344
+ * **API Credential Types:** Merchant
1345
+ * **Required Role:** Payment API Access
1346
+
1347
+ This API interrupts whatever a terminal may be doing and returns it to the
1348
+ idle state.
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+ ```ruby
1355
+ # frozen_string_literal: true
1356
+
1357
+ require 'blockchyp'
1358
+
1359
+ blockchyp = BlockChyp::BlockChyp.new(
1360
+ ENV['BC_API_KEY'],
1361
+ ENV['BC_BEARER_TOKEN'],
1362
+ ENV['BC_SIGNING_KEY']
1363
+ )
1364
+
1365
+ # Set request parameters
1366
+ request = {
1367
+ test: true,
1368
+ terminalName: 'Test Terminal'
1369
+ }
1370
+
1371
+ response = blockchyp.clear(request)
1372
+
1373
+ puts "Response: #{response.inspect}"
1374
+
1375
+
1376
+ ```
1377
+
1378
+ #### Terminal Status
1379
+
1380
+
1381
+
1382
+ * **API Credential Types:** Merchant
1383
+ * **Required Role:** Payment API Access
1384
+
1385
+ This API returns the current status of a payment terminal. This is typically used
1386
+ as a way to determine if the terminal is busy before sending a new transaction.
1387
+
1388
+ If the terminal is busy, `idle` will be false and the `status` field will return
1389
+ a short string that indicates the transaction type currently in progress. The system
1390
+ will also return the timestamp of the last status change in the `since` field.
1391
+
1392
+ The `cardInSlot` field in the response will indicates whether or not a card is currently in the card reader slot.
1393
+
1394
+ If the system is running a payment transaction and you wisely passed in a
1395
+ Transaction Ref, this API will also return the Transaction Ref of the in progress
1396
+ transaction.
1397
+
1398
+ The table below lists all possible status responses.
1399
+
1400
+ | Status Code | Description |
1401
+ |----------------------|-----------------------------------------------------------------------------------------|
1402
+ | idle | The terminal is idle and ready for transactions. The default branding is being displayed. |
1403
+ | activate | The terminal is in the process of activating and pairing with the merchant account. |
1404
+ | balance | A balance check (EBT or Gift Card) is pending on the terminal. |
1405
+ | boolean-prompt | A boolean prompt (yes/no) operation is pending on the terminal. |
1406
+ | signature | A signature capture is pending. |
1407
+ | crypto | A cryptocurrency transaction is pending. |
1408
+ | enroll | A token vault enrollment operation is pending. |
1409
+ | gift-activate | A gift card activation operation is in progress. |
1410
+ | message | The terminal is displaying a custom message. |
1411
+ | charge | The terminal is executing a charge transaction. |
1412
+ | preauth | The terminal is executing a preauth transaction. |
1413
+ | refund | The terminal is executing a refund transaction. |
1414
+ | survey | The terminal is displaying post transaction survey questions. |
1415
+ | terms-and-conditions | The terminal is pending terms and conditions acceptance and signature. |
1416
+ | text-prompt | The terminal is awaiting response to a text input prompt. |
1417
+ | txdisplay | The terminal is displaying transaction and/or line item level details. |
1418
+
1419
+
1420
+
1421
+
1422
+ ```ruby
1423
+ # frozen_string_literal: true
1424
+
1425
+ require 'blockchyp'
1426
+
1427
+ blockchyp = BlockChyp::BlockChyp.new(
1428
+ ENV['BC_API_KEY'],
1429
+ ENV['BC_BEARER_TOKEN'],
1430
+ ENV['BC_SIGNING_KEY']
1431
+ )
1432
+
1433
+ # Set request parameters
1434
+ request = {
1435
+ terminalName: 'Test Terminal'
1436
+ }
1437
+
1438
+ response = blockchyp.terminalStatus(request)
1439
+
1440
+ puts "Response: #{response.inspect}"
1441
+
1442
+
1443
+ ```
1444
+
1445
+ #### Capture Signature
1446
+
1447
+
1448
+
1449
+ * **API Credential Types:** Merchant
1450
+ * **Required Role:** Payment API Access
1451
+
1452
+ This endpoint captures a written signature from the terminal and returns the
1453
+ image.
1454
+
1455
+ Unlike the Terms & Conditions API, this endpoint performs basic signature
1456
+ capture with no agreement display or signature archival.
1457
+
1458
+ Under the hood, signatures are captured in a proprietary vector format and
1459
+ must be converted to a common raster format in order to be useful to most
1460
+ applications. At a minimum, you must specify an image format using the
1461
+ `sigFormat` parameter. Currently, JPG and PNG are supported.
1462
+
1463
+ By default, images are returned in the JSON response as hex encoded binary.
1464
+ You can redirect the binary image output to a file using the `sigFile`
1465
+ parameter.
1466
+
1467
+ You can also scale the output image to your preferred width by
1468
+ passing in a `sigWidth` parameter. The image will be scaled to that
1469
+ width, preserving the aspect ratio of the original image.
1470
+
1471
+
1472
+
1473
+
1474
+ ```ruby
1475
+ # frozen_string_literal: true
1476
+
1477
+ require 'blockchyp'
1478
+
1479
+ blockchyp = BlockChyp::BlockChyp.new(
1480
+ ENV['BC_API_KEY'],
1481
+ ENV['BC_BEARER_TOKEN'],
1482
+ ENV['BC_SIGNING_KEY']
1483
+ )
1484
+
1485
+ # Set request parameters
1486
+ request = {
1487
+ terminalName: 'Test Terminal',
1488
+
1489
+ # File format for the signature image.
1490
+ sigFormat: SignatureFormat::PNG,
1491
+
1492
+ # Width of the signature image in pixels.
1493
+ sigWidth: 200
1494
+ }
1495
+
1496
+ response = blockchyp.captureSignature(request)
1497
+
1498
+ puts "Response: #{response.inspect}"
1499
+
1500
+
1501
+ ```
1502
+
1503
+ #### New Transaction Display
1504
+
1505
+
1506
+
1507
+ * **API Credential Types:** Merchant
1508
+ * **Required Role:** Payment API Access
1509
+
1510
+ This API sends totals and line item level data to the terminal.
1511
+
1512
+ At a minimum, you should send total information as part of a display request,
1513
+ including `total`, `tax`, and `subtotal`.
1514
+
1515
+ You can also send line item level data and each line item can have a `description`,
1516
+ `qty`, `price`, and `extended` price.
1517
+
1518
+ If you fail to send an extended price, BlockChyp will multiply the `qty` by the
1519
+ `price`. However, we strongly recommend you precalculate all the fields yourself
1520
+ to ensure consistency. For example, your treatment of floating-point multiplication
1521
+ and rounding may differ slightly from BlockChyp's.
1522
+
1523
+ **Discounts**
1524
+
1525
+ You have the option to show discounts on the display as individual line items
1526
+ with negative values or you can associate discounts with a specific line item.
1527
+ You can apply any number of discounts to an individual line item with a description
1528
+ and amount.
1529
+
1530
+
1531
+
1532
+
1533
+ ```ruby
1534
+ # frozen_string_literal: true
1535
+
1536
+ require 'blockchyp'
1537
+
1538
+ blockchyp = BlockChyp::BlockChyp.new(
1539
+ ENV['BC_API_KEY'],
1540
+ ENV['BC_BEARER_TOKEN'],
1541
+ ENV['BC_SIGNING_KEY']
1542
+ )
1543
+
1544
+ # Set request parameters
1545
+ request = {
1546
+ test: true,
1547
+ terminalName: 'Test Terminal',
1548
+ transaction: {
1549
+ subtotal: '60.00',
1550
+ tax: '5.00',
1551
+ total: '65.00',
1552
+ items: [
1553
+ {
1554
+ description: 'Leki Trekking Poles',
1555
+ price: '35.00',
1556
+ quantity: 2,
1557
+ extended: '70.00',
1558
+ discounts: [
1559
+ {
1560
+ description: 'memberDiscount',
1561
+ amount: '10.00'
1562
+ }
1563
+ ]
1564
+ }
1565
+ ]
1566
+ }
1567
+ }
1568
+
1569
+ response = blockchyp.newTransactionDisplay(request)
1570
+
1571
+ puts "Response: #{response.inspect}"
1572
+
1573
+
1574
+ ```
1575
+
1576
+ #### Update Transaction Display
1577
+
1578
+
1579
+
1580
+ * **API Credential Types:** Merchant
1581
+ * **Required Role:** Payment API Access
1582
+
1583
+ Similar to *New Transaction Display*, this variant allows developers to update
1584
+ line item level data currently being displayed on the terminal.
1585
+
1586
+ This feature is designed for situations where you want to update the terminal display as
1587
+ items are scanned. You'll only have to send information to the
1588
+ terminal that's changed, which usually means the new line item and updated totals.
1589
+
1590
+ If the terminal is not in line item display mode and you invoke this endpoint,
1591
+ the first invocation will behave like a *New Transaction Display* call.
1592
+
1593
+ At a minimum, you should send total information as part of a display request,
1594
+ including `total`, `tax`, and `subtotal`.
1595
+
1596
+ You can also send line item level data and each line item can have a `description`,
1597
+ `qty`, `price`, and `extended` price.
1598
+
1599
+ If you fail to send an extended price, BlockChyp will multiply the `qty` by the
1600
+ `price`. However, we strongly recommend you precalculate all the fields yourself
1601
+ to ensure consistency. For example, your treatment of floating-point multiplication and rounding
1602
+ may differ slightly from BlockChyp's.
1603
+
1604
+ **Discounts**
1605
+
1606
+ You have the option to show discounts on the display as individual line items
1607
+ with negative values or you can associate discounts with a specific line item.
1608
+ You can apply any number of discounts to an individual line item with a description
1609
+ and amount.
1610
+
1611
+
1612
+
1613
+
1614
+ ```ruby
1615
+ # frozen_string_literal: true
1616
+
1617
+ require 'blockchyp'
1618
+
1619
+ blockchyp = BlockChyp::BlockChyp.new(
1620
+ ENV['BC_API_KEY'],
1621
+ ENV['BC_BEARER_TOKEN'],
1622
+ ENV['BC_SIGNING_KEY']
1623
+ )
1624
+
1625
+ # Set request parameters
1626
+ request = {
1627
+ test: true,
1628
+ terminalName: 'Test Terminal',
1629
+ transaction: {
1630
+ subtotal: '60.00',
1631
+ tax: '5.00',
1632
+ total: '65.00',
1633
+ items: [
1634
+ {
1635
+ description: 'Leki Trekking Poles',
1636
+ price: '35.00',
1637
+ quantity: 2,
1638
+ extended: '70.00',
1639
+ discounts: [
1640
+ {
1641
+ description: 'memberDiscount',
1642
+ amount: '10.00'
1643
+ }
1644
+ ]
1645
+ }
1646
+ ]
1647
+ }
1648
+ }
1649
+
1650
+ response = blockchyp.updateTransactionDisplay(request)
1651
+
1652
+ puts "Response: #{response.inspect}"
1653
+
1654
+
1655
+ ```
1656
+
1657
+ #### Display Message
1658
+
1659
+
1660
+
1661
+ * **API Credential Types:** Merchant
1662
+ * **Required Role:** Payment API Access
1663
+
1664
+ This API displays a message on the payment terminal.
1665
+
1666
+ Just specify the target terminal and the message using the `message` parameter.
1667
+
1668
+
1669
+
1670
+
1671
+ ```ruby
1672
+ # frozen_string_literal: true
1673
+
1674
+ require 'blockchyp'
1675
+
1676
+ blockchyp = BlockChyp::BlockChyp.new(
1677
+ ENV['BC_API_KEY'],
1678
+ ENV['BC_BEARER_TOKEN'],
1679
+ ENV['BC_SIGNING_KEY']
1680
+ )
1681
+
1682
+ # Set request parameters
1683
+ request = {
1684
+ test: true,
1685
+ terminalName: 'Test Terminal',
1686
+ message: 'Thank you for your business.'
1687
+ }
1688
+
1689
+ response = blockchyp.message(request)
1690
+
1691
+ puts "Response: #{response.inspect}"
1692
+
1693
+
1694
+ ```
1695
+
1696
+ #### Boolean Prompt
1697
+
1698
+
1699
+
1700
+ * **API Credential Types:** Merchant
1701
+ * **Required Role:** Payment API Access
1702
+
1703
+ This API prompts the customer to answer a yes or no question.
1704
+
1705
+ You can specify the question or prompt with the `prompt` parameter and
1706
+ the response is returned in the `response` field.
1707
+
1708
+ This can be used for a number of use cases including starting a loyalty enrollment
1709
+ workflow or customer facing suggestive selling prompts.
1710
+
1711
+ **Custom Captions**
1712
+
1713
+ You can optionally override the "YES" and "NO" button captions by
1714
+ using the `yesCaption` and `noCaption` request parameters.
1715
+
1716
+
1717
+
1718
+
1719
+ ```ruby
1720
+ # frozen_string_literal: true
1721
+
1722
+ require 'blockchyp'
1723
+
1724
+ blockchyp = BlockChyp::BlockChyp.new(
1725
+ ENV['BC_API_KEY'],
1726
+ ENV['BC_BEARER_TOKEN'],
1727
+ ENV['BC_SIGNING_KEY']
1728
+ )
1729
+
1730
+ # Set request parameters
1731
+ request = {
1732
+ test: true,
1733
+ terminalName: 'Test Terminal',
1734
+ prompt: 'Would you like to become a member?',
1735
+ yesCaption: 'Yes',
1736
+ noCaption: 'No'
1737
+ }
1738
+
1739
+ response = blockchyp.booleanPrompt(request)
1740
+
1741
+ puts "Response: #{response.inspect}"
1742
+
1743
+
1744
+ ```
1745
+
1746
+ #### Text Prompt
1747
+
1748
+
1749
+
1750
+ * **API Credential Types:** Merchant
1751
+ * **Required Role:** Payment API Access
1752
+
1753
+ This API prompts the customer to enter numeric or alphanumeric data.
1754
+
1755
+ Due to PCI rules, free-form prompts are not permitted when the response
1756
+ could be any valid string. The reason for this is that a malicious
1757
+ developer (not you, of course) could use text prompts to ask the customer to
1758
+ input a card number or PIN code.
1759
+
1760
+ This means that instead of providing a prompt, you provide a `promptType` instead.
1761
+
1762
+ The prompt types currently supported are listed below:
1763
+
1764
+ * **phone**: Captures a phone number.
1765
+ * **email**: Captures an email address.
1766
+ * **first-name**: Captures a first name.
1767
+ * **last-name**: Captures a last name.
1768
+ * **customer-number**: Captures a customer number.
1769
+ * **rewards-number**: Captures a rewards number.
1770
+
1771
+ You can specify the prompt with the `promptType` parameter and
1772
+ the response is returned in the `response` field.
1773
+
1774
+
1775
+
1776
+
1777
+
1778
+ ```ruby
1779
+ # frozen_string_literal: true
1780
+
1781
+ require 'blockchyp'
1782
+
1783
+ blockchyp = BlockChyp::BlockChyp.new(
1784
+ ENV['BC_API_KEY'],
1785
+ ENV['BC_BEARER_TOKEN'],
1786
+ ENV['BC_SIGNING_KEY']
1787
+ )
1788
+
1789
+ # Set request parameters
1790
+ request = {
1791
+ test: true,
1792
+ terminalName: 'Test Terminal',
1793
+
1794
+ # Type of prompt. Can be 'email', 'phone', 'customer-number', or
1795
+ # 'rewards-number'.
1796
+ promptType: PromptType::EMAIL
1797
+ }
1798
+
1799
+ response = blockchyp.textPrompt(request)
1800
+
1801
+ puts "Response: #{response.inspect}"
1802
+
1803
+
1804
+ ```
1805
+
1806
+ #### List Terminals
1807
+
1808
+
1809
+
1810
+ * **API Credential Types:** Merchant & Partner
1811
+ * **Required Role:** Terminal Management
1812
+
1813
+ This API returns details about terminals associated with a merchant account.
1814
+
1815
+ Status and resource information is returned for all terminals along with a preview of the
1816
+ current branding image displayed on the terminal
1817
+
1818
+
1819
+
1820
+
1821
+ ```ruby
1822
+ # frozen_string_literal: true
1823
+
1824
+ require 'blockchyp'
1825
+
1826
+ blockchyp = BlockChyp::BlockChyp.new(
1827
+ ENV['BC_API_KEY'],
1828
+ ENV['BC_BEARER_TOKEN'],
1829
+ ENV['BC_SIGNING_KEY']
1830
+ )
1831
+
1832
+ # Set request parameters
1833
+ request = {
1834
+ }
1835
+
1836
+ response = blockchyp.terminals(request)
1837
+
1838
+ puts "Response: #{response.inspect}"
1839
+
1840
+
1841
+ ```
1842
+
1843
+ #### Deactivate Terminal
1844
+
1845
+
1846
+
1847
+ * **API Credential Types:** Merchant & Partner
1848
+ * **Required Role:** Terminal Management
1849
+
1850
+ This API deactivates a payment terminal.
1851
+
1852
+ If the terminal exists and is currently online, it will be removed from the merchant's
1853
+ terminal inventory. The terminal will be remotely cleared and factory reset.
1854
+
1855
+
1856
+
1857
+
1858
+ ```ruby
1859
+ # frozen_string_literal: true
1860
+
1861
+ require 'blockchyp'
1862
+
1863
+ blockchyp = BlockChyp::BlockChyp.new(
1864
+ ENV['BC_API_KEY'],
1865
+ ENV['BC_BEARER_TOKEN'],
1866
+ ENV['BC_SIGNING_KEY']
1867
+ )
1868
+
1869
+ # Set request parameters
1870
+ request = {
1871
+ terminalId: '<TERMINAL ID>'
1872
+ }
1873
+
1874
+ response = blockchyp.deactivateTerminal(request)
1875
+
1876
+ puts "Response: #{response.inspect}"
1877
+
1878
+
1879
+ ```
1880
+
1881
+ #### Activate Terminal
1882
+
1883
+
1884
+
1885
+ * **API Credential Types:** Merchant & Partner
1886
+ * **Required Role:** Terminal Management
1887
+
1888
+ This API activates a payment terminal.
1889
+
1890
+ If successful, the payment terminal will restart, generate new encryption keys, and download any active
1891
+ branding assets for the merchant account it's been added to.
1892
+
1893
+ Activation requests require an activation code and a unique terminal name. All terminal names must be unique across
1894
+ a merchant account.
1895
+
1896
+ Optional Parameters
1897
+
1898
+ * **merchantId:** For partner scoped API credentials, a merchant ID is required. For merchant scoped API credentials, the merchant ID is implicit and cannot be overridden.
1899
+ * **cloudRelay:** Activates the terminal in cloud relay mode.
1900
+
1901
+
1902
+
1903
+ ```ruby
1904
+ # frozen_string_literal: true
1905
+
1906
+ require 'blockchyp'
1907
+
1908
+ blockchyp = BlockChyp::BlockChyp.new(
1909
+ ENV['BC_API_KEY'],
1910
+ ENV['BC_BEARER_TOKEN'],
1911
+ ENV['BC_SIGNING_KEY']
1912
+ )
1913
+
1914
+ # Set request parameters
1915
+ request = {
1916
+ terminalName: 'Test Terminal',
1917
+ activationCode: '<ACTIVATION CODE>'
1918
+ }
1919
+
1920
+ response = blockchyp.activateTerminal(request)
1921
+
1922
+ puts "Response: #{response.inspect}"
1923
+
1924
+
1925
+ ```
1926
+
1927
+ #### Reboot Terminal
1928
+
1929
+
1930
+
1931
+ * **API Credential Types:** Merchant
1932
+ * **Required Role:** Payment API Access
1933
+
1934
+ This API reboots the terminal.
1935
+
1936
+
1937
+
1938
+
1939
+ ```ruby
1940
+ # frozen_string_literal: true
1941
+
1942
+ require 'blockchyp'
1943
+
1944
+ blockchyp = BlockChyp::BlockChyp.new(
1945
+ ENV['BC_API_KEY'],
1946
+ ENV['BC_BEARER_TOKEN'],
1947
+ ENV['BC_SIGNING_KEY']
1948
+ )
1949
+
1950
+ # Set request parameters
1951
+ request = {
1952
+ terminalName: 'Test Terminal'
1953
+ }
1954
+
1955
+ response = blockchyp.reboot(request)
1956
+
1957
+ puts "Response: #{response.inspect}"
1958
+
1959
+
1960
+ ```
1961
+
1962
+ ### Terms & Conditions Endpoints
1963
+
1964
+
1965
+ Developers can use BlockChyp to display and capture acceptance of contracts or agreements related to transactions.
1966
+ These agreements can be any long-form contract ranging from rental agreements to HIPPA disclosures.
1967
+
1968
+ There are two basic approaches to terms and conditions capture. Merchants can store contract templates in
1969
+ BlockChyp or they can send the full agreement text as part of every API call. The right approach will largely
1970
+ depend on whether or not the system being integrated with BlockChyp already has a mechanism for organizing
1971
+ and managing agreements. For systems that already have this feature built in, it's probably not necessary
1972
+ to use Terms and Conditions.
1973
+
1974
+ When agreements are displayed on a terminal, the consumer can scroll through and read the entire agreement,
1975
+ and provide a signature. Results are returned as part of the API response, but BlockChyp also stores a
1976
+ record of the agreement including the signature image, timestamp, and the full text of the agreement that was
1977
+ agreed to.
1978
+
1979
+ The Terms and Conditions Log APIs can be used to search and retrieve acceptance records. Those records
1980
+ can also be linked to a transaction if a transaction id is provided with the original API request.
1981
+
1982
+
1983
+
1984
+ #### Terms & Conditions Capture
1985
+
1986
+
1987
+
1988
+ * **API Credential Types:** Merchant
1989
+ * **Required Role:** Terms & Conditions Management
1990
+
1991
+ This API allows you to prompt a customer to accept a legal agreement on the terminal
1992
+ and (usually) capture their signature.
1993
+
1994
+ Content for the agreement can be specified in two ways. You can reference a
1995
+ previously configured T&C template or pass in the full agreement text with every request.
1996
+
1997
+ **Using Templates**
1998
+
1999
+ If your application doesn't keep track of agreements you can leverage BlockChyp's
2000
+ template system. You can create any number of T&C Templates in the merchant dashboard
2001
+ and pass in the `tcAlias` flag to specify which one should display.
2002
+
2003
+ **Raw Content**
2004
+
2005
+ If your system keeps track of the agreement language or executes complicated merging
2006
+ and rendering logic, you can bypass our template system and pass in the full text with
2007
+ every transaction. Use `tcName` to pass in the agreement name and `tcContent` to
2008
+ pass in the contract text. Note that only plain text is supported.
2009
+
2010
+ **Bypassing Signatures**
2011
+
2012
+ Signature images are captured by default. If for some reason this doesn't fit your
2013
+ use case and you'd like to capture acceptance without actually capturing a signature image, set
2014
+ the `disableSignature` flag in the request.
2015
+
2016
+ **Terms & Conditions Log**
2017
+
2018
+ Every time a user accepts an agreement on the terminal, the signature image (if captured),
2019
+ will be uploaded to the gateway. The image will also be added to the log along with the full text of the
2020
+ agreement. This preserves the historical record in the event that standard agreements
2021
+ or templates change over time.
2022
+
2023
+ **Associating Agreements with Transactions**
2024
+
2025
+ To associate a Terms & Conditions log entry with a transaction, just pass in the
2026
+ Transaction ID or Transaction Ref for the associated transaction.
2027
+
2028
+
2029
+
2030
+
2031
+
2032
+ ```ruby
2033
+ # frozen_string_literal: true
2034
+
2035
+ require 'blockchyp'
2036
+
2037
+ blockchyp = BlockChyp::BlockChyp.new(
2038
+ ENV['BC_API_KEY'],
2039
+ ENV['BC_BEARER_TOKEN'],
2040
+ ENV['BC_SIGNING_KEY']
2041
+ )
2042
+
2043
+ # Set request parameters
2044
+ request = {
2045
+ test: true,
2046
+ terminalName: 'Test Terminal',
2047
+
2048
+ # Alias for a Terms and Conditions template configured in the BlockChyp
2049
+ # dashboard.
2050
+ tcAlias: 'hippa',
2051
+
2052
+ # Name of the contract or document if not using an alias.
2053
+ tcName: 'HIPPA Disclosure',
2054
+
2055
+ # Full text of the contract or disclosure if not using an alias.
2056
+ tcContent: 'Full contract text',
2057
+
2058
+ # File format for the signature image.
2059
+ sigFormat: SignatureFormat::PNG,
2060
+
2061
+ # Width of the signature image in pixels.
2062
+ sigWidth: 200,
2063
+
2064
+ # Whether or not a signature is required. Defaults to true.
2065
+ sigRequired: true
2066
+ }
2067
+
2068
+ response = blockchyp.termsAndConditions(request)
2069
+
2070
+ puts "Response: #{response.inspect}"
2071
+
2072
+
2073
+ ```
2074
+
2075
+ #### List Templates
2076
+
2077
+
2078
+
2079
+ * **API Credential Types:** Merchant
2080
+ * **Required Role:** Terms & Conditions Management
2081
+
2082
+ This API returns all terms and conditions templates associated with a merchant account.
2083
+
2084
+
2085
+
2086
+
2087
+ ```ruby
2088
+ # frozen_string_literal: true
2089
+
2090
+ require 'blockchyp'
2091
+
2092
+ blockchyp = BlockChyp::BlockChyp.new(
2093
+ ENV['BC_API_KEY'],
2094
+ ENV['BC_BEARER_TOKEN'],
2095
+ ENV['BC_SIGNING_KEY']
2096
+ )
2097
+
2098
+ # Set request parameters
2099
+ request = {
2100
+ }
2101
+
2102
+ response = blockchyp.tcTemplates(request)
2103
+
2104
+ puts "Response: #{response.inspect}"
2105
+
2106
+
2107
+ ```
2108
+
2109
+ #### Get Template
2110
+
2111
+
2112
+
2113
+ * **API Credential Types:** Merchant
2114
+ * **Required Role:** Terms & Conditions Management
2115
+
2116
+ This API returns as single terms and conditions template.
2117
+
2118
+
2119
+
2120
+
2121
+ ```ruby
2122
+ # frozen_string_literal: true
2123
+
2124
+ require 'blockchyp'
2125
+
2126
+ blockchyp = BlockChyp::BlockChyp.new(
2127
+ ENV['BC_API_KEY'],
2128
+ ENV['BC_BEARER_TOKEN'],
2129
+ ENV['BC_SIGNING_KEY']
2130
+ )
2131
+
2132
+ # Set request parameters
2133
+ request = {
2134
+ templateId: '<TEMPLATE ID>'
2135
+ }
2136
+
2137
+ response = blockchyp.tcTemplate(request)
2138
+
2139
+ puts "Response: #{response.inspect}"
2140
+
2141
+
2142
+ ```
2143
+
2144
+ #### Update Template
2145
+
2146
+
2147
+
2148
+ * **API Credential Types:** Merchant
2149
+ * **Required Role:** Terms & Conditions Management
2150
+
2151
+ This API updates or creates a terms and conditions template.
2152
+
2153
+ Terms and conditions templates are fairly simple and essentially consist of a name, content, and alias.
2154
+
2155
+ The name is the caption that will be displayed at the top of the screen. The alias is a code or short
2156
+ description that will be used in subsequence API calls to refer to the template.
2157
+
2158
+ Content is the full text of the contract or agreement. Currently, no special formatting or
2159
+ merge behavior is supported. Only plain text is supported.
2160
+
2161
+
2162
+
2163
+
2164
+ ```ruby
2165
+ # frozen_string_literal: true
2166
+
2167
+ require 'blockchyp'
2168
+
2169
+ blockchyp = BlockChyp::BlockChyp.new(
2170
+ ENV['BC_API_KEY'],
2171
+ ENV['BC_BEARER_TOKEN'],
2172
+ ENV['BC_SIGNING_KEY']
2173
+ )
2174
+
2175
+ # Set request parameters
2176
+ request = {
2177
+ alias: 'HIPPA',
2178
+ name: 'HIPPA Disclosure',
2179
+ content: 'Lorem ipsum dolor sit amet.'
2180
+ }
2181
+
2182
+ response = blockchyp.tcUpdateTemplate(request)
2183
+
2184
+ puts "Response: #{response.inspect}"
2185
+
2186
+
2187
+ ```
2188
+
2189
+ #### Delete Template
2190
+
2191
+
2192
+
2193
+ * **API Credential Types:** Merchant
2194
+ * **Required Role:** Terms & Conditions Management
2195
+
2196
+ This API deletes a terms and conditions template.
2197
+
2198
+ If a template is deleted, its alias can be reused and any previous Terms & Conditions log entry
2199
+ derived from the template being deleted is fully preserved since log entries always include
2200
+ a complete independent copy of the agreement text.
2201
+
2202
+
2203
+
2204
+
2205
+ ```ruby
2206
+ # frozen_string_literal: true
2207
+
2208
+ require 'blockchyp'
2209
+
2210
+ blockchyp = BlockChyp::BlockChyp.new(
2211
+ ENV['BC_API_KEY'],
2212
+ ENV['BC_BEARER_TOKEN'],
2213
+ ENV['BC_SIGNING_KEY']
2214
+ )
2215
+
2216
+ # Set request parameters
2217
+ request = {
2218
+ templateId: '<TEMPLATE ID>'
2219
+ }
2220
+
2221
+ response = blockchyp.tcDeleteTemplate(request)
2222
+
2223
+ puts "Response: #{response.inspect}"
2224
+
2225
+
2226
+ ```
2227
+
2228
+ #### Terms & Conditions Log
2229
+
2230
+
2231
+
2232
+ * **API Credential Types:** Merchant
2233
+ * **Required Role:** Terms & Conditions Management
2234
+
2235
+ This API allows developers to search and sort through terms and conditions log entries.
2236
+
2237
+ The default API call with no parameters will return the last 250 log entries in descending order.
2238
+
2239
+ Optional parameters can be used to filter and query the data set.
2240
+
2241
+ * **transactionId:** If provided, returns only those log entries associated with a specific transactions. Paging and date filters are ignored if this parameter is used.
2242
+ * **maxResults:** The max number of results to return in a single page. Defaults to 250 and 250 is the maximum value.
2243
+ * **startIndex** The zero based start index of results within the full result set to return. Used to advance pages. For example, if the page size is 10 and you wish to return the second page of results, send a startIndex of 10.
2244
+ * **startDate**: An optional start date for results provided as an ISO 8601 timestamp. (e.g. 2022-05-24T13:51:38+00:00)
2245
+ * **endDate**: An optional end date for results provided as an ISO 8601 timestamp. (e.g. 2022-05-24T13:51:38+00:00)
2246
+
2247
+
2248
+
2249
+
2250
+ ```ruby
2251
+ # frozen_string_literal: true
2252
+
2253
+ require 'blockchyp'
2254
+
2255
+ blockchyp = BlockChyp::BlockChyp.new(
2256
+ ENV['BC_API_KEY'],
2257
+ ENV['BC_BEARER_TOKEN'],
2258
+ ENV['BC_SIGNING_KEY']
2259
+ )
2260
+
2261
+ # Set request parameters
2262
+ request = {
2263
+ logEntryId: '<LOG ENTRY ID>'
2264
+ }
2265
+
2266
+ response = blockchyp.tcLog(request)
2267
+
2268
+ puts "Response: #{response.inspect}"
2269
+
2270
+
2271
+ ```
2272
+
2273
+ #### Terms & Conditions Details
2274
+
2275
+
2276
+
2277
+ * **API Credential Types:** Merchant
2278
+ * **Required Role:** Terms & Conditions Management
2279
+
2280
+ This API returns details for a single terms and conditions log entry. The `logEntryId` of the record to be returned is the only required parameter.
2281
+
2282
+ The signature image is returned as Base 64 encoded binary in the image format specified by the `sigFormat` field.
2283
+ The default format is PNG.
2284
+
2285
+
2286
+
2287
+
2288
+ ```ruby
2289
+ # frozen_string_literal: true
2290
+
2291
+ require 'blockchyp'
2292
+
2293
+ blockchyp = BlockChyp::BlockChyp.new(
2294
+ ENV['BC_API_KEY'],
2295
+ ENV['BC_BEARER_TOKEN'],
2296
+ ENV['BC_SIGNING_KEY']
2297
+ )
2298
+
2299
+ # Set request parameters
2300
+ request = {
2301
+ logEntryId: '<ENTRY ID>'
2302
+ }
2303
+
2304
+ response = blockchyp.tcEntry(request)
2305
+
2306
+ puts "Response: #{response.inspect}"
2307
+
2308
+
2309
+ ```
2310
+
2311
+ ### Token Management
2312
+
2313
+
2314
+ BlockChyp supports saved payments and recurring payments through the use of tokens. Tokens can be created
2315
+ via the Enroll API or the web tokenizer. Once created, these tokens can be used for subsequent payments
2316
+ or associated with customer records as saved payment methods.
2317
+
2318
+ Tokens are limited to a single merchant by default, but can be shared across an organization for multi-location
2319
+ merchants by special arrangement with BlockChyp. Contact your BlockChyp rep to setup token sharing.
2320
+
2321
+
2322
+
2323
+ #### Enroll
2324
+
2325
+
2326
+
2327
+ * **API Credential Types:** Merchant
2328
+ * **Required Role:** Payment API Access
2329
+
2330
+ This API allows you to tokenize and enroll a payment method in the token
2331
+ vault. You can also pass in customer information and associate the
2332
+ payment method with a customer record.
2333
+
2334
+ A token is returned in the response that can be used in subsequent charge,
2335
+ preauth, and refund transactions.
2336
+
2337
+ **Gift Cards and EBT**
2338
+
2339
+ Gift Cards and EBT cards cannot be tokenized.
2340
+
2341
+ **E-Commerce Tokens**
2342
+
2343
+ The tokens returned by the enroll API and the e-commerce web tokenizer
2344
+ are the same tokens and can be used interchangeably.
2345
+
2346
+
2347
+
2348
+
2349
+ ```ruby
2350
+ # frozen_string_literal: true
2351
+
2352
+ require 'blockchyp'
2353
+
2354
+ blockchyp = BlockChyp::BlockChyp.new(
2355
+ ENV['BC_API_KEY'],
2356
+ ENV['BC_BEARER_TOKEN'],
2357
+ ENV['BC_SIGNING_KEY']
2358
+ )
2359
+
2360
+ # Set request parameters
2361
+ request = {
2362
+ test: true,
2363
+ terminalName: 'Test Terminal'
2364
+ }
2365
+
2366
+ response = blockchyp.enroll(request)
2367
+
2368
+ puts "Response: #{response.inspect}"
2369
+
2370
+
2371
+ ```
2372
+
2373
+ #### Token Metadata
2374
+
2375
+
2376
+
2377
+ * **API Credential Types:** Merchant
2378
+ * **Required Role:** Payment API Access
2379
+
2380
+ This API retrieves status and metadata information about a token,
2381
+ including any links to customer records.
2382
+
2383
+ This will also return any customer records related to the card
2384
+ behind the token. If the underlying card has been tokenized
2385
+ multiple times, all customers related to the card will be returned,
2386
+ even if those customer associations are related to other tokens.
2387
+
2388
+
2389
+
2390
+
2391
+ ```ruby
2392
+ # frozen_string_literal: true
2393
+
2394
+ require 'blockchyp'
2395
+
2396
+ blockchyp = BlockChyp::BlockChyp.new(
2397
+ ENV['BC_API_KEY'],
2398
+ ENV['BC_BEARER_TOKEN'],
2399
+ ENV['BC_SIGNING_KEY']
2400
+ )
2401
+
2402
+ # Set request parameters
2403
+ request = {
2404
+ token: '<TOKEN>'
2405
+ }
2406
+
2407
+ response = blockchyp.tokenMetadata(request)
2408
+
2409
+ puts "Response: #{response.inspect}"
2410
+
2411
+
2412
+ ```
2413
+
2414
+ #### Link Token
2415
+
2416
+
2417
+
2418
+ * **API Credential Types:** Merchant
2419
+ * **Required Role:** Payment API Access
2420
+
2421
+ This API links a payment token with a customer record. Usually this would only be needed
2422
+ to reverse a previous unlink operation.
2423
+
2424
+
2425
+
2426
+
2427
+ ```ruby
2428
+ # frozen_string_literal: true
2429
+
2430
+ require 'blockchyp'
2431
+
2432
+ blockchyp = BlockChyp::BlockChyp.new(
2433
+ ENV['BC_API_KEY'],
2434
+ ENV['BC_BEARER_TOKEN'],
2435
+ ENV['BC_SIGNING_KEY']
2436
+ )
2437
+
2438
+ # Set request parameters
2439
+ request = {
2440
+ token: '<TOKEN>',
2441
+ customerId: '<CUSTOMER ID>'
2442
+ }
2443
+
2444
+ response = blockchyp.linkToken(request)
2445
+
2446
+ puts "Response: #{response.inspect}"
2447
+
2448
+
2449
+ ```
2450
+
2451
+ #### Unlink Token
2452
+
2453
+
2454
+
2455
+ * **API Credential Types:** Merchant
2456
+ * **Required Role:** Payment API Access
2457
+
2458
+ This API removes a payment token link from a customer record.
2459
+
2460
+ This will remove links between the customer record and all tokens
2461
+ for the same underlying card.
2462
+
2463
+
2464
+
2465
+
2466
+ ```ruby
2467
+ # frozen_string_literal: true
2468
+
2469
+ require 'blockchyp'
2470
+
2471
+ blockchyp = BlockChyp::BlockChyp.new(
2472
+ ENV['BC_API_KEY'],
2473
+ ENV['BC_BEARER_TOKEN'],
2474
+ ENV['BC_SIGNING_KEY']
2475
+ )
2476
+
2477
+ # Set request parameters
2478
+ request = {
2479
+ token: '<TOKEN>',
2480
+ customerId: '<CUSTOMER ID>'
2481
+ }
2482
+
2483
+ response = blockchyp.unlinkToken(request)
2484
+
2485
+ puts "Response: #{response.inspect}"
2486
+
2487
+
2488
+ ```
2489
+
2490
+ #### Delete Token
2491
+
2492
+
2493
+
2494
+ * **API Credential Types:** Merchant
2495
+ * **Required Role:** Payment API Access
2496
+
2497
+ This API deletes a payment token from the gateway. Tokens are automatically deleted if they have not been used
2498
+ for a year.
2499
+
2500
+
2501
+
2502
+
2503
+ ```ruby
2504
+ # frozen_string_literal: true
2505
+
2506
+ require 'blockchyp'
2507
+
2508
+ blockchyp = BlockChyp::BlockChyp.new(
2509
+ ENV['BC_API_KEY'],
2510
+ ENV['BC_BEARER_TOKEN'],
2511
+ ENV['BC_SIGNING_KEY']
2512
+ )
2513
+
2514
+ # Set request parameters
2515
+ request = {
2516
+ token: '<TOKEN>'
2517
+ }
2518
+
2519
+ response = blockchyp.deleteToken(request)
2520
+
2521
+ puts "Response: #{response.inspect}"
2522
+
2523
+
2524
+ ```
2525
+
2526
+ ### Customer Endpoints
2527
+
2528
+
2529
+ These APIs allow developers to create and manage customer records in BlockChyp. Developers who wish to use
2530
+ BlockChyp for tokenized recurring payments can use tokens directly if they have their own customer management
2531
+ system. However, BlockChyp provides additional tools for managing customers and keeping track of a customer's saved
2532
+ payment tokens.
2533
+
2534
+ In addition, if customer features are used, BlockChyp can detect a payment method associated with an existing
2535
+ customer, and return customer data with payment transactions. This can be used as a passive method to detect
2536
+ repeat customers.
2537
+
2538
+
2539
+
2540
+ #### Update Customer
2541
+
2542
+
2543
+
2544
+ * **API Credential Types:** Merchant
2545
+ * **Required Role:** Payment API Access
2546
+
2547
+ This API adds or updates a customer record.
2548
+
2549
+ If you pass in customer information including `firstName`, `lastName`, `email`,
2550
+ or `sms` without any Customer ID or Customer Ref, a new record will
2551
+ be created.
2552
+
2553
+ If you pass in `customerRef` and `customerId`, the customer record will be updated
2554
+ if it exists.
2555
+
2556
+ **Customer Ref**
2557
+
2558
+ The `customerRef` field is optional, but highly recommended as this allows you
2559
+ to use your own customer identifiers instead of storing BlockChyp's Customer IDs
2560
+ in your systems.
2561
+
2562
+ **Creating Customer Records With Payment Transactions**
2563
+
2564
+ If you have customer information available at the time a payment transaction is
2565
+ executed, you can pass all the same customer information directly into a payment transaction. BlockChyp
2566
+ will create a customer record at the same time payment is captured. The advantage of this approach is
2567
+ that the customer's payment card is automatically associated with the customer record in a single step.
2568
+ If the customer uses the payment card in the future, the customer data will automatically
2569
+ be returned. You won't need to ask the customer to provide any additional information.
2570
+
2571
+
2572
+
2573
+
2574
+ ```ruby
2575
+ # frozen_string_literal: true
2576
+
2577
+ require 'blockchyp'
2578
+
2579
+ blockchyp = BlockChyp::BlockChyp.new(
2580
+ ENV['BC_API_KEY'],
2581
+ ENV['BC_BEARER_TOKEN'],
2582
+ ENV['BC_SIGNING_KEY']
2583
+ )
2584
+
2585
+ # Set request parameters
2586
+ request = {
2587
+ customer: {
2588
+ id: '<CUSTOMER ID>',
2589
+ customerRef: 'Customer reference string',
2590
+ firstName: 'FirstName',
2591
+ lastName: 'LastName',
2592
+ companyName: 'Company Name',
2593
+ emailAddress: 'notifications@blockchypteam.m8r.co',
2594
+ smsNumber: '(123) 123-1231'
2595
+ }
2596
+ }
2597
+
2598
+ response = blockchyp.updateCustomer(request)
2599
+
2600
+ puts "Response: #{response.inspect}"
2601
+
2602
+
2603
+ ```
2604
+
2605
+ #### Retrieve Customer
2606
+
2607
+
2608
+
2609
+ * **API Credential Types:** Merchant
2610
+ * **Required Role:** Payment API Access
2611
+
2612
+ With this API, you can retrieve detailed information about a customer record, including saved payment
2613
+ methods if available.
2614
+
2615
+ Customers can be looked up by `customerId` or `customerRef`.
2616
+
2617
+
2618
+
2619
+
2620
+ ```ruby
2621
+ # frozen_string_literal: true
2622
+
2623
+ require 'blockchyp'
2624
+
2625
+ blockchyp = BlockChyp::BlockChyp.new(
2626
+ ENV['BC_API_KEY'],
2627
+ ENV['BC_BEARER_TOKEN'],
2628
+ ENV['BC_SIGNING_KEY']
2629
+ )
2630
+
2631
+ # Set request parameters
2632
+ request = {
2633
+ customerId: '<CUSTOMER ID>'
2634
+ }
2635
+
2636
+ response = blockchyp.customer(request)
2637
+
2638
+ puts "Response: #{response.inspect}"
2639
+
2640
+
2641
+ ```
2642
+
2643
+ #### Search Customer
2644
+
2645
+
2646
+
2647
+ * **API Credential Types:** Merchant
2648
+ * **Required Role:** Payment API Access
2649
+
2650
+ This API searches the customer database and returns matching results.
2651
+
2652
+ Use `query` to pass in a search string and the system will return all results whose
2653
+ first or last names contain the query string.
2654
+
2655
+
2656
+
2657
+
2658
+ ```ruby
2659
+ # frozen_string_literal: true
2660
+
2661
+ require 'blockchyp'
2662
+
2663
+ blockchyp = BlockChyp::BlockChyp.new(
2664
+ ENV['BC_API_KEY'],
2665
+ ENV['BC_BEARER_TOKEN'],
2666
+ ENV['BC_SIGNING_KEY']
2667
+ )
2668
+
2669
+ # Set request parameters
2670
+ request = {
2671
+ query: '(123) 123-1234'
2672
+ }
2673
+
2674
+ response = blockchyp.customerSearch(request)
2675
+
2676
+ puts "Response: #{response.inspect}"
2677
+
2678
+
2679
+ ```
2680
+
2681
+ #### Delete Customer
2682
+
2683
+
2684
+
2685
+ * **API Credential Types:** Merchant
2686
+ * **Required Role:** Payment API Access
2687
+
2688
+ This API deletes a customer record.
2689
+
2690
+
2691
+
2692
+
2693
+ ```ruby
2694
+ # frozen_string_literal: true
2695
+
2696
+ require 'blockchyp'
2697
+
2698
+ blockchyp = BlockChyp::BlockChyp.new(
2699
+ ENV['BC_API_KEY'],
2700
+ ENV['BC_BEARER_TOKEN'],
2701
+ ENV['BC_SIGNING_KEY']
2702
+ )
2703
+
2704
+ # Set request parameters
2705
+ request = {
2706
+ customerId: '<CUSTOMER ID>'
2707
+ }
2708
+
2709
+ response = blockchyp.deleteCustomer(request)
2710
+
2711
+ puts "Response: #{response.inspect}"
2712
+
2713
+
2714
+ ```
2715
+
2716
+ ### Survey Reference
2717
+
2718
+
2719
+ These APIs are used to work with post-transaction surveys and survey data.
2720
+
2721
+ Merchants can optionally configure scaled (1-5) or yes/no questions that can be presented to consumers
2722
+ after every approved Charge and Preauth transaction. Surveys do not require any custom programming and
2723
+ merchants can simply configure them without the point-of-sale system needing any additional customization.
2724
+
2725
+ However, these APIs allow point-of-sale or third-party system developers to integrate survey question configuration
2726
+ or result visualization into their own systems.
2727
+
2728
+
2729
+
2730
+ #### List Questions
2731
+
2732
+
2733
+
2734
+ * **API Credential Types:** Merchant
2735
+ * **Required Role:** Survey Management
2736
+
2737
+ This API returns all survey questions in the order in which they would be presented on the terminal.
2738
+
2739
+ All questions are returned, whether enabled or disabled.
2740
+
2741
+
2742
+
2743
+
2744
+ ```ruby
2745
+ # frozen_string_literal: true
2746
+
2747
+ require 'blockchyp'
2748
+
2749
+ blockchyp = BlockChyp::BlockChyp.new(
2750
+ ENV['BC_API_KEY'],
2751
+ ENV['BC_BEARER_TOKEN'],
2752
+ ENV['BC_SIGNING_KEY']
2753
+ )
2754
+
2755
+ # Set request parameters
2756
+ request = {
2757
+ }
2758
+
2759
+ response = blockchyp.surveyQuestions(request)
2760
+
2761
+ puts "Response: #{response.inspect}"
2762
+
2763
+
2764
+ ```
2765
+
2766
+ #### Question Details
2767
+
2768
+
2769
+
2770
+ * **API Credential Types:** Merchant
2771
+ * **Required Role:** Survey Management
2772
+
2773
+ This API returns a single survey question with response data. `questionId` is required.
2774
+
2775
+
2776
+
2777
+
2778
+ ```ruby
2779
+ # frozen_string_literal: true
2780
+
2781
+ require 'blockchyp'
2782
+
2783
+ blockchyp = BlockChyp::BlockChyp.new(
2784
+ ENV['BC_API_KEY'],
2785
+ ENV['BC_BEARER_TOKEN'],
2786
+ ENV['BC_SIGNING_KEY']
2787
+ )
2788
+
2789
+ # Set request parameters
2790
+ request = {
2791
+ questionId: '<QUESTION ID>'
2792
+ }
2793
+
2794
+ response = blockchyp.surveyQuestion(request)
2795
+
2796
+ puts "Response: #{response.inspect}"
2797
+
2798
+
2799
+ ```
2800
+
2801
+ #### Update Question
2802
+
2803
+
2804
+
2805
+ * **API Credential Types:** Merchant
2806
+ * **Required Role:** Survey Management
2807
+
2808
+ This API updates or creates survey questions. `questionText` and `questionType` are required
2809
+ fields. The following values are valid for `questionType`.
2810
+
2811
+ * **yes_no:** Use for simple yes or no questions.
2812
+ * **scaled:** Displays the question with buttons that allow the customer to respond with values from 1 through 5.
2813
+
2814
+ Questions are disabled by default. Pass in `enabled` to enable a question.
2815
+
2816
+ The `ordinal` field is used to control the sequence of questions when multiple questions are enabled. We recommend keeping
2817
+ the number of questions minimal.
2818
+
2819
+
2820
+
2821
+
2822
+ ```ruby
2823
+ # frozen_string_literal: true
2824
+
2825
+ require 'blockchyp'
2826
+
2827
+ blockchyp = BlockChyp::BlockChyp.new(
2828
+ ENV['BC_API_KEY'],
2829
+ ENV['BC_BEARER_TOKEN'],
2830
+ ENV['BC_SIGNING_KEY']
2831
+ )
2832
+
2833
+ # Set request parameters
2834
+ request = {
2835
+ id: '<QUESTION ID>',
2836
+ ordinal: 1,
2837
+ questionText: 'Would you shop here again?',
2838
+ questionType: 'yes_no',
2839
+ enabled: true
2840
+ }
2841
+
2842
+ response = blockchyp.updateSurveyQuestion(request)
2843
+
2844
+ puts "Response: #{response.inspect}"
2845
+
2846
+
2847
+ ```
2848
+
2849
+ #### Delete Question
2850
+
2851
+
2852
+
2853
+ * **API Credential Types:** Merchant
2854
+ * **Required Role:** Survey Management
2855
+
2856
+ This API deletes a survey question. `questionId` is a required parameter.
2857
+
2858
+
2859
+
2860
+
2861
+ ```ruby
2862
+ # frozen_string_literal: true
2863
+
2864
+ require 'blockchyp'
2865
+
2866
+ blockchyp = BlockChyp::BlockChyp.new(
2867
+ ENV['BC_API_KEY'],
2868
+ ENV['BC_BEARER_TOKEN'],
2869
+ ENV['BC_SIGNING_KEY']
2870
+ )
2871
+
2872
+ # Set request parameters
2873
+ request = {
2874
+ questionId: '<QUESTION ID>'
2875
+ }
2876
+
2877
+ response = blockchyp.deleteSurveyQuestion(request)
2878
+
2879
+ puts "Response: #{response.inspect}"
2880
+
2881
+
2882
+ ```
2883
+
2884
+ #### Survey Results
2885
+
2886
+
2887
+
2888
+ * **API Credential Types:** Merchant
2889
+ * **Required Role:** Survey Management
2890
+
2891
+ This API returns survey results for a single question.
2892
+
2893
+ The results returned include the response rate, which is the percentage of transactions after which
2894
+ the consumer provided an answer.
2895
+
2896
+ The `responses` array breaks down the results by answer, providing the total number of responses,
2897
+ the answer's percentage of the total, and the average transaction amount associated with a specific
2898
+ answer.
2899
+
2900
+ By default, all results based on all responses are returned. However, developers may optionally provide
2901
+ `startDate` and `endDate` parameters to return only responses provided between certain dates.
2902
+
2903
+ `startDate` and `endDate` can be provided in MM/DD/YYYY or YYYY-MM-DD format.
2904
+
2905
+
2906
+
2907
+
2908
+ ```ruby
2909
+ # frozen_string_literal: true
2910
+
2911
+ require 'blockchyp'
2912
+
2913
+ blockchyp = BlockChyp::BlockChyp.new(
2914
+ ENV['BC_API_KEY'],
2915
+ ENV['BC_BEARER_TOKEN'],
2916
+ ENV['BC_SIGNING_KEY']
2917
+ )
2918
+
2919
+ # Set request parameters
2920
+ request = {
2921
+ questionId: '<QUESTION ID>'
2922
+ }
2923
+
2924
+ response = blockchyp.surveyResults(request)
2925
+
2926
+ puts "Response: #{response.inspect}"
2927
+
2928
+
2929
+ ```
2930
+
2931
+ ### Media and Branding Control
2932
+
2933
+
2934
+ BlockChyp has a sophisticated terminal media and branding control platform. Terminals can be configured to
2935
+ display logos, images, videos, and slide shows when a terminal is idle. Branding assets can be configured
2936
+ at the partner, organization, and merchant level with fine-grained hour-by-hour schedules, if desired.
2937
+
2938
+ Conceptually, all branding and media start with the media library. Merchants, Partners, and Organizations can
2939
+ upload images or video and build branding assets from uploaded media.
2940
+
2941
+ Slide shows can combine images from the media library into a timed loop of repeating images.
2942
+
2943
+ Branding Assets can then be used to combine media or slide shows with priority and timing rules to create what
2944
+ we call the Terminal Branding Stack.
2945
+
2946
+ We call a group of branding assets the *Terminal Branding Stack* because there are implicit rules about which
2947
+ branding assets take priority. For example, a merchant with no branding assets configured will inherit the
2948
+ branding rules from any organization to which the merchant may belong. If the merchant doesn't belong to an organization
2949
+ or the organization has no branding rules configured, then the system will defer to branding defaults established
2950
+ by the point-of-sale or software partner that owns the merchant.
2951
+
2952
+ This feature enables partners and organizations (multi-store operators and large national chains) to configure branding
2953
+ for potentially thousands of terminals from a single interface.
2954
+
2955
+ Terminal Branding can also be configured at the individual terminal level and a merchant's terminal fleet
2956
+ can be broken into groups and branding configured at the group level. Branding configured at the terminal
2957
+ level will always override branding from any higher level group.
2958
+
2959
+ The order of priority for the Terminal Branding Stack is given below.
2960
+
2961
+ * Terminal
2962
+ * Terminal Group
2963
+ * Merchant
2964
+ * Organization (Region, Chain, etc)
2965
+ * Partner
2966
+ * BlockChyp Default Logo
2967
+
2968
+
2969
+
2970
+ #### Media Library
2971
+
2972
+
2973
+
2974
+ * **API Credential Types:** Merchant, Partner, & Organization
2975
+ * **Required Role:** Media Management
2976
+
2977
+ This API returns the entire media library associated with the API Credentials (Merchant, Partner, or Organization). The media library results will include the ID used
2978
+ to reference a media asset in slide shows and branding assets along with the full file url and thumbnail.
2979
+
2980
+
2981
+
2982
+
2983
+ ```ruby
2984
+ # frozen_string_literal: true
2985
+
2986
+ require 'blockchyp'
2987
+
2988
+ blockchyp = BlockChyp::BlockChyp.new(
2989
+ ENV['BC_API_KEY'],
2990
+ ENV['BC_BEARER_TOKEN'],
2991
+ ENV['BC_SIGNING_KEY']
2992
+ )
2993
+
2994
+ # Set request parameters
2995
+ request = {
2996
+ }
2997
+
2998
+ response = blockchyp.media(request)
2999
+
3000
+ puts "Response: #{response.inspect}"
3001
+
3002
+
3003
+ ```
3004
+
3005
+ #### Upload Media
3006
+
3007
+
3008
+
3009
+ * **API Credential Types:** Merchant, Partner, & Organization
3010
+ * **Required Role:** Media Management
3011
+
3012
+ This API supports media library uploads. The operation of this API works slightly differently depending
3013
+ on the SDK platform. In all cases, the intent is to allow the file's binary to be passed into the SDK using
3014
+ the lowest level I/O primitive possible in order to support situations where developers aren't working
3015
+ with literal files. It might be (and usually is) more convenient to work with buffers, raw bytes, or streams.
3016
+
3017
+ For example, the Go implementation accepts an `io.Reader` and the Java implementation accepts a
3018
+ `java.io.InputStream`. The CLI does accept a literal File URL via the `-file` command line parameter.
3019
+
3020
+ The following file formats are accepted as valid uploads:
3021
+
3022
+ * .png
3023
+ * .jpg
3024
+ * .jpeg
3025
+ * .gif
3026
+ * .mov
3027
+ * .mpg
3028
+ * .mp4
3029
+ * .mpeg
3030
+
3031
+ The UploadMetadata object allows developers to pass additional metadata about the upload including
3032
+ `fileName`, `fileSize`, and `uploadId`.
3033
+
3034
+ None of these values are required, but providing them can unlock some additional functionality relating to
3035
+ media uploads. `fileName` will be used to record the original file name in the media library. `fileSize`
3036
+ and `uploadId` are used to support upload status tracking, which is especially useful for large video file
3037
+ uploads.
3038
+
3039
+ The `fileSize` should be the file's full size in bytes.
3040
+
3041
+ The `uploadId` value can be any random string. This is the value you'll use to check the status of an upload
3042
+ via the Upload Status API. This API will return information needed to drive progress feedback on uploads and
3043
+ return video transcoding information.
3044
+
3045
+
3046
+
3047
+
3048
+ ```ruby
3049
+ # frozen_string_literal: true
3050
+
3051
+ require 'blockchyp'
3052
+
3053
+ blockchyp = BlockChyp::BlockChyp.new(
3054
+ ENV['BC_API_KEY'],
3055
+ ENV['BC_BEARER_TOKEN'],
3056
+ ENV['BC_SIGNING_KEY']
3057
+ )
3058
+
3059
+ # Set request parameters
3060
+ request = {
3061
+ fileName: 'aviato.png',
3062
+ fileSize: 18843,
3063
+ uploadId: '<RANDOM ID>'
3064
+ }
3065
+
3066
+ file = File.open("aviato.png")
3067
+ content = file.read
3068
+ response = blockchyp.uploadMedia(request, content)
3069
+
3070
+ puts "Response: #{response.inspect}"
3071
+
3072
+
3073
+ ```
3074
+
3075
+ #### Upload Status
3076
+
3077
+
3078
+
3079
+ * **API Credential Types:** Merchant, Partner, & Organization
3080
+ * **Required Role:** Media Management
3081
+
3082
+ This API returns status and progress information about in progress or recently completed uploads.
3083
+
3084
+ Before calling this API, developers must first start a file upload with `fileSize` and `uploadId` parameters.
3085
+
3086
+ The data structure returned will include the file size, number of bytes uploaded, a narrative status
3087
+ and flags indicating whether or not the upload is complete or post upload processing is in progress.
3088
+ If the upload is completed, the ID assigned to the media asset and a link to the thumbnail image will
3089
+ also be returned.
3090
+
3091
+
3092
+
3093
+
3094
+ ```ruby
3095
+ # frozen_string_literal: true
3096
+
3097
+ require 'blockchyp'
3098
+
3099
+ blockchyp = BlockChyp::BlockChyp.new(
3100
+ ENV['BC_API_KEY'],
3101
+ ENV['BC_BEARER_TOKEN'],
3102
+ ENV['BC_SIGNING_KEY']
3103
+ )
3104
+
3105
+ # Set request parameters
3106
+ request = {
3107
+ uploadId: '<UPLOAD ID>'
3108
+ }
3109
+
3110
+ response = blockchyp.uploadStatus(request)
3111
+
3112
+ puts "Response: #{response.inspect}"
3113
+
3114
+
3115
+ ```
3116
+
3117
+ #### Get Media Asset
3118
+
3119
+
3120
+
3121
+ * **API Credential Types:** Merchant, Partner, & Organization
3122
+ * **Required Role:** Media Management
3123
+
3124
+ This API returns a detailed media asset. The data returned includes the exact same media information returned
3125
+ by the full media library endpoint, including fully qualified URLs pointing to the original media file
3126
+ and the thumbnail.
3127
+
3128
+
3129
+
3130
+
3131
+ ```ruby
3132
+ # frozen_string_literal: true
3133
+
3134
+ require 'blockchyp'
3135
+
3136
+ blockchyp = BlockChyp::BlockChyp.new(
3137
+ ENV['BC_API_KEY'],
3138
+ ENV['BC_BEARER_TOKEN'],
3139
+ ENV['BC_SIGNING_KEY']
3140
+ )
3141
+
3142
+ # Set request parameters
3143
+ request = {
3144
+ mediaId: '<MEDIA ASSET ID>'
3145
+ }
3146
+
3147
+ response = blockchyp.mediaAsset(request)
3148
+
3149
+ puts "Response: #{response.inspect}"
3150
+
3151
+
3152
+ ```
3153
+
3154
+ #### Delete Media Asset
3155
+
3156
+
3157
+
3158
+ * **API Credential Types:** Merchant, Partner, & Organization
3159
+ * **Required Role:** Media Management
3160
+
3161
+ This API deletes a media asset. Note that a media asset cannot be deleted if it is in use in a slide
3162
+ show or in the terminal branding stack.
3163
+
3164
+
3165
+
3166
+
3167
+ ```ruby
3168
+ # frozen_string_literal: true
3169
+
3170
+ require 'blockchyp'
3171
+
3172
+ blockchyp = BlockChyp::BlockChyp.new(
3173
+ ENV['BC_API_KEY'],
3174
+ ENV['BC_BEARER_TOKEN'],
3175
+ ENV['BC_SIGNING_KEY']
3176
+ )
3177
+
3178
+ # Set request parameters
3179
+ request = {
3180
+ mediaId: '<MEDIA ASSET ID>'
3181
+ }
3182
+
3183
+ response = blockchyp.deleteMediaAsset(request)
3184
+
3185
+ puts "Response: #{response.inspect}"
3186
+
3187
+
3188
+ ```
3189
+
3190
+ #### List Slide Shows
3191
+
3192
+
3193
+
3194
+ * **API Credential Types:** Merchant, Partner, & Organization
3195
+ * **Required Role:** Media Management
3196
+
3197
+ This API returns all slide shows.
3198
+
3199
+ Note that slide level data is not returned with this API. Use the Get Slide Show API to get slide level detail.
3200
+
3201
+
3202
+
3203
+
3204
+ ```ruby
3205
+ # frozen_string_literal: true
3206
+
3207
+ require 'blockchyp'
3208
+
3209
+ blockchyp = BlockChyp::BlockChyp.new(
3210
+ ENV['BC_API_KEY'],
3211
+ ENV['BC_BEARER_TOKEN'],
3212
+ ENV['BC_SIGNING_KEY']
3213
+ )
3214
+
3215
+ # Set request parameters
3216
+ request = {
3217
+ }
3218
+
3219
+ response = blockchyp.slideShows(request)
3220
+
3221
+ puts "Response: #{response.inspect}"
3222
+
3223
+
3224
+ ```
3225
+
3226
+ #### Get Slide Show
3227
+
3228
+
3229
+
3230
+ * **API Credential Types:** Merchant, Partner, & Organization
3231
+ * **Required Role:** Media Management
3232
+
3233
+ This API returns a single slide show. Slide level detail is returned with the fully qualified thumbnail URL
3234
+ for each slide.
3235
+
3236
+ `slideShowId` is the only required parameter.
3237
+
3238
+
3239
+
3240
+
3241
+ ```ruby
3242
+ # frozen_string_literal: true
3243
+
3244
+ require 'blockchyp'
3245
+
3246
+ blockchyp = BlockChyp::BlockChyp.new(
3247
+ ENV['BC_API_KEY'],
3248
+ ENV['BC_BEARER_TOKEN'],
3249
+ ENV['BC_SIGNING_KEY']
3250
+ )
3251
+
3252
+ # Set request parameters
3253
+ request = {
3254
+ slideShowId: '<SLIDE SHOW ID>'
3255
+ }
3256
+
3257
+ response = blockchyp.slideShow(request)
3258
+
3259
+ puts "Response: #{response.inspect}"
3260
+
3261
+
3262
+ ```
3263
+
3264
+ #### Update Slide Show
3265
+
3266
+
3267
+
3268
+ * **API Credential Types:** Merchant, Partner, & Organization
3269
+ * **Required Role:** Media Management
3270
+
3271
+ This API updates or creates a slide show. `name`, `delay` and `slides` are required.
3272
+
3273
+ The slides property is an array of slides. The Slide data structure has ordinal and thumbnail URL fields,
3274
+ but these are not required when updating or creating a slide show. Only the `mediaId` field is required
3275
+ when updating or creating a slide show.
3276
+
3277
+ When using the CLI, slides can be specified by sending a comma-separated list of media ids via the `-mediaId`
3278
+ parameter.
3279
+
3280
+
3281
+
3282
+
3283
+ ```ruby
3284
+ # frozen_string_literal: true
3285
+
3286
+ require 'blockchyp'
3287
+
3288
+ blockchyp = BlockChyp::BlockChyp.new(
3289
+ ENV['BC_API_KEY'],
3290
+ ENV['BC_BEARER_TOKEN'],
3291
+ ENV['BC_SIGNING_KEY']
3292
+ )
3293
+
3294
+ # Set request parameters
3295
+ request = {
3296
+ name: 'Test Slide Show',
3297
+ delay: 5,
3298
+ slides: [
3299
+ {
3300
+ mediaId: '<MEDIA ID>'
3301
+ }
3302
+ ]
3303
+ }
3304
+
3305
+ response = blockchyp.updateSlideShow(request)
3306
+
3307
+ puts "Response: #{response.inspect}"
3308
+
3309
+
3310
+ ```
3311
+
3312
+ #### Delete Slide Show
3313
+
3314
+
3315
+
3316
+ * **API Credential Types:** Merchant, Partner, & Organization
3317
+ * **Required Role:** Media Management
3318
+
3319
+ This API deletes a slide show `slideShowId` is the only required parameter.
3320
+
3321
+
3322
+
3323
+
3324
+ ```ruby
3325
+ # frozen_string_literal: true
3326
+
3327
+ require 'blockchyp'
3328
+
3329
+ blockchyp = BlockChyp::BlockChyp.new(
3330
+ ENV['BC_API_KEY'],
3331
+ ENV['BC_BEARER_TOKEN'],
3332
+ ENV['BC_SIGNING_KEY']
3333
+ )
3334
+
3335
+ # Set request parameters
3336
+ request = {
3337
+ slideShowId: '<SLIDE SHOW ID>'
3338
+ }
3339
+
3340
+ response = blockchyp.deleteSlideShow(request)
3341
+
3342
+ puts "Response: #{response.inspect}"
3343
+
3344
+
3345
+ ```
3346
+
3347
+ #### Terminal Branding
3348
+
3349
+
3350
+
3351
+ * **API Credential Types:** Merchant, Partner, & Organization
3352
+ * **Required Role:** Media Management
3353
+
3354
+ This API returns the full branding stack for a given API scope in the order of priority.
3355
+
3356
+ Consumers of this API should pay special attention to the `editable` field. This field indicates whether or
3357
+ not a branding asset is read-only from the perspective of a particular API Credential scope.
3358
+
3359
+ The `thumbnail` and `previewImage` attributes can be used to support building user interfaces for
3360
+ managing the branding stack. `previewImage` differs from `thumbnail` in that the preview image is
3361
+ intended to show how an asset would actually look when displayed on the terminal.
3362
+
3363
+ `activeAsset` returns the asset that is currently visible on the terminal.
3364
+
3365
+
3366
+
3367
+
3368
+ ```ruby
3369
+ # frozen_string_literal: true
3370
+
3371
+ require 'blockchyp'
3372
+
3373
+ blockchyp = BlockChyp::BlockChyp.new(
3374
+ ENV['BC_API_KEY'],
3375
+ ENV['BC_BEARER_TOKEN'],
3376
+ ENV['BC_SIGNING_KEY']
3377
+ )
3378
+
3379
+ # Set request parameters
3380
+ request = {
3381
+ }
3382
+
3383
+ response = blockchyp.terminalBranding(request)
3384
+
3385
+ puts "Response: #{response.inspect}"
3386
+
3387
+
3388
+ ```
3389
+
3390
+ #### Update Branding Asset
3391
+
3392
+
3393
+
3394
+ * **API Credential Types:** Merchant, Partner, & Organization
3395
+ * **Required Role:** Media Management
3396
+
3397
+ This API updates or creates a single Branding Asset.
3398
+
3399
+ Branding Assets represent a single element of the terminal branding stack. A Branding Asset can be a video or image,
3400
+ in which case a `mediaId` referencing an asset from the media library must be provided. A Branding Asset can also
3401
+ be a slide show, in which case `slideShowId` must be provided. Branding Assets must have a valid `mediaId` or a valid
3402
+ `slideShowId`. The optional `notes` field can be used to provide short notes and descriptions for a Branding asset.
3403
+
3404
+ **Visibility Flags**
3405
+
3406
+ In order for a Branding Asset to be visible on a terminal, the `enabled` flag must be set to true and the `preview`
3407
+ must be turned off. `preview` is intended to show how a proposed Branding Asset will behave
3408
+ without pushing it to live terminals. The Publish button in the BlockChyp merchant portal effectively turns
3409
+ the `preview` setting off.
3410
+
3411
+ **Order and Sequencing**
3412
+
3413
+ The `ordinal` field is used to specify priority for a Branding Asset. Assets with a higher value for `ordinal`
3414
+ will be prioritized first.
3415
+
3416
+ **Padding Images**
3417
+
3418
+ For plain images, it's sometimes helpful to add margins to images. This is especially helpful with logos
3419
+ or any image file rendered without any white space or margins between the image content and edge of the image file.
3420
+ Set the `padded` flag to true if you'd like BlockChyp to auto apply margins when displaying an image on
3421
+ the terminal.
3422
+
3423
+ **Scheduling**
3424
+
3425
+ By default, a Branding Asset placed on top of the Branding Stack, if it's `enabled` and not in `preview`
3426
+ mode, will immediately be displayed on the terminal round the clock.
3427
+
3428
+ Branding Assets can be scheduled with effective start and stop dates for seasonal campaigns. These assets can
3429
+ also be scheduled for specific times of day and specific days of the week.
3430
+
3431
+ * **startDate:** Optional date after which the Branding Asset is eligible for display. Can be provided in MM/DD/YYYY or YYYY-MM-DD format.
3432
+ * **endDate:** Optional date before which the Branding Asset is eligible for display. Can be provided in MM/DD/YYYY or YYYY-MM-DD format.
3433
+ * **startTime** Optional time of day after which the branding asset is eligible for display. Must be provided in 24 hour time: HH:MM.
3434
+ * **endTime** Optional time of day before which the branding asset is eligible for display. Must be provided in 24 hour time format: HH:MM
3435
+ * **daysOfWeek** For branding assets that should only be displayed on certain days of the week, this field is an array of day of the week constants. (Constants vary by SDK platform.)
3436
+
3437
+ **Read Only Fields**
3438
+
3439
+ The Branding Asset data structure has a number of read only fields that are returned when Branding Assets are
3440
+ retrieved. But these fields are ignored when you try to send them as part of an update. These are derived
3441
+ or calculated fields and are helpful for displaying branding assets in a management user interface, but
3442
+ cannot be changed via an API call.
3443
+
3444
+ These fields are:
3445
+
3446
+ * ownerId
3447
+ * merchantId
3448
+ * organizationId
3449
+ * partnerId
3450
+ * userId
3451
+ * userName
3452
+ * thumbnail
3453
+ * lastModified
3454
+ * editable
3455
+ * assetType
3456
+ * ownerType
3457
+ * ownerTypeCaption
3458
+ * previewImage
3459
+ * narrativeEffectiveDates
3460
+ * narrativeDisplayPeriod
3461
+
3462
+
3463
+
3464
+
3465
+ ```ruby
3466
+ # frozen_string_literal: true
3467
+
3468
+ require 'blockchyp'
3469
+
3470
+ blockchyp = BlockChyp::BlockChyp.new(
3471
+ ENV['BC_API_KEY'],
3472
+ ENV['BC_BEARER_TOKEN'],
3473
+ ENV['BC_SIGNING_KEY']
3474
+ )
3475
+
3476
+ # Set request parameters
3477
+ request = {
3478
+ mediaId: '<MEDIA ID>',
3479
+ padded: true,
3480
+ ordinal: 10,
3481
+ startDate: '01/06/2021',
3482
+ startTime: '14:00',
3483
+ endDate: '11/05/2024',
3484
+ endTime: '16:00',
3485
+ notes: 'Test Branding Asset',
3486
+ preview: false,
3487
+ enabled: true
3488
+ }
3489
+
3490
+ response = blockchyp.updateBrandingAsset(request)
3491
+
3492
+ puts "Response: #{response.inspect}"
3493
+
3494
+
3495
+ ```
3496
+
3497
+ #### Delete Branding Asset
3498
+
3499
+
3500
+
3501
+ * **API Credential Types:** Merchant, Partner, & Organization
3502
+ * **Required Role:** Media Management
3503
+
3504
+ This API deletes a Branding Asset from the branding stack.
3505
+
3506
+ Note that deleting a Branding Asset does not delete the underlying media from the media library or slide
3507
+ show from the slide show library.
3508
+
3509
+
3510
+
3511
+
3512
+ ```ruby
3513
+ # frozen_string_literal: true
3514
+
3515
+ require 'blockchyp'
3516
+
3517
+ blockchyp = BlockChyp::BlockChyp.new(
3518
+ ENV['BC_API_KEY'],
3519
+ ENV['BC_BEARER_TOKEN'],
3520
+ ENV['BC_SIGNING_KEY']
3521
+ )
3522
+
3523
+ # Set request parameters
3524
+ request = {
3525
+ assetId: '<BRANDING ASSET ID>'
3526
+ }
3527
+
3528
+ response = blockchyp.deleteBrandingAsset(request)
3529
+
3530
+ puts "Response: #{response.inspect}"
3531
+
3532
+
3533
+ ```
3534
+
3535
+ ### Merchant Management
3536
+
3537
+
3538
+ These APIs allow partners to manage and configure their merchant portfolios.
3539
+
3540
+ Use of these APIs (other than the Merchant Profile API) requires partner scoped API credentials
3541
+ with special roles and permissions that may require a special arrangement with BlockChyp.
3542
+
3543
+ For example, Partners usually can't board merchants directly, but must board merchants using
3544
+ the standard underwriting process via offer codes and invitations.
3545
+
3546
+
3547
+
3548
+ #### Merchant Profile
3549
+
3550
+
3551
+
3552
+ * **API Credential Types:** Merchant
3553
+ * **Required Role:** Payment API Access
3554
+
3555
+ The API returns detailed metadata about the merchant's configuration, including
3556
+ basic identity information, terminal settings, store and forward settings,
3557
+ and bank account information for merchants that support split settlement.
3558
+
3559
+ Some of these fields can be updated via the Update Merchant API, but many of these
3560
+ fields are controlled by underwriting and cannot be altered outside of the
3561
+ underwriting and risk processes.
3562
+
3563
+ **Merchant Descriptive Fields**
3564
+
3565
+ The following fields are basic descriptive fields that can be used to describe and identify merchants.
3566
+
3567
+ * **companyName:** The merchant's official corporate entity name.
3568
+ * **dbaName:** The business's DBA (doing business as) name.
3569
+ * **contactName:** Name of the merchant's primary control contact.
3570
+ * **contactNumber:** Primary control contact's phone number.
3571
+ * **locationName:** Optional location name for multi-location operators.
3572
+ * **storeNumber:** Optional store number for multi-location operators.
3573
+ * **partnerRef:** Optional reference number partners can add to a merchant record. Usually the partner's own identifier for the merchant.
3574
+ * **timeZone:** Unix style local time zone for the merchant. Example: America/New_York.
3575
+ * **publicKey:** Read only field. The merchant's blockchain public key. Generated and assigned when a merchant account is first created.
3576
+ * **billingAddress:** Address for billing and written correspondence.
3577
+ * **shippingAddress:** Physical shipping address. Usually the actual street address of the business.
3578
+ * **status:** Current status of the merchant account.
3579
+ * **tcDisabled:** Disables all terms and conditions features in the merchant dashboard. Used to hide the feature if a partner has not chosen to support it.
3580
+ * **gatewayOnly:** Indicates that a merchant has been boarded in gateway only mode. Not common.
3581
+
3582
+ **Batch and Terminal Settings**
3583
+
3584
+ The following fields are used to control batch closure and high level terminal configuration.
3585
+
3586
+ * **batchCloseTime:** Time in 24 hour HH:MM format when batches will automatically close in the merchant's local time. Defaults to 3 AM.
3587
+ * **autoBatchClose:** Flag the determines whether or not batches will automatically close. Defaults to true.
3588
+ * **disableBatchEmails:** Flag that optionally turns off automatic batch closure notification emails.
3589
+ * **cooldownTimeout:** The amount of time in seconds after a transactions for which the transaction response is displayed on the terminal. After the cooldown period elapses, the terminal will revert to the idle state and display the currently active terminal branding.
3590
+ * **surveyTimeout:** The amount of time in seconds a survey question should be displayed on a terminal before reverting to the idle screen.
3591
+ * **pinEnabled:** Enables pin code entry for debit cards, EBT cards, and EMV cards with pin CVMs. Will be ignored if terminals are not injected with the proper encryption keys.
3592
+ * **pinBypassEnabled:** Enable pin bypass for debit transactions.
3593
+ * **cashBackEnabled:** Enables cash back for debit transactions.
3594
+ * **cashbackPresets:** An array of four default values for cashback amounts when cashback is enabled.
3595
+ * **storeAndForwardEnabled:** Enables automatic store and forward during network outages. Store and Forward does not support cash back, refunds, EBT, or gift card transactions.
3596
+ * **storeAndForwardFloorLimit:** Maximum dollar value of a store and forward transaction.
3597
+ * **ebtEnabled:** Enables EBT (SNAP) on BlockChyp terminals.
3598
+ * **tipEnabled:** Enables tips entry on the terminal.
3599
+ * **promptForTip:** If true, the terminal will always prompt for a tip, even if the API call does not request a tip prompt.
3600
+ * **tipDefaults:** An array of exactly three percentages that will be used to calculate default tip amounts.
3601
+ * **giftCardsDisabled:** Disables BlockChyp gift cards. Normally only used if the merchant is using an alternate gift card system.
3602
+ * **digitalSignaturesEnabled:** Enables electronic signature capture for mag stripe cards and EMV cards with Signature CVMs.
3603
+ * **digitalSignatureReversal:** Will cause a transaction to auto-reverse if the consumer refuses to provide a signature.
3604
+ * **manualEntryEnabled:** Enables manual card entry.
3605
+ * **manualEntryPromptZip:** Requires zip code based address verification for manual card entry.
3606
+ * **manualEntryPromptStreetNumber:** Requires street/address based verification for manual card entry.
3607
+
3608
+ **Card Brand and Transaction Settings**
3609
+
3610
+ * **freeRangeRefundsEnabled:** Enables direct refunds that do not reference a previous transaction.
3611
+ * **partialAuthEnabled:** Indicates that partial authorizations (usually for gift card support) are enabled.
3612
+ * **splitBankAccountsEnabled:** Used for law firm merchants only.
3613
+ * **contactlessEmv:** Enables contactless/tap transactions on a terminal. Defaults to true.
3614
+ * **visa:** Enables Visa transactions.
3615
+ * **masterCard:** Enables MasterCard transactions.
3616
+ * **amex:** Enables American Express transactions.
3617
+ * **discover:** Enables Discover transactions.
3618
+ * **jcb:** Enables JCB (Japan Card Bureau) transactions.
3619
+ * **unionPay:** Enables China UnionPay transactions.
3620
+
3621
+
3622
+
3623
+
3624
+ ```ruby
3625
+ # frozen_string_literal: true
3626
+
3627
+ require 'blockchyp'
3628
+
3629
+ blockchyp = BlockChyp::BlockChyp.new(
3630
+ ENV['BC_API_KEY'],
3631
+ ENV['BC_BEARER_TOKEN'],
3632
+ ENV['BC_SIGNING_KEY']
3633
+ )
3634
+
3635
+ # Set request parameters
3636
+ request = {
3637
+ }
3638
+
3639
+ response = blockchyp.merchantProfile(request)
3640
+
3641
+ puts "Response: #{response.inspect}"
3642
+
3643
+
3644
+ ```
3645
+
3646
+ #### Get Merchants
3647
+
3648
+
3649
+
3650
+ * **API Credential Types:** Partner & Organization
3651
+ * **Required Role:** Merchant Management
3652
+
3653
+ This is a partner or organization level API that can be used to return the merchant portfolio.
3654
+
3655
+ Live merchants are returned by default. Use the `test` flag to return only test merchants. The
3656
+ results returned include detailed settings including underwriting controlled flags.
3657
+
3658
+ A maximum of 250 merchants are returned by default. For large merchant portfolios, the `maxResults`
3659
+ and `startIndex` field can be used to reduce the page size and page through multiple pages of results.
3660
+
3661
+
3662
+
3663
+
3664
+ ```ruby
3665
+ # frozen_string_literal: true
3666
+
3667
+ require 'blockchyp'
3668
+
3669
+ blockchyp = BlockChyp::BlockChyp.new(
3670
+ ENV['BC_API_KEY'],
3671
+ ENV['BC_BEARER_TOKEN'],
3672
+ ENV['BC_SIGNING_KEY']
3673
+ )
3674
+
3675
+ # Set request parameters
3676
+ request = {
3677
+ test: true
3678
+ }
3679
+
3680
+ response = blockchyp.getMerchants(request)
3681
+
3682
+ puts "Response: #{response.inspect}"
3683
+
3684
+
3685
+ ```
3686
+
3687
+ #### Update Merchant
3688
+
3689
+
3690
+
3691
+ * **API Credential Types:** Merchant, Partner, & Organization
3692
+ * **Required Role:** Merchant Management
3693
+
3694
+ This API can be used to update or create merchant accounts.
3695
+
3696
+ Merchant scoped API credentials can be used to update merchant account settings.
3697
+
3698
+ Partner scoped API credentials can be used to update merchants, create new test
3699
+ merchants or board new gateway merchants.
3700
+
3701
+ **Merchant Descriptive Fields**
3702
+
3703
+ The following fields are basic descriptive fields that can be used to describe and identify merchants.
3704
+
3705
+ * **companyName:** The merchant's official corporate entity name.
3706
+ * **dbaName:** The businesses DBA (doing business as) name.
3707
+ * **contactName:** Name of the merchant's primary control contact.
3708
+ * **contactNumber:** Primary control contact's phone number.
3709
+ * **locationName:** Optional location name for multi location operators.
3710
+ * **storeNumber:** Optional store number for multi location operators.
3711
+ * **partnerRef:** Optional reference number partners can add to a merchant record. Usually the partner's own identifier for the merchant.
3712
+ * **timeZone:** Unix style local time zone for the merchant. Example: America/New_York.
3713
+ * **publicKey:** Read only field. The merchant's blockchain public key. Generated and assigned when a merchant account is first created.
3714
+ * **billingAddress:** Address for billing and written correspondence.
3715
+ * **shippingAddress:** Physical shipping address. Usually the actual street address of the business.
3716
+ * **status:** Current status of the merchant account.
3717
+ * **tcDisabled:** Disables all terms and conditions features in the merchant dashboard. Used to hide the feature if a partner has not chosen to support it.
3718
+ * **gatewayOnly:** Indicates that a merchant has been boarded in gateway only mode. Not common.
3719
+
3720
+ **Batch and Terminal Settings**
3721
+
3722
+ The following fields are used to control batch closure and high level terminal configuration.
3723
+
3724
+ * **batchCloseTime:** Time in 24 hour HH:MM format when batches will automatically close in the merchant's local time. Defaults to 3 AM.
3725
+ * **autoBatchClose:** Flag the determines whether or not batches will automatically close. Defaults to true.
3726
+ * **disableBatchEmails:** Flag that optionally turns off automatic batch closure notification emails.
3727
+ * **cooldownTimeout:** The amount of time in seconds after a transactions for which the transaction response is displayed on the terminal. After the cooldown period elapses, the terminal will revert to the idle state and display the currently active terminal branding.
3728
+ * **surveyTimeout:** The amount of time in seconds a survey question should be displayed on a terminal before reverting to the idle screen.
3729
+ * **pinEnabled:** Enables pin code entry for debit cards, EBT cards, and EMV cards with pin CVMs. Will be ignored if terminals are not injected with the proper encryption keys.
3730
+ * **pinBypassEnabled:** Enable pin bypass for debit transactions.
3731
+ * **cashBackEnabled:** Enables cash back for debit transactions.
3732
+ * **cashbackPresets:** An array of four default values for cashback amounts when cashback is enabled.
3733
+ * **storeAndForwardEnabled:** Enables automatic store and forward during network outages. Store and Forward does not support cash back, refunds, EBT, or gift card transactions.
3734
+ * **storeAndForwardFloorLimit:** Maximum dollar value of a store and forward transaction.
3735
+ * **ebtEnabled:** Enables EBT (SNAP) on BlockChyp terminals.
3736
+ * **tipEnabled:** Enables tips entry on the terminal.
3737
+ * **promptForTip:** If true, the terminal will always prompt for a tip, even if the API call does not request a tip prompt.
3738
+ * **tipDefaults:** An array of exactly three percentages that will be used to calculate default tip amounts.
3739
+ * **giftCardsDisabled:** Disables BlockChyp gift cards. Normally only used if the merchant is using an alternate gift card system.
3740
+ * **digitalSignaturesEnabled:** Enables electronic signature capture for mag stripe cards and EMV cards with Signature CVMs.
3741
+ * **digitalSignatureReversal:** Will cause a transaction to auto-reverse if the consumer refuses to provide a signature.
3742
+ * **manualEntryEnabled:** Enables manual card entry.
3743
+ * **manualEntryPromptZip:** Requires zip code based address verification for manual card entry.
3744
+ * **manualEntryPromptStreetNumber:** Requires street/address based verification for manual card entry.
3745
+
3746
+ **Card Brand and Transaction Settings**
3747
+
3748
+ * **freeRangeRefundsEnabled:** Enables direct refunds that do not reference a previous transaction.
3749
+ * **partialAuthEnabled:** Indicates that partial authorizations (usually for gift card support) are enabled.
3750
+ * **splitBankAccountsEnabled:** Used for law firm merchants only.
3751
+ * **contactlessEmv:** Enables contactless/tap transactions on a terminal. Defaults to true.
3752
+ * **visa:** Enables Visa transactions.
3753
+ * **masterCard:** Enables MasterCard transactions.
3754
+ * **amex:** Enables American Express transactions.
3755
+ * **discover:** Enables Discover transactions.
3756
+ * **jcb:** Enables JCB (Japan Card Bureau) transactions.
3757
+ * **unionPay:** Enables China UnionPay transactions.
3758
+
3759
+
3760
+
3761
+
3762
+ ```ruby
3763
+ # frozen_string_literal: true
3764
+
3765
+ require 'blockchyp'
3766
+
3767
+ blockchyp = BlockChyp::BlockChyp.new(
3768
+ ENV['BC_API_KEY'],
3769
+ ENV['BC_BEARER_TOKEN'],
3770
+ ENV['BC_SIGNING_KEY']
3771
+ )
3772
+
3773
+ # Set request parameters
3774
+ request = {
3775
+ merchantId: '<MERCHANT ID>',
3776
+ test: true,
3777
+ dbaName: 'Test Merchant',
3778
+ companyName: 'Test Merchant',
3779
+ billingAddress: {
3780
+ address1: '1060 West Addison',
3781
+ city: 'Chicago',
3782
+ stateOrProvince: 'IL',
3783
+ postalCode: '60613'
3784
+ }
3785
+ }
3786
+
3787
+ response = blockchyp.updateMerchant(request)
3788
+
3789
+ puts "Response: #{response.inspect}"
3790
+
3791
+
3792
+ ```
3793
+
3794
+ #### Merchant Users
3795
+
3796
+
3797
+
3798
+ * **API Credential Types:** Partner & Organization
3799
+ * **Required Role:** Merchant Management
3800
+
3801
+ This API returns all users and pending invites associated with a merchant account including any assigned role codes.
3802
+
3803
+
3804
+
3805
+
3806
+ ```ruby
3807
+ # frozen_string_literal: true
3808
+
3809
+ require 'blockchyp'
3810
+
3811
+ blockchyp = BlockChyp::BlockChyp.new(
3812
+ ENV['BC_API_KEY'],
3813
+ ENV['BC_BEARER_TOKEN'],
3814
+ ENV['BC_SIGNING_KEY']
3815
+ )
3816
+
3817
+ # Set request parameters
3818
+ request = {
3819
+ merchantId: '<MERCHANT ID>'
3820
+ }
3821
+
3822
+ response = blockchyp.merchantUsers(request)
3823
+
3824
+ puts "Response: #{response.inspect}"
3825
+
3826
+
3827
+ ```
3828
+
3829
+ #### Invite Merchant User
3830
+
3831
+
3832
+
3833
+ * **API Credential Types:** Partner & Organization
3834
+ * **Required Role:** Merchant Management
3835
+
3836
+ Invites a new user to join a merchant account. `email`, `firstName`, and `lastName` are required.
3837
+
3838
+ The user will be sent an invite email with steps for creating a BlockChyp account and linking it to
3839
+ a merchant account. If the user already has a BlockChyp user account, the new user signup wil be skipped
3840
+ and the existing user account will be linked to the merchant account.
3841
+
3842
+ Developers can optionally restrict the user's access level by sending one or more role codes.
3843
+ Otherwise, the user will be given the default merchant user role. (STDMERCHANT)
3844
+
3845
+
3846
+
3847
+
3848
+ ```ruby
3849
+ # frozen_string_literal: true
3850
+
3851
+ require 'blockchyp'
3852
+
3853
+ blockchyp = BlockChyp::BlockChyp.new(
3854
+ ENV['BC_API_KEY'],
3855
+ ENV['BC_BEARER_TOKEN'],
3856
+ ENV['BC_SIGNING_KEY']
3857
+ )
3858
+
3859
+ # Set request parameters
3860
+ request = {
3861
+ email: 'Email address for the invite'
3862
+ }
3863
+
3864
+ response = blockchyp.inviteMerchantUser(request)
3865
+
3866
+ puts "Response: #{response.inspect}"
3867
+
3868
+
3869
+ ```
3870
+
3871
+ #### Add Test Merchant
3872
+
3873
+
3874
+
3875
+ * **API Credential Types:** Partner
3876
+ * **Required Role:** Merchant Management
3877
+
3878
+ This is a partner level API that can be used to create test merchant accounts. This creates
3879
+ a basic test merchant with default settings.
3880
+
3881
+ Settings can be changed by using the Update Merchant API.
3882
+
3883
+
3884
+
3885
+
3886
+ ```ruby
3887
+ # frozen_string_literal: true
3888
+
3889
+ require 'blockchyp'
3890
+
3891
+ blockchyp = BlockChyp::BlockChyp.new(
3892
+ ENV['BC_API_KEY'],
3893
+ ENV['BC_BEARER_TOKEN'],
3894
+ ENV['BC_SIGNING_KEY']
3895
+ )
3896
+
3897
+ # Set request parameters
3898
+ request = {
3899
+ dbaName: 'DBA Name',
3900
+ companyName: 'Corporate Entity Name'
3901
+ }
3902
+
3903
+ response = blockchyp.addTestMerchant(request)
3904
+
3905
+ puts "Response: #{response.inspect}"
3906
+
3907
+
3908
+ ```
3909
+
3910
+ #### Delete Test Merchant
3911
+
3912
+
3913
+
3914
+ * **API Credential Types:** Partner
3915
+ * **Required Role:** Merchant Management
3916
+
3917
+ This partner API can be used to delete unused test merchant accounts. `merchantId` is a required parameter.
3918
+
3919
+
3920
+
3921
+
3922
+ ```ruby
3923
+ # frozen_string_literal: true
3924
+
3925
+ require 'blockchyp'
3926
+
3927
+ blockchyp = BlockChyp::BlockChyp.new(
3928
+ ENV['BC_API_KEY'],
3929
+ ENV['BC_BEARER_TOKEN'],
3930
+ ENV['BC_SIGNING_KEY']
3931
+ )
3932
+
3933
+ # Set request parameters
3934
+ request = {
3935
+ merchantId: '<MERCHANT ID>'
3936
+ }
3937
+
3938
+ response = blockchyp.deleteTestMerchant(request)
3939
+
3940
+ puts "Response: #{response.inspect}"
3941
+
3942
+
3943
+ ```
3944
+
3945
+
3946
+
3947
+
3948
+
3949
+ ## Running Integration Tests
3950
+
3951
+ If you'd like to run the integration tests, create a new file on your system
3952
+ called `sdk-itest-config.json` with the API credentials you'll be using as
3953
+ shown in the example below.
3954
+
3955
+ ```
3956
+ {
3957
+ "gatewayHost": "https://api.blockchyp.com",
3958
+ "testGatewayHost": "https://test.blockchyp.com",
3959
+ "apiKey": "PZZNEFK7HFULCB3HTLA7HRQDJU",
3960
+ "bearerToken": "QUJCHIKNXOMSPGQ4QLT2UJX5DI",
3961
+ "signingKey": "f88a72d8bc0965f193abc7006bbffa240663c10e4d1dc3ba2f81e0ca10d359f5"
3962
+ }
3963
+ ```
3964
+
3965
+ This file can be located in a few different places, but is usually located
3966
+ at `<USER_HOME>/.config/blockchyp/sdk-itest-config.json`. All BlockChyp SDKs
3967
+ use the same configuration file.
3968
+
3969
+ To run the integration test suite via `make`, type the following command:
3970
+
3971
+ `make integration`
3972
+
3973
+
3974
+ ## Running Integration Tests Via Rake or Ruby
3975
+
3976
+ If you'd like to bypass make and run the integration test suite directly,
3977
+ you can run the entire test suite with Rake using the following command:
3978
+
3979
+ `BC_TEST_DELAY=5 rake test`
3980
+
3981
+ You can run individual tests by adding executing them as normal Ruby files.
3982
+
3983
+ `ruby test/terminal_charge_test.rb`
3984
+
3985
+
3986
+
3987
+
3988
+
3989
+ ## Contributions
3990
+
3991
+ BlockChyp welcomes contributions from the open source community, but bear in mind
3992
+ that this repository has been generated by our internal SDK Generator tool. If
3993
+ we choose to accept a PR or contribution, your code will be moved into our SDK
3994
+ Generator project, which is a private repository.
3995
+
3996
+ ## License
3997
+
3998
+ Copyright BlockChyp, Inc., 2019
3999
+
4000
+ Distributed under the terms of the [MIT] license, blockchyp-ruby is free and open source software.
4001
+
4002
+ [MIT]: https://github.com/blockchyp/blockchyp-ruby/blob/master/LICENSE
4003
+
4004
+ ## Other SDKs
4005
+
4006
+ BlockChyp has officially supported SDKs for eight different development platforms and counting.
4007
+ Here's the full list with links to their GitHub repositories.
4008
+
4009
+ [Go SDK](https://github.com/blockchyp/blockchyp-go)
4010
+
4011
+ [Node.js/JavaScript SDK](https://github.com/blockchyp/blockchyp-js)
4012
+
4013
+ [Java SDK](https://github.com/blockchyp/blockchyp-java)
4014
+
4015
+ [.net/C# SDK](https://github.com/blockchyp/blockchyp-csharp)
4016
+
4017
+ [Ruby SDK](https://github.com/blockchyp/blockchyp-ruby)
4018
+
4019
+ [PHP SDK](https://github.com/blockchyp/blockchyp-php)
4020
+
4021
+ [Python SDK](https://github.com/blockchyp/blockchyp-python)
4022
+
4023
+ [iOS (Objective-C/Swift) SDK](https://github.com/blockchyp/blockchyp-ios)