bluepay 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +7 -0
  2. data/README +47 -15
  3. data/Rakefile +11 -63
  4. data/bluepay.gemspec +13 -0
  5. data/doc/BluePay.html +2699 -0
  6. data/doc/README.html +173 -0
  7. data/doc/created.rid +3 -0
  8. data/doc/fonts.css +167 -0
  9. data/doc/fonts/Lato-Light.ttf +0 -0
  10. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  11. data/doc/fonts/Lato-Regular.ttf +0 -0
  12. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  13. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  14. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  15. data/doc/images/add.png +0 -0
  16. data/doc/images/arrow_up.png +0 -0
  17. data/doc/images/brick.png +0 -0
  18. data/doc/images/brick_link.png +0 -0
  19. data/doc/images/bug.png +0 -0
  20. data/doc/images/bullet_black.png +0 -0
  21. data/doc/images/bullet_toggle_minus.png +0 -0
  22. data/doc/images/bullet_toggle_plus.png +0 -0
  23. data/doc/images/date.png +0 -0
  24. data/doc/images/delete.png +0 -0
  25. data/doc/images/find.png +0 -0
  26. data/doc/images/loadingAnimation.gif +0 -0
  27. data/doc/images/macFFBgHack.png +0 -0
  28. data/doc/images/package.png +0 -0
  29. data/doc/images/page_green.png +0 -0
  30. data/doc/images/page_white_text.png +0 -0
  31. data/doc/images/page_white_width.png +0 -0
  32. data/doc/images/plugin.png +0 -0
  33. data/doc/images/ruby.png +0 -0
  34. data/doc/images/tag_blue.png +0 -0
  35. data/doc/images/tag_green.png +0 -0
  36. data/doc/images/transparent.png +0 -0
  37. data/doc/images/wrench.png +0 -0
  38. data/doc/images/wrench_orange.png +0 -0
  39. data/doc/images/zoom.png +0 -0
  40. data/doc/index.html +92 -0
  41. data/doc/js/darkfish.js +140 -0
  42. data/doc/js/jquery.js +18 -0
  43. data/doc/js/navigation.js +142 -0
  44. data/doc/js/search.js +109 -0
  45. data/doc/js/search_index.js +1 -0
  46. data/doc/js/searcher.js +228 -0
  47. data/doc/rdoc.css +580 -0
  48. data/doc/table_of_contents.html +405 -0
  49. data/lib/bluepay.rb +488 -0
  50. data/test/get_data/retrieve_settlement_data.rb +39 -0
  51. data/test/get_data/retrieve_transaction_data.rb +37 -0
  52. data/test/get_data/transaction_query.rb +48 -0
  53. data/test/getting_stuff_done/get_transaction_data.rb +37 -0
  54. data/test/getting_stuff_done/run_ach_payment.rb +75 -0
  55. data/test/getting_stuff_done/run_cc_payment.rb +73 -0
  56. data/test/getting_stuff_done/set_up_rebill_ach.rb +85 -0
  57. data/test/getting_stuff_done/set_up_rebill_cc.rb +84 -0
  58. data/test/rebills/cancel_rebill.rb +96 -0
  59. data/test/rebills/create_rebill.rb +84 -0
  60. data/test/rebills/get_rebill.rb +97 -0
  61. data/test/rebills/update_rebill.rb +128 -0
  62. data/test/transactions/cancel_transaction.rb +85 -0
  63. data/test/transactions/charge_customer.rb +74 -0
  64. data/test/transactions/check_customer_credit.rb +74 -0
  65. data/test/transactions/credit_customer.rb +75 -0
  66. data/test/transactions/customer_defined_data.rb +99 -0
  67. data/test/transactions/return_funds.rb +86 -0
  68. data/test/transactions/store_payment_information.rb +74 -0
  69. data/test/transactions/use_token.rb +44 -0
  70. metadata +106 -35
  71. data/lib/Bluepay.rb +0 -206
  72. data/test/bp20post_test.rb +0 -12
@@ -0,0 +1,405 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>Table of Contents - Ruby Merchant Bluepay</title>
8
+
9
+ <link href="./fonts.css" rel="stylesheet">
10
+ <link href="./rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "./";
14
+ </script>
15
+
16
+ <script src="./js/jquery.js"></script>
17
+ <script src="./js/navigation.js"></script>
18
+ <script src="./js/search_index.js"></script>
19
+ <script src="./js/search.js"></script>
20
+ <script src="./js/searcher.js"></script>
21
+ <script src="./js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" class="table-of-contents">
25
+ <main role="main">
26
+ <h1 class="class">Table of Contents - Ruby Merchant Bluepay</h1>
27
+
28
+ <h2 id="pages">Pages</h2>
29
+ <ul>
30
+ <li class="file">
31
+ <a href="README.html">README</a>
32
+
33
+ <ul>
34
+ <li><a href="README.html#label-Welcome+to+Bluepay">Welcome to Bluepay</a>
35
+ <li><a href="README.html#label-Example">Example</a>
36
+ <li><a href="README.html#label-About">About</a>
37
+ </ul>
38
+ </li>
39
+
40
+ </ul>
41
+
42
+ <h2 id="classes">Classes and Modules</h2>
43
+ <ul>
44
+ <li class="class">
45
+ <a href="BluePay.html">BluePay</a>
46
+ </li>
47
+ </ul>
48
+
49
+ <h2 id="methods">Methods</h2>
50
+ <ul>
51
+
52
+ <li class="method">
53
+ <a href="BluePay.html#method-c-calc_trans_notify_tps">::calc_trans_notify_tps</a>
54
+ &mdash;
55
+ <span class="container">BluePay</span>
56
+
57
+ <li class="method">
58
+ <a href="BluePay.html#method-c-new">::new</a>
59
+ &mdash;
60
+ <span class="container">BluePay</span>
61
+
62
+ <li class="method">
63
+ <a href="BluePay.html#method-i-add_recurring_fields">#add_recurring_fields</a>
64
+ &mdash;
65
+ <span class="container">BluePay</span>
66
+
67
+ <li class="method">
68
+ <a href="BluePay.html#method-i-auth">#auth</a>
69
+ &mdash;
70
+ <span class="container">BluePay</span>
71
+
72
+ <li class="method">
73
+ <a href="BluePay.html#method-i-calc_rebill_tps">#calc_rebill_tps</a>
74
+ &mdash;
75
+ <span class="container">BluePay</span>
76
+
77
+ <li class="method">
78
+ <a href="BluePay.html#method-i-calc_report_tps">#calc_report_tps</a>
79
+ &mdash;
80
+ <span class="container">BluePay</span>
81
+
82
+ <li class="method">
83
+ <a href="BluePay.html#method-i-calc_tps">#calc_tps</a>
84
+ &mdash;
85
+ <span class="container">BluePay</span>
86
+
87
+ <li class="method">
88
+ <a href="BluePay.html#method-i-cancel_rebilling_cycle">#cancel_rebilling_cycle</a>
89
+ &mdash;
90
+ <span class="container">BluePay</span>
91
+
92
+ <li class="method">
93
+ <a href="BluePay.html#method-i-capture">#capture</a>
94
+ &mdash;
95
+ <span class="container">BluePay</span>
96
+
97
+ <li class="method">
98
+ <a href="BluePay.html#method-i-credit">#credit</a>
99
+ &mdash;
100
+ <span class="container">BluePay</span>
101
+
102
+ <li class="method">
103
+ <a href="BluePay.html#method-i-get_amount">#get_amount</a>
104
+ &mdash;
105
+ <span class="container">BluePay</span>
106
+
107
+ <li class="method">
108
+ <a href="BluePay.html#method-i-get_auth_code">#get_auth_code</a>
109
+ &mdash;
110
+ <span class="container">BluePay</span>
111
+
112
+ <li class="method">
113
+ <a href="BluePay.html#method-i-get_avs_code">#get_avs_code</a>
114
+ &mdash;
115
+ <span class="container">BluePay</span>
116
+
117
+ <li class="method">
118
+ <a href="BluePay.html#method-i-get_bank_name">#get_bank_name</a>
119
+ &mdash;
120
+ <span class="container">BluePay</span>
121
+
122
+ <li class="method">
123
+ <a href="BluePay.html#method-i-get_card_type">#get_card_type</a>
124
+ &mdash;
125
+ <span class="container">BluePay</span>
126
+
127
+ <li class="method">
128
+ <a href="BluePay.html#method-i-get_creation_date">#get_creation_date</a>
129
+ &mdash;
130
+ <span class="container">BluePay</span>
131
+
132
+ <li class="method">
133
+ <a href="BluePay.html#method-i-get_cvv2_code">#get_cvv2_code</a>
134
+ &mdash;
135
+ <span class="container">BluePay</span>
136
+
137
+ <li class="method">
138
+ <a href="BluePay.html#method-i-get_cycles_remaining">#get_cycles_remaining</a>
139
+ &mdash;
140
+ <span class="container">BluePay</span>
141
+
142
+ <li class="method">
143
+ <a href="BluePay.html#method-i-get_id">#get_id</a>
144
+ &mdash;
145
+ <span class="container">BluePay</span>
146
+
147
+ <li class="method">
148
+ <a href="BluePay.html#method-i-get_last_date">#get_last_date</a>
149
+ &mdash;
150
+ <span class="container">BluePay</span>
151
+
152
+ <li class="method">
153
+ <a href="BluePay.html#method-i-get_masked_account">#get_masked_account</a>
154
+ &mdash;
155
+ <span class="container">BluePay</span>
156
+
157
+ <li class="method">
158
+ <a href="BluePay.html#method-i-get_message">#get_message</a>
159
+ &mdash;
160
+ <span class="container">BluePay</span>
161
+
162
+ <li class="method">
163
+ <a href="BluePay.html#method-i-get_name1">#get_name1</a>
164
+ &mdash;
165
+ <span class="container">BluePay</span>
166
+
167
+ <li class="method">
168
+ <a href="BluePay.html#method-i-get_name2">#get_name2</a>
169
+ &mdash;
170
+ <span class="container">BluePay</span>
171
+
172
+ <li class="method">
173
+ <a href="BluePay.html#method-i-get_next_amount">#get_next_amount</a>
174
+ &mdash;
175
+ <span class="container">BluePay</span>
176
+
177
+ <li class="method">
178
+ <a href="BluePay.html#method-i-get_next_date">#get_next_date</a>
179
+ &mdash;
180
+ <span class="container">BluePay</span>
181
+
182
+ <li class="method">
183
+ <a href="BluePay.html#method-i-get_payment_type">#get_payment_type</a>
184
+ &mdash;
185
+ <span class="container">BluePay</span>
186
+
187
+ <li class="method">
188
+ <a href="BluePay.html#method-i-get_reb_id">#get_reb_id</a>
189
+ &mdash;
190
+ <span class="container">BluePay</span>
191
+
192
+ <li class="method">
193
+ <a href="BluePay.html#method-i-get_rebill_amount">#get_rebill_amount</a>
194
+ &mdash;
195
+ <span class="container">BluePay</span>
196
+
197
+ <li class="method">
198
+ <a href="BluePay.html#method-i-get_rebill_id">#get_rebill_id</a>
199
+ &mdash;
200
+ <span class="container">BluePay</span>
201
+
202
+ <li class="method">
203
+ <a href="BluePay.html#method-i-get_rebill_status">#get_rebill_status</a>
204
+ &mdash;
205
+ <span class="container">BluePay</span>
206
+
207
+ <li class="method">
208
+ <a href="BluePay.html#method-i-get_rebilling_cycle_status">#get_rebilling_cycle_status</a>
209
+ &mdash;
210
+ <span class="container">BluePay</span>
211
+
212
+ <li class="method">
213
+ <a href="BluePay.html#method-i-get_response">#get_response</a>
214
+ &mdash;
215
+ <span class="container">BluePay</span>
216
+
217
+ <li class="method">
218
+ <a href="BluePay.html#method-i-get_sched_expression">#get_sched_expression</a>
219
+ &mdash;
220
+ <span class="container">BluePay</span>
221
+
222
+ <li class="method">
223
+ <a href="BluePay.html#method-i-get_settled_transaction_report">#get_settled_transaction_report</a>
224
+ &mdash;
225
+ <span class="container">BluePay</span>
226
+
227
+ <li class="method">
228
+ <a href="BluePay.html#method-i-get_single_trans_query">#get_single_trans_query</a>
229
+ &mdash;
230
+ <span class="container">BluePay</span>
231
+
232
+ <li class="method">
233
+ <a href="BluePay.html#method-i-get_status">#get_status</a>
234
+ &mdash;
235
+ <span class="container">BluePay</span>
236
+
237
+ <li class="method">
238
+ <a href="BluePay.html#method-i-get_template_id">#get_template_id</a>
239
+ &mdash;
240
+ <span class="container">BluePay</span>
241
+
242
+ <li class="method">
243
+ <a href="BluePay.html#method-i-get_trans_id">#get_trans_id</a>
244
+ &mdash;
245
+ <span class="container">BluePay</span>
246
+
247
+ <li class="method">
248
+ <a href="BluePay.html#method-i-get_trans_type">#get_trans_type</a>
249
+ &mdash;
250
+ <span class="container">BluePay</span>
251
+
252
+ <li class="method">
253
+ <a href="BluePay.html#method-i-get_transaction_report">#get_transaction_report</a>
254
+ &mdash;
255
+ <span class="container">BluePay</span>
256
+
257
+ <li class="method">
258
+ <a href="BluePay.html#method-i-process">#process</a>
259
+ &mdash;
260
+ <span class="container">BluePay</span>
261
+
262
+ <li class="method">
263
+ <a href="BluePay.html#method-i-query_by_amount">#query_by_amount</a>
264
+ &mdash;
265
+ <span class="container">BluePay</span>
266
+
267
+ <li class="method">
268
+ <a href="BluePay.html#method-i-query_by_name1">#query_by_name1</a>
269
+ &mdash;
270
+ <span class="container">BluePay</span>
271
+
272
+ <li class="method">
273
+ <a href="BluePay.html#method-i-query_by_name2">#query_by_name2</a>
274
+ &mdash;
275
+ <span class="container">BluePay</span>
276
+
277
+ <li class="method">
278
+ <a href="BluePay.html#method-i-query_by_payment_type">#query_by_payment_type</a>
279
+ &mdash;
280
+ <span class="container">BluePay</span>
281
+
282
+ <li class="method">
283
+ <a href="BluePay.html#method-i-query_by_trans_type">#query_by_trans_type</a>
284
+ &mdash;
285
+ <span class="container">BluePay</span>
286
+
287
+ <li class="method">
288
+ <a href="BluePay.html#method-i-query_by_transaction_id">#query_by_transaction_id</a>
289
+ &mdash;
290
+ <span class="container">BluePay</span>
291
+
292
+ <li class="method">
293
+ <a href="BluePay.html#method-i-refund">#refund</a>
294
+ &mdash;
295
+ <span class="container">BluePay</span>
296
+
297
+ <li class="method">
298
+ <a href="BluePay.html#method-i-sale">#sale</a>
299
+ &mdash;
300
+ <span class="container">BluePay</span>
301
+
302
+ <li class="method">
303
+ <a href="BluePay.html#method-i-set_ach_information">#set_ach_information</a>
304
+ &mdash;
305
+ <span class="container">BluePay</span>
306
+
307
+ <li class="method">
308
+ <a href="BluePay.html#method-i-set_amount_food">#set_amount_food</a>
309
+ &mdash;
310
+ <span class="container">BluePay</span>
311
+
312
+ <li class="method">
313
+ <a href="BluePay.html#method-i-set_amount_misc">#set_amount_misc</a>
314
+ &mdash;
315
+ <span class="container">BluePay</span>
316
+
317
+ <li class="method">
318
+ <a href="BluePay.html#method-i-set_amount_tax">#set_amount_tax</a>
319
+ &mdash;
320
+ <span class="container">BluePay</span>
321
+
322
+ <li class="method">
323
+ <a href="BluePay.html#method-i-set_amount_tip">#set_amount_tip</a>
324
+ &mdash;
325
+ <span class="container">BluePay</span>
326
+
327
+ <li class="method">
328
+ <a href="BluePay.html#method-i-set_cc_information">#set_cc_information</a>
329
+ &mdash;
330
+ <span class="container">BluePay</span>
331
+
332
+ <li class="method">
333
+ <a href="BluePay.html#method-i-set_custom_id1">#set_custom_id1</a>
334
+ &mdash;
335
+ <span class="container">BluePay</span>
336
+
337
+ <li class="method">
338
+ <a href="BluePay.html#method-i-set_custom_id2">#set_custom_id2</a>
339
+ &mdash;
340
+ <span class="container">BluePay</span>
341
+
342
+ <li class="method">
343
+ <a href="BluePay.html#method-i-set_customer_information">#set_customer_information</a>
344
+ &mdash;
345
+ <span class="container">BluePay</span>
346
+
347
+ <li class="method">
348
+ <a href="BluePay.html#method-i-set_email">#set_email</a>
349
+ &mdash;
350
+ <span class="container">BluePay</span>
351
+
352
+ <li class="method">
353
+ <a href="BluePay.html#method-i-set_invoice_id">#set_invoice_id</a>
354
+ &mdash;
355
+ <span class="container">BluePay</span>
356
+
357
+ <li class="method">
358
+ <a href="BluePay.html#method-i-set_memo">#set_memo</a>
359
+ &mdash;
360
+ <span class="container">BluePay</span>
361
+
362
+ <li class="method">
363
+ <a href="BluePay.html#method-i-set_order_id">#set_order_id</a>
364
+ &mdash;
365
+ <span class="container">BluePay</span>
366
+
367
+ <li class="method">
368
+ <a href="BluePay.html#method-i-set_param">#set_param</a>
369
+ &mdash;
370
+ <span class="container">BluePay</span>
371
+
372
+ <li class="method">
373
+ <a href="BluePay.html#method-i-set_phone">#set_phone</a>
374
+ &mdash;
375
+ <span class="container">BluePay</span>
376
+
377
+ <li class="method">
378
+ <a href="BluePay.html#method-i-update_rebilling_cycle">#update_rebilling_cycle</a>
379
+ &mdash;
380
+ <span class="container">BluePay</span>
381
+
382
+ <li class="method">
383
+ <a href="BluePay.html#method-i-update_rebilling_payment_information">#update_rebilling_payment_information</a>
384
+ &mdash;
385
+ <span class="container">BluePay</span>
386
+
387
+ <li class="method">
388
+ <a href="BluePay.html#method-i-uri_query">#uri_query</a>
389
+ &mdash;
390
+ <span class="container">BluePay</span>
391
+
392
+ <li class="method">
393
+ <a href="BluePay.html#method-i-void">#void</a>
394
+ &mdash;
395
+ <span class="container">BluePay</span>
396
+ </ul>
397
+ </main>
398
+
399
+
400
+ <footer id="validator-badges" role="contentinfo">
401
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
402
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
403
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
404
+ </footer>
405
+
@@ -0,0 +1,488 @@
1
+ #!/usr/bin/ruby
2
+ require "net/http"
3
+ require "net/https"
4
+ require "uri"
5
+ require "digest/md5"
6
+
7
+ class BluePay
8
+ SERVER = "secure.bluepay.com"
9
+ # Make sure this is the correct path to your CA certificates directory
10
+ RootCA = "/etc/ssl/certs"
11
+
12
+ def initialize(account,key,mode='TEST')
13
+ @ACCOUNT_ID = account
14
+ @SECRET_KEY = key
15
+ @PARAM_HASH = { 'MODE' => mode }
16
+ @RETURN_HASH = Hash.new()
17
+ end
18
+
19
+ def set_param(key, val)
20
+ @PARAM_HASH[key] = val
21
+ end
22
+
23
+ # Set up a credit card payment.
24
+ def set_cc_information(account, expire, cvv='')
25
+ @PARAM_HASH['PAYMENT_TYPE'] = 'CREDIT'
26
+ @PARAM_HASH['CC_NUM'] = account
27
+ @PARAM_HASH['CC_EXPIRES'] = expire
28
+ @PARAM_HASH['CVCVV2'] = cvv
29
+ end
30
+
31
+ # Set up an ACH transaction. Expects:
32
+ # acc_type: C for Checking, S for Savings
33
+ # routing: Bank routing number
34
+ # account: Customer's checking or savings account number
35
+ # doc_type: WEB, TEL, ARC, etc -- see docs. Optional.
36
+ # REMEMBER: Ach requires some other fields,
37
+ # such as address and phone
38
+ def set_ach_information(routing, account, acc_type, doc_type='')
39
+ @PARAM_HASH['PAYMENT_TYPE'] = 'ACH'
40
+ @PARAM_HASH['ACH_ROUTING'] = routing
41
+ @PARAM_HASH['ACH_ACCOUNT'] = account
42
+ @PARAM_HASH['ACH_ACCOUNT_TYPE'] = acc_type
43
+ @PARAM_HASH['DOC_TYPE'] = doc_type
44
+ end
45
+
46
+ # Set up a sale
47
+ def sale(amount, trans_id='')
48
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'SALE'
49
+ @PARAM_HASH['AMOUNT'] = amount
50
+ @PARAM_HASH['RRNO'] = trans_id
51
+ end
52
+
53
+ # Set up an Auth
54
+ def auth(amount, trans_id='')
55
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'AUTH'
56
+ @PARAM_HASH['AMOUNT'] = amount
57
+ @PARAM_HASH['RRNO'] = trans_id
58
+ end
59
+
60
+ # Credit
61
+ def credit(amount, trans_id='')
62
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'CREDIT'
63
+ @PARAM_HASH['AMOUNT'] = amount
64
+ @PARAM_HASH['RRNO'] = trans_id
65
+ end
66
+
67
+ # Capture an Auth
68
+ def capture(trans_id, amount='')
69
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'CAPTURE'
70
+ @PARAM_HASH['AMOUNT'] = amount
71
+ @PARAM_HASH['RRNO'] = trans_id
72
+ end
73
+
74
+ # Refund
75
+ def refund(trans_id, amount='')
76
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'REFUND'
77
+ @PARAM_HASH['RRNO'] = trans_id
78
+ @PARAM_HASH['AMOUNT'] = amount
79
+ end
80
+
81
+ # Void
82
+ def void(trans_id)
83
+ @PARAM_HASH['TRANSACTION_TYPE'] = 'VOID'
84
+ @PARAM_HASH['AMOUNT'] = ''
85
+ @PARAM_HASH['RRNO'] = trans_id
86
+ end
87
+
88
+ # Sets customer information for the transaction
89
+ def set_customer_information(name1, name2, addr1, city, state, zip, addr2='', country='')
90
+ @PARAM_HASH['NAME1'] = name1
91
+ @PARAM_HASH['NAME2'] = name2
92
+ @PARAM_HASH['ADDR1'] = addr1
93
+ @PARAM_HASH['CITY'] = city
94
+ @PARAM_HASH['STATE'] = state
95
+ @PARAM_HASH['ZIPCODE'] = zip
96
+ @PARAM_HASH['ADDR2'] = addr2
97
+ @PARAM_HASH['COUNTRY'] = country
98
+ end
99
+
100
+ # Set customer phone #
101
+ def set_phone(phone)
102
+ @PARAM_HASH['PHONE'] = phone
103
+ end
104
+
105
+ # Set customer E-mail address
106
+ def set_email(email)
107
+ @PARAM_HASH['EMAIL'] = email
108
+ end
109
+
110
+ # Set MEMO field
111
+ def set_memo(memo)
112
+ @PARAM_HASH['COMMENT'] = memo
113
+ end
114
+
115
+ # Set CUSTOM_ID field
116
+ def set_custom_id1(custom_id1)
117
+ @PARAM_HASH['CUSTOM_ID'] = custom_id1
118
+ end
119
+
120
+ # Set CUSTOM_ID2 field
121
+ def set_custom_id2(custom_id2)
122
+ @PARAM_HASH['CUSTOM_ID2'] = custom_id2
123
+ end
124
+
125
+ # Set INVOICE_ID field
126
+ def set_invoice_id(invoice_id)
127
+ @PARAM_HASH['INVOICE_ID'] = invoice_id
128
+ end
129
+
130
+ # Set ORDER_ID field
131
+ def set_order_id(order_id)
132
+ @PARAM_HASH['ORDER_ID'] = order_id
133
+ end
134
+
135
+ # Set AMOUNT_TIP field
136
+ def set_amount_tip(amount_tip)
137
+ @PARAM_HASH['AMOUNT_TIP'] = amount_tip
138
+ end
139
+
140
+ # Set AMOUNT_TAX field
141
+ def set_amount_tax(amount_tax)
142
+ @PARAM_HASH['AMOUNT_TAX'] = amount_tax
143
+ end
144
+
145
+ # Set AMOUNT_FOOD field
146
+ def set_amount_food(amount_food)
147
+ @PARAM_HASH['AMOUNT_FOOD'] = amount_food
148
+ end
149
+
150
+ # Set AMOUNT_MISC field
151
+ def set_amount_misc(amount_misc)
152
+ @PARAM_HASH['AMOUNT_MISC'] = amount_misc
153
+ end
154
+
155
+ # Set fields for a recurring payment
156
+ def add_recurring_fields(rebill_first_date, rebill_expr, reb_cycles, reb_amount)
157
+ @PARAM_HASH['REBILLING'] = '1'
158
+ @PARAM_HASH['REB_FIRST_DATE'] = rebill_first_date
159
+ @PARAM_HASH['REB_EXPR'] = rebill_expr
160
+ @PARAM_HASH['REB_CYCLES'] = reb_cycles
161
+ @PARAM_HASH['REB_AMOUNT'] = reb_amount
162
+ end
163
+
164
+ # Set fields to do an update on an existing rebilling cycle
165
+ def update_rebilling_cycle(rebill_id, rebill_next_date, rebill_expr, rebill_cycles, rebill_amount,
166
+ rebill_next_amount)
167
+ @PARAM_HASH['TRANS_TYPE'] = "SET"
168
+ @PARAM_HASH['REBILL_ID'] = rebill_id
169
+ @PARAM_HASH['NEXT_DATE'] = rebill_next_date
170
+ @PARAM_HASH['REB_EXPR'] = rebill_expr
171
+ @PARAM_HASH['REB_CYCLES'] = rebill_cycles
172
+ @PARAM_HASH['REB_AMOUNT'] = rebill_amount
173
+ @PARAM_HASH['NEXT_AMOUNT'] = rebill_next_amount
174
+ end
175
+
176
+ # Set fields to cancel an existing rebilling cycle
177
+ def cancel_rebilling_cycle(rebill_id)
178
+ @PARAM_HASH["TRANS_TYPE"] = "SET"
179
+ @PARAM_HASH["STATUS"] = "stopped"
180
+ @PARAM_HASH["REBILL_ID"] = rebill_id
181
+ end
182
+
183
+ # Set fields to get the status of an existing rebilling cycle
184
+ def get_rebilling_cycle_status(rebill_id)
185
+ @PARAM_HASH["TRANS_TYPE"] = "GET"
186
+ @PARAM_HASH["REBILL_ID"] = rebill_id
187
+ end
188
+
189
+ # Updates an existing rebilling cycle's payment information.
190
+ def update_rebilling_payment_information(template_id)
191
+ @PARAM_HASH["TEMPLATE_ID"] = template_id
192
+ end
193
+
194
+ # Gets a report on all transactions within a specified date range
195
+ def get_transaction_report(report_start, report_end, subaccounts_searched, do_not_escape = '', errors = '')
196
+ @PARAM_HASH["QUERY_BY_SETTLEMENT"] = '0'
197
+ @PARAM_HASH["REPORT_START_DATE"] = report_start
198
+ @PARAM_HASH["REPORT_END_DATE"] = report_end
199
+ @PARAM_HASH["QUERY_BY_HIERARCHY"] = subaccounts_searched
200
+ @PARAM_HASH["DO_NOT_ESCAPE"] = do_not_escape
201
+ @PARAM_HASH["EXCLUDE_ERRORS"] = errors
202
+ end
203
+
204
+ # Gets a report on all settled transactions within a specified date range
205
+ def get_settled_transaction_report(report_start, report_end, subaccounts_searched, do_not_escape = '', errors = '')
206
+ @PARAM_HASH["QUERY_BY_SETTLEMENT"] = '1'
207
+ @PARAM_HASH["REPORT_START_DATE"] = report_start
208
+ @PARAM_HASH["REPORT_END_DATE"] = report_end
209
+ @PARAM_HASH["QUERY_BY_HIERARCHY"] = subaccounts_searched
210
+ @PARAM_HASH["DO_NOT_ESCAPE"] = do_not_escape
211
+ @PARAM_HASH["EXCLUDE_ERRORS"] = errors
212
+ end
213
+
214
+ # Gets data on a specific transaction
215
+ def get_single_trans_query(report_start, report_end, errors = "")
216
+ @PARAM_HASH["REPORT_START_DATE"] = report_start
217
+ @PARAM_HASH["REPORT_END_DATE"] = report_end
218
+ @PARAM_HASH["EXCLUDE_ERRORS"] = errors
219
+ end
220
+
221
+ # Queries by a specific Transaction ID. To be used with get_single_trans_query
222
+ def query_by_transaction_id(trans_id)
223
+ @PARAM_HASH["id"] = trans_id;
224
+ end
225
+
226
+ # Queries by a specific Payment Type. To be used with get_single_trans_query
227
+ def query_by_payment_type(pay_type)
228
+ @PARAM_HASH["payment_type"] = payment_type
229
+ end
230
+
231
+ # Queries by a specific Transaction Type. To be used with get_single_trans_query
232
+ def query_by_trans_type(trans_type)
233
+ @PARAM_HASH["trans_type"] = trans_type
234
+ end
235
+
236
+ # Queries by a specific Transaction Amount. To be used with get_single_trans_query
237
+ def query_by_amount(amount)
238
+ @PARAM_HASH["amount"] = amount
239
+ end
240
+
241
+ # Queries by a specific First Name. To be used with get_single_trans_query
242
+ def query_by_name1(name1)
243
+ @PARAM_HASH["name1"] = name1
244
+ end
245
+
246
+ # Queries by a specific Last Name. To be used with get_single_trans_query
247
+ def query_by_name2(name2)
248
+ @PARAM_HASH["name2"] = name2
249
+ end
250
+
251
+ # Turns a hash into a nvp style string
252
+ def uri_query(h)
253
+ a = Array.new()
254
+ h.each_pair {|key, val| a.push(URI.escape(key) + "=" + URI.escape(val)) }
255
+ return a.join("&")
256
+ end
257
+
258
+ # Sets TAMPER_PROOF_SEAL in @PARAM_HASH
259
+ def calc_tps()
260
+ @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest(@SECRET_KEY + @ACCOUNT_ID +
261
+ (@PARAM_HASH["TRANSACTION_TYPE"] || '') + @PARAM_HASH["AMOUNT"] + (@PARAM_HASH["REBILLING"] || '') +
262
+ (@PARAM_HASH["REB_FIRST_DATE"] || '') + (@PARAM_HASH["REB_EXPR"] || '') + (@PARAM_HASH["REB_CYCLES"] || '') +
263
+ (@PARAM_HASH["REB_AMOUNT"] || '') + (@PARAM_HASH["RRNO"] || '') + @PARAM_HASH["MODE"])
264
+ end
265
+
266
+ # Sets TAMPER_PROOF_SEAL in @PARAM_HASH for rebadmin API
267
+ def calc_rebill_tps()
268
+ @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest(@SECRET_KEY + @ACCOUNT_ID +
269
+ @PARAM_HASH["TRANS_TYPE"] + @PARAM_HASH["REBILL_ID"])
270
+ end
271
+
272
+ # Sets TAMPER_PROOF_SEAL in @PARAM_HASH for bpdailyreport2 API
273
+ def calc_report_tps()
274
+ @PARAM_HASH["TAMPER_PROOF_SEAL"] = Digest::MD5.hexdigest(@SECRET_KEY + @ACCOUNT_ID +
275
+ @PARAM_HASH["REPORT_START_DATE"] + @PARAM_HASH["REPORT_END_DATE"])
276
+ end
277
+
278
+ # Calculates TAMPER_PROOF_SEAL to be used with Trans Notify API
279
+ def self.calc_trans_notify_tps(secret_key, trans_id, trans_status, trans_type, amount, batch_id, batch_status,
280
+ total_count, total_amount, batch_upload_id, rebill_id, rebill_amount, rebill_status)
281
+ return Digest::MD5.hexdigest(@SECRET_KEY + trans_id + trans_status + transtype +
282
+ amount + batch_id + batch_status + total_count + total_amount + batch_upload_id + rebill_id + rebill_amount + rebill_status)
283
+ end
284
+
285
+ # sends HTTPS POST to BluePay gateway for processing
286
+ def process()
287
+ ua = Net::HTTP.new(SERVER, 443)
288
+ ua.use_ssl = true
289
+ if File.directory? RootCA
290
+ ua.ca_path = RootCA
291
+ ua.verify_mode = OpenSSL::SSL::VERIFY_PEER
292
+ ua.verify_depth = 3
293
+ else
294
+ puts "Invalid CA certificates directory. Exiting..."
295
+ exit
296
+ end
297
+ begin
298
+ @PARAM_HASH["REMOTE_IP"] = request.env['REMOTE_ADDR']
299
+ rescue Exception
300
+ end
301
+ # Generate the query string and headers
302
+ if (@PARAM_HASH.has_key?("QUERY_BY_HIERARCHY"))
303
+ calc_report_tps()
304
+ path = "/interfaces/bpdailyreport2"
305
+ query = "ACCOUNT_ID=#{@ACCOUNT_ID}&"
306
+ query += uri_query(@PARAM_HASH)
307
+ elsif (@PARAM_HASH.has_key?("REPORT_START_DATE"))
308
+ calc_report_tps()
309
+ path = "/interfaces/stq"
310
+ query = "ACCOUNT_ID=#{@ACCOUNT_ID}&"
311
+ query += uri_query(@PARAM_HASH)
312
+ elsif (@PARAM_HASH["TRANS_TYPE"] != "SET" and @PARAM_HASH["TRANS_TYPE"] != "GET")
313
+ calc_tps()
314
+ path = "/interfaces/bp10emu"
315
+ query = "MERCHANT=#{@ACCOUNT_ID}&"
316
+ query += uri_query(@PARAM_HASH)
317
+ else
318
+ calc_rebill_tps()
319
+ path = "/interfaces/bp20rebadmin"
320
+ query = "ACCOUNT_ID=#{@ACCOUNT_ID}&"
321
+ query += uri_query(@PARAM_HASH)
322
+ end
323
+
324
+ queryheaders = {
325
+ 'User-Agent' => 'Bluepay Ruby Client',
326
+ 'Content-Type' => 'application/x-www-form-urlencoded'
327
+ }
328
+ @PARAM_HASH["VERSION"] = '3'
329
+ # Post parameters to BluePay gateway
330
+ headers, body = ua.post(path, query, queryheaders)
331
+ # Split the response into the response hash.
332
+ @RESPONSE_HASH = {}
333
+ if path == "/interfaces/bp10emu"
334
+ response = headers["Location"].split("?")[1]
335
+ else
336
+ response = headers.body
337
+ end
338
+ response.split("&").each { |pair|
339
+ (key, val) = pair.split("=")
340
+ val = "" if(val == nil)
341
+ @RESPONSE_HASH[URI.unescape(key)] = URI.unescape(val)
342
+ }
343
+ end
344
+
345
+ def get_response()
346
+ return @RESPONSE_HASH
347
+ end
348
+
349
+ # Returns E for Error, 1 for Approved, 0 for Decline
350
+ def get_status()
351
+ return @RESPONSE_HASH['Result']
352
+ end
353
+
354
+ # Returns the human-readable response from Bluepay.
355
+ # Or a nasty error.
356
+ def get_message()
357
+ m = @RESPONSE_HASH['MESSAGE']
358
+ if (m == nil or m == "")
359
+ return "ERROR - NO MESSAGE FROM BLUEPAY"
360
+ end
361
+ return m
362
+ end
363
+
364
+ # Returns the single-character AVS response from the
365
+ # Card Issuing Bank
366
+ def get_avs_code()
367
+ return @RESPONSE_HASH['AVS']
368
+ end
369
+
370
+ # Same as avs_code, but for CVV2
371
+
372
+ def get_cvv2_code()
373
+ return @RESPONSE_HASH['CVV2']
374
+ end
375
+
376
+ # In the case of an approved transaction, contains the
377
+ # 6-character authorization code from the processing network.
378
+ # In the case of a decline or error, the contents may be junk.
379
+ def get_auth_code()
380
+ return @RESPONSE_HASH['AUTH_CODE']
381
+ end
382
+
383
+ # The all-important transaction ID.
384
+ def get_trans_id()
385
+ return @RESPONSE_HASH['RRNO']
386
+ end
387
+
388
+ # If you set up a rebilling, this'll get its ID.
389
+ def get_rebill_id()
390
+ return @RESPONSE_HASH['REBID']
391
+ end
392
+
393
+ # Masked credit card or ACH account
394
+ def get_masked_account()
395
+ return @RESPONSE_HASH['PAYMENT_ACCOUNT']
396
+ end
397
+
398
+ # Card type used in transaction
399
+ def get_card_type()
400
+ return @RESPONSE_HASH['CARD_TYPE']
401
+ end
402
+
403
+ # Bank account used in transaction
404
+ def get_bank_name()
405
+ return @RESPONSE_HASH['BANK_NAME']
406
+ end
407
+
408
+ # Rebill ID from bprebadmin API
409
+ def get_reb_id()
410
+ return @RESPONSE_HASH['rebill_id']
411
+ end
412
+
413
+ # Template ID of rebilling
414
+ def get_template_id()
415
+ return @RESPONSE_HASH['template_id']
416
+ end
417
+
418
+ # Status of rebilling
419
+ def get_rebill_status()
420
+ return @RESPONSE_HASH['status']
421
+ end
422
+
423
+ # Creation date of rebilling
424
+ def get_creation_date()
425
+ return @RESPONSE_HASH['creation_date']
426
+ end
427
+
428
+ # Next date that the rebilling is set to fire off on
429
+ def get_next_date()
430
+ return @RESPONSE_HASH['next_date']
431
+ end
432
+
433
+ # Last date that the rebilling fired off on
434
+ def get_last_date()
435
+ return @RESPONSE_HASH['last_date']
436
+ end
437
+
438
+ # Rebilling expression
439
+ def get_sched_expression()
440
+ return @RESPONSE_HASH['sched_expr']
441
+ end
442
+
443
+ # Number of cycles remaining on rebilling
444
+ def get_cycles_remaining()
445
+ return @RESPONSE_HASH['cycles_remain']
446
+ end
447
+
448
+ # Amount to charge when rebilling fires off
449
+ def get_rebill_amount()
450
+ return @RESPONSE_HASH['reb_amount']
451
+ end
452
+
453
+ # Next amount to charge when rebilling fires off
454
+ def get_next_amount()
455
+ return @RESPONSE_HASH['next_amount']
456
+ end
457
+
458
+ # Transaction ID used with stq API
459
+ def get_id()
460
+ return @RESPONSE_HASH['id']
461
+ end
462
+
463
+ # First name associated with the transaction
464
+ def get_name1()
465
+ return @RESPONSE_HASH['name1']
466
+ end
467
+
468
+ # Last name associated with the transaction
469
+ def get_name2()
470
+ return @RESPONSE_HASH['name2']
471
+ end
472
+
473
+ # Payment type associated with the transaction
474
+ def get_payment_type()
475
+ return @RESPONSE_HASH['payment_type']
476
+ end
477
+
478
+ # Transaction type associated with the transaction
479
+ def get_trans_type()
480
+ return @RESPONSE_HASH['trans_type']
481
+ end
482
+
483
+ # Amount associated with the transaction
484
+ def get_amount()
485
+ return @RESPONSE_HASH['amount']
486
+ end
487
+
488
+ end