vantiv 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +7 -0
  2. data/.env.example +4 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +2 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +5 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +354 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +19 -0
  12. data/bin/generate_sandbox_fixtures +23 -0
  13. data/bin/paypage_server +20 -0
  14. data/bin/setup +7 -0
  15. data/cert_fixtures/L_AC_1.json +27 -0
  16. data/cert_fixtures/L_AC_1A.json +8 -0
  17. data/cert_fixtures/L_AC_2.json +27 -0
  18. data/cert_fixtures/L_AC_2A.json +8 -0
  19. data/cert_fixtures/L_AC_3.json +26 -0
  20. data/cert_fixtures/L_AC_3A.json +8 -0
  21. data/cert_fixtures/L_AC_4.json +25 -0
  22. data/cert_fixtures/L_AC_4A.json +8 -0
  23. data/cert_fixtures/L_AC_5.json +18 -0
  24. data/cert_fixtures/L_AC_5A.json +8 -0
  25. data/cert_fixtures/L_AC_6.json +27 -0
  26. data/cert_fixtures/L_AC_7.json +26 -0
  27. data/cert_fixtures/L_AC_8.json +26 -0
  28. data/cert_fixtures/L_AC_9.json +26 -0
  29. data/cert_fixtures/L_AR_1.json +27 -0
  30. data/cert_fixtures/L_AR_1A.json +9 -0
  31. data/cert_fixtures/L_AR_1B.json +8 -0
  32. data/cert_fixtures/L_AR_2.json +27 -0
  33. data/cert_fixtures/L_AR_2A.json +8 -0
  34. data/cert_fixtures/L_AR_3.json +26 -0
  35. data/cert_fixtures/L_AR_3A.json +8 -0
  36. data/cert_fixtures/L_AR_4.json +25 -0
  37. data/cert_fixtures/L_AR_4A.json +9 -0
  38. data/cert_fixtures/L_AR_4B.json +9 -0
  39. data/cert_fixtures/L_AR_5.json +17 -0
  40. data/cert_fixtures/L_AR_5A.json +9 -0
  41. data/cert_fixtures/L_EP_1.json +15 -0
  42. data/cert_fixtures/L_EP_2.json +15 -0
  43. data/cert_fixtures/L_EP_3.json +11 -0
  44. data/cert_fixtures/L_EP_4.json +15 -0
  45. data/cert_fixtures/L_EP_5.json +15 -0
  46. data/cert_fixtures/L_EP_6.json +15 -0
  47. data/cert_fixtures/L_EP_7.json +15 -0
  48. data/cert_fixtures/L_RC_1.json +27 -0
  49. data/cert_fixtures/L_RC_1A.json +8 -0
  50. data/cert_fixtures/L_RC_1B.json +8 -0
  51. data/cert_fixtures/L_RC_2.json +27 -0
  52. data/cert_fixtures/L_RC_2A.json +8 -0
  53. data/cert_fixtures/L_RC_2B.json +8 -0
  54. data/cert_fixtures/L_RC_3.json +26 -0
  55. data/cert_fixtures/L_RC_3A.json +8 -0
  56. data/cert_fixtures/L_RC_3B.json +8 -0
  57. data/cert_fixtures/L_RC_4.json +25 -0
  58. data/cert_fixtures/L_RC_4A.json +8 -0
  59. data/cert_fixtures/L_RC_4B.json +8 -0
  60. data/cert_fixtures/L_RC_5.json +18 -0
  61. data/cert_fixtures/L_RC_5A.json +8 -0
  62. data/cert_fixtures/L_RC_5B.json +8 -0
  63. data/cert_fixtures/L_RC_6.json +27 -0
  64. data/cert_fixtures/L_RC_6A.json +8 -0
  65. data/cert_fixtures/L_RC_7.json +26 -0
  66. data/cert_fixtures/L_RC_7A.json +8 -0
  67. data/cert_fixtures/L_RC_8.json +18 -0
  68. data/cert_fixtures/L_S_1.json +27 -0
  69. data/cert_fixtures/L_S_2.json +27 -0
  70. data/cert_fixtures/L_S_3.json +26 -0
  71. data/cert_fixtures/L_S_4.json +25 -0
  72. data/cert_fixtures/L_S_5.json +18 -0
  73. data/cert_fixtures/L_S_6.json +26 -0
  74. data/cert_fixtures/L_S_7.json +26 -0
  75. data/cert_fixtures/L_S_8.json +26 -0
  76. data/cert_fixtures/L_S_9.json +26 -0
  77. data/cert_fixtures/L_T_1.json +11 -0
  78. data/cert_fixtures/L_T_10.json +19 -0
  79. data/cert_fixtures/L_T_11.json +19 -0
  80. data/cert_fixtures/L_T_2.json +11 -0
  81. data/cert_fixtures/L_T_3.json +12 -0
  82. data/cert_fixtures/L_T_4.json +11 -0
  83. data/cert_fixtures/L_T_6.json +19 -0
  84. data/cert_fixtures/L_T_7.json +19 -0
  85. data/cert_fixtures/L_T_8.json +19 -0
  86. data/cert_fixtures/L_T_9.json +20 -0
  87. data/cert_fixtures/L_V_1.json +27 -0
  88. data/cert_fixtures/L_V_1A.json +8 -0
  89. data/cert_fixtures/L_V_1B.json +8 -0
  90. data/cert_fixtures/L_V_1C.json +8 -0
  91. data/cert_fixtures/L_V_2.json +27 -0
  92. data/cert_fixtures/L_V_2A.json +8 -0
  93. data/cert_fixtures/L_V_3.json +18 -0
  94. data/cert_fixtures/L_V_3A.json +8 -0
  95. data/cert_fixtures/L_V_4.json +26 -0
  96. data/cert_fixtures/L_V_4A.json +8 -0
  97. data/exe/vantiv-certify-app +23 -0
  98. data/lib/vantiv.rb +152 -0
  99. data/lib/vantiv/api.rb +10 -0
  100. data/lib/vantiv/api/capture_response.rb +26 -0
  101. data/lib/vantiv/api/endpoints.rb +15 -0
  102. data/lib/vantiv/api/live_transaction_response.rb +50 -0
  103. data/lib/vantiv/api/request.rb +75 -0
  104. data/lib/vantiv/api/request_body.rb +111 -0
  105. data/lib/vantiv/api/request_body_generator.rb +43 -0
  106. data/lib/vantiv/api/response.rb +50 -0
  107. data/lib/vantiv/api/tied_transaction_response.rb +30 -0
  108. data/lib/vantiv/api/tokenization_response.rb +45 -0
  109. data/lib/vantiv/certification/cert_request_body_compiler.rb +38 -0
  110. data/lib/vantiv/certification/paypage_driver.rb +54 -0
  111. data/lib/vantiv/certification/paypage_server.rb +70 -0
  112. data/lib/vantiv/certification/response_cache.rb +29 -0
  113. data/lib/vantiv/certification/validation_test_runner.rb +103 -0
  114. data/lib/vantiv/certification/views/index.html.erb +76 -0
  115. data/lib/vantiv/environment.rb +14 -0
  116. data/lib/vantiv/mocked_sandbox.rb +29 -0
  117. data/lib/vantiv/mocked_sandbox/api_request.rb +53 -0
  118. data/lib/vantiv/mocked_sandbox/fixture_generator.rb +48 -0
  119. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json.erb +23 -0
  120. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json.erb +23 -0
  121. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010010900010.json.erb +21 -0
  122. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json.erb +23 -0
  123. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json.erb +23 -0
  124. data/lib/vantiv/paypage.rb +7 -0
  125. data/lib/vantiv/test_card.rb +94 -0
  126. data/lib/vantiv/version.rb +3 -0
  127. data/vantiv-ruby.gemspec +29 -0
  128. metadata +271 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 923cb51d4a0626d8b63cb9139ff3961ea5bbbd96
4
+ data.tar.gz: 5ce0a976b96f07c76e1251d5c4de9b453b26b56f
5
+ SHA512:
6
+ metadata.gz: 4209143635bf22f01654e50a1dbddd61b331a1329b0a9d5a4fb26b74da986260a2e3c7c6cfee33667cfec3ef6b200fc862ae2724cf4fe85b903a255d3e7dd2f3
7
+ data.tar.gz: 3b61c32775ed45e78a0cd3f1454acd7729b56abbf9e7bb6743ff7e8f20a60bdfc524c15c49bb15fb843a487517f1c061bd3216ef447723e4dd63c8ffd67239e1
@@ -0,0 +1,4 @@
1
+ # This is an example .env file
2
+ ACCEPTOR_ID="paste-vantiv-acceptor-id-here"
3
+ LICENSE_ID="paste-vantiv-license-id-here"
4
+ PAYPAGE_ID="paste-vantiv-paypage-id-here"
@@ -0,0 +1,11 @@
1
+ /.env
2
+ /certs.txt
3
+ /.bundle/
4
+ /.yardoc
5
+ /Gemfile.lock
6
+ /_yardoc/
7
+ /coverage/
8
+ /doc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ 2.2.3
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ before_install: gem install bundler -v 1.10.6
3
+ cache: bundler
4
+ notifications:
5
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Joshua Balloch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,354 @@
1
+ # Vantiv Ruby Client
2
+ [![Build Status](https://travis-ci.org/plated/vantiv-ruby.svg)](https://travis-ci.org/plated/vantiv-ruby)
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'vantiv-ruby'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install vantiv-ruby
19
+
20
+ ## Configuration
21
+
22
+ The gem needs the following configuration to be set on app initialization. It is highly recommended that you do not commit sensitive data into version control, but instead use environment variables.
23
+
24
+ ```ruby
25
+ Vantiv.configure do |config|
26
+ config.license_id = ENV["VANTIV_LICENSE_ID"]
27
+ config.acceptor_id = ENV["VANTIV_ACCEPTOR_ID"]
28
+ config.order_source = "desired-order-source"
29
+ config.paypage_id = ENV["VANTIV_PAYPAGE_ID"]
30
+
31
+ config.default_report_group = 'default-report-group'
32
+ end
33
+ ```
34
+
35
+ ## Certification
36
+
37
+ Vantiv's DevHub requires merchants to certify their applications for usage with their API. To make this integration process easy, the gem provides a script to run through these tests.
38
+
39
+ To certify your application, run the following script:
40
+
41
+ ```
42
+ $ LICENSE_ID=sub-your-license-id-in-here ACCEPTOR_ID=sub-your-acceptor-id-in-here PAYPAGE_ID=your-paypage-id vantiv-certify-app
43
+ ```
44
+
45
+ A certs.txt file will be generated in the directory that the script is run, and then opened. It contains a list of DevHub Certification test names and associated Request IDs, like follows:
46
+
47
+ ```
48
+ L_AC_1, request-id-for-L_AC_1-here
49
+ L_AC_2, request-id-for-L_AC_2-here
50
+ ```
51
+
52
+ Navigate to your application's page in DevHub's developer portal (apideveloper.vantiv.com). Paste the contents of this file into the validation form input field, and then click "Validate".
53
+
54
+ ## Usage
55
+
56
+ The vantiv-ruby gem provides a simple ruby client for interacting with Vantiv's DevHub API. This API wraps their Litle/XML API and provides an API that uses json. This gem provides a way for a merchant to:
57
+
58
+ 1. Use Vantiv's eProtect feature to tokenize sensitive card information directly to Vantiv's servers.
59
+ 2. Run the following transactions on customers' accounts:
60
+
61
+ 1. Authorizations (Vantiv.auth)
62
+ 2. Authorization reversals (Vantiv.auth_reversal)
63
+ 3. Capturing authorizations (Vantiv.capture)
64
+ 4. Direct authorization-and-captures (sales) (Vantiv.auth_capture)
65
+ 5. Credits (Vantiv.credit)
66
+ 6. Voids (Vantiv.void)
67
+ 7. Refunds (Vantiv.refund)
68
+
69
+ Please note that this gem only provides a structure for integrating with Vantiv in a structure where the merchant never handles sensitive card data. This enables merchants to seek a simpler PCI compliance level. As such, placing transactions via this ruby client requires the merchant to first tokenize cardholder data via Vantiv's eProtect feature (supported).
70
+
71
+ ### Tokenizing via eProtect
72
+
73
+ This gem provides a structure for tokenizing client payment information via Vantiv's eProtect feature. The basic structure for tokenizing via eProtect are:
74
+
75
+ 1. Customer submits their payment information via a Vantiv iframe element.
76
+ 2. The iframe element returns a temporary token (Paypage Registration ID).
77
+ 3. The page submits the temporary token to the merchant server.
78
+ 4. The merchant server submits the temporary token to Vantiv, and receives a PaymentAccountID to store for future transactions.
79
+
80
+ #### Obtaining a Paypage Registration ID
81
+
82
+ To submit client card data and retrieve a temporary token from Vantiv, the merchant needs to add the Vantiv payframe to a form where a user inputs their payment information. The payframe renders, within an iframe, four fields:
83
+
84
+ 1. Card number
85
+ 2. Expiry Month
86
+ 3. Expiry Year
87
+ 4. CVV
88
+
89
+ Other information, like billing address information, cardholder name, and others are rendered by the merchant's pay page and passed to the iframe as it submits card data.
90
+
91
+ To render the payframe, the merchant must include the payframe js file in the page and then initialize it like so:
92
+
93
+ ```
94
+ # html.erb example
95
+ <script src="<%= Vantiv.payframe_js %>" type="text/javascript"></script>
96
+ # OR:
97
+ <%= javascript_include_tag Vantiv.payframe_js %>
98
+ # OR it can be hardcoded:
99
+ <script src="https://request-prelive.np-securepaypage-litle.com/LitlePayPage/js/payframe-client.min.js" type="text/javascript"></script>
100
+ ```
101
+
102
+ To initialize the payframe:
103
+ ```js
104
+ // Create a callback to pass to the payframe, which is called
105
+ // after the payframe submits and receives a response from Vantiv
106
+ var payframeClientCallback = function(response) {
107
+ if (response.response !== '870') {
108
+ // Then an error occurred.
109
+ // The response may have one of a few error codes plus a human readable message
110
+ // The merchant can decide what to do in this case
111
+ console.log(response.message);
112
+ } else {
113
+ // Then the temporary token has been retrieved, and the merchant can submit it
114
+ // to the merchant's servers to retrieve the PaymentAccountID
115
+ console.log(response.paypageRegistrationId);
116
+ }
117
+ }
118
+
119
+ // Initialize a Payframe client, which has many options
120
+ var client = new LitlePayframeClient({
121
+ "paypageId": "<%= Vantiv.paypage_id %>",
122
+ "style":"sample2",
123
+ "height":"250",
124
+ "reportGroup":"IFrame Sample",
125
+ "timeout":"60000",
126
+ "div": "payframe", // this references the ID of the element in which you want the payframe to render
127
+ "callback": payframeClientCallback,
128
+ "showCvv": true,
129
+ "months": {
130
+ "1":"January",
131
+ "2":"February",
132
+ "3":"March",
133
+ "4":"April",
134
+ "5":"May",
135
+ "6":"June",
136
+ "7":"July",
137
+ "8":"August",
138
+ "9":"September",
139
+ "10":"October",
140
+ "11":"November",
141
+ "12":"December"
142
+ },
143
+ "numYears": 8,
144
+ "tooltipText": "A CVV is the 3 digit code on the back of your Visa, MasterCard and Discover or a 4 digit code on the front of your American Express",
145
+ "tabIndex": {
146
+ "cvv":4,
147
+ "accountNumber":1,
148
+ "expMonth":2,
149
+ "expYear":3
150
+ },
151
+ "placeholderText": {
152
+ "cvv":"CVV",
153
+ "accountNumber":"Account Number"
154
+ }
155
+ });
156
+
157
+ // Now with a client initialize, the merchant is responsible for interrupting form submission
158
+ // in whatever way it wants (this is only an example), getting the temporary token, and
159
+ // then proceeding as it wishes.
160
+ window.onFormSubmit = function(){
161
+ client.getPaypageRegistrationId({
162
+ "id": "customer-id?",
163
+ "orderId": "someOrderID"
164
+ });
165
+
166
+ return false;
167
+ }
168
+ ```
169
+
170
+ The above example shows the basic mechanics of rendering and interacting with the payframe.
171
+
172
+ TODO: add more infor on payframe error codes here
173
+
174
+ Once the temporary token has been retrieved, it should be posted to the merchant server, where the gem can be used to retrieved the permanent token (PaymentAccountID).
175
+
176
+ #### Retrieving a Payment Account ID
177
+
178
+ In the server, once a temporary token has been received, a permanent token can be retrieved. To do so, use the `tokenize` method:
179
+
180
+ ```ruby
181
+ Vantiv.tokenize(temporary_token: 'temporary-token-here')
182
+ ```
183
+
184
+ This will return a TokenizationResponse object, which responds to `success?` and `failure?`, and which returns the `payment_account_id` retrieved from Vantiv. The merchant should save this token for use on future transactions.
185
+
186
+ NOTES: There are a few gotchas with tokenization, namely:
187
+
188
+ 1. PaymentAccountIDs in Vantiv are unique to the card information. If a merchant has two users using the same card info, it may end up retrieving the same PaymentAccountID for both clients. Depending on how the merchant runs its reporting/attribution, this may be a concern to look into.
189
+ 2. The process of tokenization does not provide any assurance on the validity of a cardholder's account. An auth can be used to check this validity.
190
+
191
+ ### Authorizations
192
+
193
+ Authorizations enable a merchant to confirm the validity of a submitted payment method and place a hold on funds for a purchase of goods or services from a merchant. They last from 7-30 days, depending on the payment type:
194
+
195
+ | Network | Auth Lifespan |
196
+ | ------------- | ------------- |
197
+ | Amex | 7 days |
198
+ | Discover | 10 days |
199
+ | Mastercard | 7 days |
200
+ | Paypal | 29 days (Vantiv recommends 3 days max) |
201
+ | Paypal Credit | 30 days |
202
+ | Visa | 7 days |
203
+
204
+ To place an authorization on a client's card, simply do:
205
+
206
+ ```ruby
207
+ Vantiv.auth(
208
+ payment_account_id: '12345', # retrieved earlier
209
+ amount: 10000, # amount in cents, as an integer
210
+ customer_id: '123',
211
+ external_id: 'order123'
212
+ )
213
+
214
+ ```
215
+
216
+ Notes:
217
+
218
+ 1. See Tokenizing via eProtect for notes on how to retrieve a payment account id.
219
+ 2. Customer ID and Order ID are reference data required for placing authorizations and auth_captures in Vantiv's system. The merchant can choose what reference data to put in here; they only need to exist.
220
+
221
+ ### Authorization Reversals
222
+
223
+ Authorization reversals allow a merchant to remove a hold on a client's credit card, freeing up funds to use on other purchases. Authorization reversals can reverse the full amount of an authorization, or the remaining balance after a partial capture of an authorization.
224
+ Amount must be less than the amount authorized.
225
+
226
+ ```ruby
227
+ Vantiv.auth_reversal(
228
+ transaction_id: 'transaction-id-from-auth', # retrieved earlier
229
+ amount: 10000, # amount in cents, as an integer. must be less than or equal to auth amount.
230
+ )
231
+
232
+ ```
233
+
234
+ ### Capturing Authorizations
235
+
236
+ Captures enable a merchant to charge a customer funds previously placed under an authorization. To place a capture, simply do:
237
+
238
+ ```ruby
239
+ Vantiv.capture(transaction_id: 'transaction-id-from-auth')
240
+ ```
241
+
242
+ The above captures the full amount placed on hold via a previous authorization.
243
+
244
+ It is possible for a merchant to capture an amount differing from the amount placed on the authorization. Use cases for this typically consist of orders that are fulfilled in steps, for examples multiple shipments, or services for which the final charge is not determined at the point of authorization, like restaurants / tips. To perform a partial capture, simply pass the optional amount argument to the capture:
245
+
246
+ ```ruby
247
+ Vantiv.capture(
248
+ transaction_id: 'transaction-id-from-auth',
249
+ amount: 10000 #amount in cents
250
+ )
251
+ ```
252
+
253
+ It is possible to capture an amount exceeding the amount authorized, there are some restrictions that may vary from network to network on how much it can be exceeded by. It is recommended not to do so without consulting Vantiv or other relevant groups.
254
+
255
+ ### Auth capture (sales)
256
+
257
+ TODO: Add usage info
258
+
259
+ ### Credits
260
+
261
+ Vantiv's Credit transaction enables a merchant to refund customers money against the following transactions:
262
+
263
+ 1. Capture Transactions
264
+ 2. Sale Transactions
265
+
266
+ To perform a credit, simply:
267
+
268
+ ```ruby
269
+ Vantiv.credit(
270
+ transaction_id: 'transaction-id-from-prior-transaction',
271
+ amount: 10000 #amount to refund in cents
272
+ )
273
+ ```
274
+
275
+ NOTE: Vantiv does NOT provide any transaction checking when a request is received to credit a customer. This includes even not checking that the prior transaction _even exists_. See 'Tied Transaction Error Handling' for more info.
276
+
277
+ ### Voids
278
+
279
+ > The Void transaction enables you to cancel any settlement transaction as long as the transaction has not yet settled and the original transaction occurred within the system.
280
+ > Do not use Void transactions to void an Authorization. To remove an Authorization use an Authorization reversal transaction.
281
+
282
+ TODO: Add usage info
283
+
284
+ ### Refunds
285
+
286
+ TODO: Add usage info
287
+
288
+ ## Usage in non-production environments
289
+
290
+ To use the gem in any non-production environment, set the client's environment to the certification environment.
291
+
292
+ ```ruby
293
+ Vantiv.configure do |config|
294
+ config.environment = Vantiv::Environment::CERTIFICATION
295
+ end
296
+ ```
297
+
298
+ This directs the gem to make API requests to Vantiv's pre-live, certification environment. Transactions made in this environment behave like in production, but do not result in any charges going through.
299
+
300
+ Vantiv provides a whitelist of card numbers that lead to certain types of behaviour that merchants may wish to enact when developing their applications.
301
+
302
+ The gem provides a simple `Vantiv::TestCard` class for users' convenience. For example, Vantiv's whitelist includes a Visa card that maps to a 'valid account' - one for which all auths / charges will process successfully. This info can be accessed via `Vantiv::TestCard`, which returns an object with all of the card info needed:
303
+
304
+ ```ruby
305
+ card = Vantiv::TestCard.valid_account
306
+ card.card_number
307
+ card.cvv
308
+ card.expiry_month
309
+ card.expiry_year
310
+ card.network
311
+ card.name
312
+ ```
313
+
314
+ The `TestCard` class does not encompass the complete list of whitelisted cards, though more cards will continue to be added to it. For a complete list & more information on Vantiv's whitelisted cards, please see Vantiv's documentation.
315
+
316
+ NOTE: The card object also has a `mocked_sandbox_payment_account_id`. This is not the payment_account_id that the pre-live environment will return for the card - this varies from merchant to merchant.
317
+
318
+ ## Usage in test environments
319
+
320
+ This gem comes prepackaged with a way to operate in applications' test environments without making external Web requests. Users can rest assured that this self-mocked setup responds exactly like the Vantiv pre-live (certification) environment does. It is *highly recommended* that users enable this in their tests.
321
+
322
+ To enable this, simply add the following to your spec_helper, if using RSpec, or call this at the beginning of the test suite:
323
+
324
+ ```ruby
325
+ Vantiv::MockedSandbox.enable_self_mocked_requests!
326
+ ```
327
+
328
+ From a user perspective, the gem will behave identically as when it is not self mocked. Users can use `TestCard`s to get the responses they would also expect to receive in the certification environment. The only difference is that in mocked mode, the gem will return stable payment_account_ids for tokenizing card information, which can be accessed on a test card as `#mocked_sandbox_payment_account_id`
329
+
330
+ The only gotcha is that only whitelisted cards included in the `TestCard` class will function in the test environment. If there is one missing that is useful to you, please open an issue (or a PR).
331
+
332
+ See 'Usage in non-production environments' above for more information.
333
+
334
+ If it is _necessary_ to, this can be disabled at any time:
335
+
336
+ ```ruby
337
+ Vantiv::MockedSandbox.disable_self_mocked_requests!
338
+ ```
339
+
340
+ ## Development
341
+
342
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
343
+
344
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
345
+
346
+ ## Contributing
347
+
348
+ Bug reports and pull requests are welcome on GitHub at https://github.com/plated/vantiv-ruby.
349
+
350
+
351
+ ## License
352
+
353
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
354
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vantiv"
5
+
6
+ require "dotenv"
7
+ Dotenv.load
8
+ Vantiv.configure do |config|
9
+ config.environment = Vantiv::Environment::CERTIFICATION
10
+ config.license_id = ENV["LICENSE_ID"]
11
+ config.acceptor_id = ENV["ACCEPTOR_ID"]
12
+ config.order_source = "ecommerce"
13
+ config.paypage_id = ENV["PAYPAGE_ID"]
14
+
15
+ config.default_report_group = '1'
16
+ end
17
+
18
+ require "pry"
19
+ Pry.start