alpha_card 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -4
  3. data/CHANGELOG.md +21 -3
  4. data/Gemfile +0 -2
  5. data/Gemfile.lock +6 -24
  6. data/README.md +115 -85
  7. data/ROADMAP.md +13 -9
  8. data/alpha_card.gemspec +3 -4
  9. data/lib/alpha_card.rb +44 -72
  10. data/lib/alpha_card/account.rb +51 -0
  11. data/lib/alpha_card/attribute.rb +337 -0
  12. data/lib/alpha_card/data/credit_card_codes.yml +54 -54
  13. data/lib/alpha_card/errors/invalid_attribute_format.rb +14 -0
  14. data/lib/alpha_card/errors/invalid_attribute_type.rb +14 -0
  15. data/lib/alpha_card/errors/invalid_attribute_value.rb +14 -0
  16. data/lib/alpha_card/errors/{invalid_object_error.rb → validation_error.rb} +1 -1
  17. data/lib/alpha_card/{alpha_card_object.rb → resource.rb} +14 -28
  18. data/lib/alpha_card/resources/billing.rb +29 -0
  19. data/lib/alpha_card/{objects → resources}/order.rb +8 -8
  20. data/lib/alpha_card/{objects → resources}/shipping.rb +15 -13
  21. data/lib/alpha_card/{alpha_card_response.rb → response.rb} +21 -6
  22. data/lib/alpha_card/transaction.rb +30 -0
  23. data/lib/alpha_card/transactions/auth.rb +18 -0
  24. data/lib/alpha_card/transactions/capture.rb +32 -0
  25. data/lib/alpha_card/transactions/credit.rb +18 -0
  26. data/lib/alpha_card/{objects → transactions}/refund.rb +9 -2
  27. data/lib/alpha_card/transactions/sale.rb +91 -0
  28. data/lib/alpha_card/transactions/update.rb +61 -0
  29. data/lib/alpha_card/transactions/validate.rb +21 -0
  30. data/lib/alpha_card/transactions/void.rb +26 -0
  31. data/lib/alpha_card/version.rb +1 -1
  32. data/spec/alpha_card/attribute_spec.rb +126 -0
  33. data/spec/alpha_card/response_spec.rb +8 -4
  34. data/spec/alpha_card/transactions/auth_spec.rb +43 -0
  35. data/spec/alpha_card/{objects → transactions}/capture_spec.rb +11 -12
  36. data/spec/alpha_card/transactions/credit_spec.rb +102 -0
  37. data/spec/alpha_card/{objects → transactions}/refund_spec.rb +4 -4
  38. data/spec/alpha_card/{objects → transactions}/sale_spec.rb +42 -41
  39. data/spec/alpha_card/{objects → transactions}/update_spec.rb +4 -4
  40. data/spec/alpha_card/transactions/validate_spec.rb +100 -0
  41. data/spec/alpha_card/{objects → transactions}/void_spec.rb +11 -11
  42. data/spec/spec_helper.rb +4 -0
  43. metadata +36 -47
  44. data/lib/alpha_card/errors/alpha_card_error.rb +0 -29
  45. data/lib/alpha_card/objects/account.rb +0 -48
  46. data/lib/alpha_card/objects/billing.rb +0 -31
  47. data/lib/alpha_card/objects/capture.rb +0 -51
  48. data/lib/alpha_card/objects/sale.rb +0 -82
  49. data/lib/alpha_card/objects/update.rb +0 -54
  50. data/lib/alpha_card/objects/void.rb +0 -45
  51. data/spec/alpha_card/objects/account_spec.rb +0 -20
  52. data/spec/alpha_card/objects/deprecated_methods_spec.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e5ac24025977d5cd2c3406cba14ebde613b4f7b
4
- data.tar.gz: 7696ce4ea24336d3214c056e612a7e5a068940fc
3
+ metadata.gz: be339a6f92fcdf01468ecf0da9522e8a6369672c
4
+ data.tar.gz: 1ccab5e6c73ea8a0d98b18854a05e62c9ba807bb
5
5
  SHA512:
6
- metadata.gz: 3666ded11769f172c69f8dee353a22a762daa403e850a46fc82174b968fee31339a6b101fd9cf7a0885a4b0c4c667aee8ad748e58e7b6558e9d848b60d823a8a
7
- data.tar.gz: 453305dfd596b13e12ce9ea3064cd188806ba429bf9d5d51c9573cf022d646e592c1ebeaf18fce331dd5cd19f7b8330f8a79f6dd16885aa914e3a5c3d8bf1485
6
+ metadata.gz: 5aea65ee2cf8ac68bba49a46937c60c5d175204ff4d8b64431490a74ee3ef80d2ea0dc536e64c189d190275e22f41d90d8de382847160597e73e0e65b49bae25
7
+ data.tar.gz: ca8da9382717060a317522d35732ded4a68dc2e174abf2866bcf7e07c81bcecafc91efe405bae37e530c070e6e0d12497fbfbad19895366707b28245edf7583f
@@ -3,12 +3,12 @@ before_install: gem install bundler
3
3
  bundler_args: --without yard guard benchmarks
4
4
  script: "rake spec"
5
5
  rvm:
6
- - 2.0.0
7
- - 2.1.5
8
6
  - 2.2.4
9
7
  - 2.3.0
10
- - jruby-9.0.0.0
8
+ - jruby-9.0.5.0
9
+ - jruby-9.1.5.0
11
10
  - ruby-head
11
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
12
12
  matrix:
13
13
  allow_failures:
14
- - rvm: ruby-head
14
+ - rvm: ruby-head
@@ -2,11 +2,29 @@
2
2
 
3
3
  Reverse Chronological Order:
4
4
 
5
+ ## `0.4.0` (2016-10-07)
6
+
7
+ https://github.com/nbulaj/alpha_card/compare/0.3.0...0.4.0
8
+
9
+ ### Breaking changes
10
+ * Dropped support of Ruby <= 2.2.2
11
+ * Removed deprecated methods (a.k.a. old transaction variables names)
12
+ * All transactions now returns `AlphaCard::Response` regardless of the operation result (except HTTP errors)
13
+ * `AlphaCard::Account` now works as global Alpha Card Merchant Account configuration (see docs)
14
+
15
+ ### Other changes
16
+ * New AlphaCard transactions: `Auth`, `Credit`, `Validate`
17
+ * Own Attributes DSL with types, validations and other useful things
18
+ * Dropped `Virtus` dependency
19
+ * Fixed `check` payment (added new transaction variables for this type of operation)
20
+ * Credit Card authorization codes changes (removed dot at the end ot the message, improved `Response` API)
21
+ * Specs and documentation improvements
22
+
5
23
  ## `0.3.0` (2016-09-22)
6
24
 
7
25
  https://github.com/nbulaj/alpha_card/compare/0.2.6...0.3.0
8
26
 
9
- * Dropped support of Ruby 1.9.3
27
+ * Dropped support of Ruby 1.9.3 and jruby-1.7
10
28
  * New AlphaCard transactions: `Void`, `Refund`, `Capture`, `Update`
11
29
  * New AlphaCard transactions variables
12
30
  * New AlphaCard transactions variables naming (**old is deprecated**)
@@ -44,9 +62,9 @@ https://github.com/nbulaj/alpha_card/compare/0.2.4...0.2.6
44
62
  ## `0.1.9` (2014-07-02)
45
63
 
46
64
  * Errors handling
47
- * COde refactoring
48
- * Specs
65
+ * Code refactoring
49
66
  * Documentation improvements
67
+ * Specs
50
68
  * Fixes
51
69
 
52
70
  ## `0.1.0` (2014-06-25)
data/Gemfile CHANGED
@@ -2,8 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'virtus'
6
-
7
5
  group :test do
8
6
  gem 'coveralls', require: false
9
7
  gem 'rack-test', require: false
@@ -1,40 +1,29 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- alpha_card (0.3.0)
5
- rack (~> 1.2, >= 1.2)
6
- virtus (~> 1.0, >= 1.0.5)
4
+ alpha_card (0.4.0)
5
+ rack (~> 2.0, >= 2.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- axiom-types (0.1.1)
12
- descendants_tracker (~> 0.0.4)
13
- ice_nine (~> 0.11.0)
14
- thread_safe (~> 0.3, >= 0.3.1)
15
- coercible (1.0.0)
16
- descendants_tracker (~> 0.0.1)
17
10
  coveralls (0.8.15)
18
11
  json (>= 1.8, < 3)
19
12
  simplecov (~> 0.12.0)
20
13
  term-ansicolor (~> 1.3)
21
14
  thor (~> 0.19.1)
22
15
  tins (>= 1.6.0, < 2)
23
- descendants_tracker (0.0.4)
24
- thread_safe (~> 0.3, >= 0.3.1)
25
16
  diff-lcs (1.2.5)
26
17
  docile (1.1.5)
27
- equalizer (0.0.11)
28
- ice_nine (0.11.2)
29
18
  json (2.0.2)
30
- rack (1.6.4)
19
+ rack (2.0.1)
31
20
  rack-test (0.6.3)
32
21
  rack (>= 1.0)
33
22
  rspec (3.5.0)
34
23
  rspec-core (~> 3.5.0)
35
24
  rspec-expectations (~> 3.5.0)
36
25
  rspec-mocks (~> 3.5.0)
37
- rspec-core (3.5.3)
26
+ rspec-core (3.5.4)
38
27
  rspec-support (~> 3.5.0)
39
28
  rspec-expectations (3.5.0)
40
29
  diff-lcs (>= 1.2.0, < 2.0)
@@ -48,16 +37,10 @@ GEM
48
37
  json (>= 1.8, < 3)
49
38
  simplecov-html (~> 0.10.0)
50
39
  simplecov-html (0.10.0)
51
- term-ansicolor (1.3.2)
40
+ term-ansicolor (1.4.0)
52
41
  tins (~> 1.0)
53
42
  thor (0.19.1)
54
- thread_safe (0.3.5)
55
43
  tins (1.12.0)
56
- virtus (1.0.5)
57
- axiom-types (~> 0.1)
58
- coercible (~> 1.0)
59
- descendants_tracker (~> 0.0, >= 0.0.3)
60
- equalizer (~> 0.0, >= 0.0.9)
61
44
 
62
45
  PLATFORMS
63
46
  ruby
@@ -68,7 +51,6 @@ DEPENDENCIES
68
51
  coveralls
69
52
  rack-test
70
53
  rspec (~> 3.5)
71
- virtus
72
54
 
73
55
  BUNDLED WITH
74
- 1.12.5
56
+ 1.13.1
data/README.md CHANGED
@@ -20,7 +20,7 @@ https://secure.alphacardgateway.com/merchants/resources/integration/integration_
20
20
  If using bundler, first add 'alpha_card' to your Gemfile:
21
21
 
22
22
  ```ruby
23
- gem 'alpha_card', '~> 0.3'
23
+ gem 'alpha_card', '~> 0.4'
24
24
  ```
25
25
 
26
26
  And run:
@@ -32,50 +32,52 @@ bundle install
32
32
  Otherwise simply install the gem:
33
33
 
34
34
  ```sh
35
- gem install alpha_card
35
+ gem install alpha_card -v '0.4'
36
36
  ```
37
37
 
38
38
  Dependencies required:
39
39
 
40
- * ruby >= 2.0.0;
40
+ * ruby >= 2.0.0 or [jruby](https://github.com/jruby/jruby) >= 9.0.5.0;
41
41
 
42
- ## Alpha Card Objects & Transactions
42
+ ## Configure
43
43
 
44
- Alpha Card operates with next objects:
44
+ In order to use Alpha Card Gateway API you need to have a Merchant account credentials such as `username` and `password`.
45
45
 
46
- * Account
47
- * Order
48
- - Billing
49
- - Shipping
50
- * Sale
51
- * Refund
52
- * Void
53
- * Capture
54
- * Update
46
+ If your project will always use only one account, then you can configure gem as follows:
55
47
 
56
- Let us consider each of them.
48
+ ```ruby
49
+ # config/initializers/alpha_card.rb - for Rails projects
50
+ AlphaCard::Account.username = 'username'
51
+ AlphaCard::Account.password = 'password'
52
+ ```
57
53
 
58
- ### Account
54
+ Another way is to pass the credentials as a last argument when creating some transactions or perform operations (it can be useful when you need to operate with multiple Alpha Card accounts):
59
55
 
60
- Account represents credentials data to access Alpha Card Gateway.
61
- All transactions (`sale`, `refund`, etc) will be created for the specified account.
56
+ ```ruby
57
+ void = AlphaCard::Void.new(transaction_id: '312110')
58
+ void.process(username: 'demo', password: 'demo')
59
+ ```
62
60
 
63
- _Required fields_:
61
+ ## Alpha Card Objects & Transactions
64
62
 
65
- * username : `String`
66
- * password : `String`
63
+ Alpha Card operates with next objects:
67
64
 
68
- _Constructor_:
65
+ * [Order](#order)
66
+ - [Billing](#billing)
67
+ - [Shipping](#shipping)
68
+ * [Sale](#sale)/[Authorization](#authorization)/[Credit](#credit)/[Validate](#validate)
69
+ * [Refund](#refund)
70
+ * [Void](#void)
71
+ * [Capture](#capture)
72
+ * [Update](#update)
69
73
 
70
- ```ruby
71
- AlphaCard::Account.new(username, password)
72
- ```
74
+ Let us consider each of them.
73
75
 
74
76
  ### Order
75
77
 
76
78
  Order represents itself.
77
79
 
78
- _Optional fields_:
80
+ _Optional attributes_:
79
81
 
80
82
  * id : `String`
81
83
  * description : `String`
@@ -88,14 +90,14 @@ _Optional fields_:
88
90
  _Constructor_:
89
91
 
90
92
  ```ruby
91
- AlphaCard::Order.new(field_name: value, ...)
93
+ AlphaCard::Order.new(property: value, ...)
92
94
  ```
93
95
 
94
96
  ### Billing
95
97
 
96
98
  Specify Billing information for Order.
97
99
 
98
- _Optional fields_:
100
+ _Optional attributes_:
99
101
 
100
102
  * first_name : `String`
101
103
  * last_name : `String`
@@ -114,14 +116,14 @@ _Optional fields_:
114
116
  _Constructor_:
115
117
 
116
118
  ```ruby
117
- AlphaCard::Billing.new(field_name: value, ...)
119
+ AlphaCard::Billing.new(property: value, ...)
118
120
  ```
119
121
 
120
122
  ### Shipping
121
123
 
122
- Specify Shipping information for Order.
124
+ Contains Shipping information for the Order.
123
125
 
124
- _Optional fields_:
126
+ _Optional attributes_:
125
127
 
126
128
  * first_name : `String`
127
129
  * last_name : `String`
@@ -137,122 +139,133 @@ _Optional fields_:
137
139
  _Constructor_:
138
140
 
139
141
  ```ruby
140
- AlphaCard::Shipping.new(field_name: value, ...)
142
+ AlphaCard::Shipping.new(property: value, ...)
141
143
  ```
142
144
 
143
145
  ### Sale
144
146
 
145
- Sale is the main object of the Alpha Card Services. It processes fees associated with credit cards.
147
+ Sale transaction is the main object of the Alpha Card Services. It is used to processed common payments for orders.
146
148
 
147
- _Required fields_:
149
+ _Required attributes_:
148
150
 
149
151
  * card_expiration_date : `String` (format: `MMYY`)
150
152
  * card_number : `String`
151
153
  * amount : `String` (format: `x.xx`)
152
154
 
153
- _Optional fields_:
155
+ _Optional attributes_:
156
+
154
157
  * cvv : `String`
155
158
  * payment : `String` (default: `'creditcard'`, values: `'creditcard'` or `'check'`)
156
159
  * customer_receipt : `String` (values `'true'` or `'false'`)
160
+ * check_name : `String`
161
+ * check_aba : `String`
162
+ * check_account : `String`
163
+ * account_holder_type : `String` (values: `'business'` or `'personal'`)
164
+ * account_type : `String` (values: `'checking'` or `'savings'`)
165
+ * sec_code : `String` (values: `'PPD'`, `'WEB'`, `'TEL'`, or `'CCD'`)
157
166
 
158
167
  _Constructor_:
159
168
 
160
169
  ```ruby
161
- AlphaCard::Sale.new(field_name: value, ...)
170
+ AlphaCard::Sale.new(property: value, ...)
162
171
  ```
163
172
 
164
- To create the payment you must call *create(_alpha_card_order_, _alpha_card_account_)* method:
173
+ To create the payment you must call *create(_alpha_card_order_)* method:
165
174
 
166
175
  ```ruby
167
176
  # ...
168
177
  sale = AlphaCard::Sale.new(amount: 10)
169
- success, alpha_card_response = sale.create(order, account)
178
+ response = sale.process(order)
170
179
 
171
- # => [true, #<AlphaCard::AlphaCardResponse:0x1a0fda ...>]
180
+ # => #<AlphaCard::Response:0x1a0fda ...>
172
181
  ```
173
182
 
174
- This method returns _true_ if sale was created successfully and raise an `AlphaCardError` exception if some of the fields is invalid.
175
-
176
183
  ### Refund
177
184
 
178
185
  Represents refund transaction.
179
186
 
180
- _Required fields_:
187
+ _Required attributes_:
181
188
 
182
- * transaction_id : `String`
189
+ * transaction_id : `String` or `Integer`
183
190
 
184
- _Optional fields_:
191
+ _Optional attributes_:
185
192
 
186
193
  * amount : `String` (format: `x.xx`)
187
194
 
188
195
  _Constructor_:
189
196
 
190
197
  ```ruby
191
- AlphaCard::Refund.new(field_name: value, ...)
198
+ AlphaCard::Refund.new(property: value, ...)
192
199
  ```
193
200
 
194
- To create the refund transaction you must call *create(_alpha_card_account_)* method:
201
+ To create the refund transaction you must call *create* or *process* method:
195
202
 
196
203
  ```ruby
197
204
  # ...
198
205
  refund = AlphaCard::Refund.new(transaction_id: '12312312', amount: 10)
199
- refund.create(account)
206
+ refund.process
200
207
  ```
201
208
 
202
209
  ### Void
203
210
 
204
211
  Represents void transaction.
205
212
 
206
- _Required fields_:
213
+ _Required attributes_:
207
214
 
208
- * transaction_id : `String`
215
+ * transaction_id : `String` or `Integer`
209
216
 
210
217
  _Constructor_:
211
218
 
212
219
  ```ruby
213
- AlphaCard::Void.new(field_name: value, ...)
220
+ AlphaCard::Void.new(property: value, ...)
214
221
  ```
215
222
 
216
- To create the void transaction you must call *create(_alpha_card_account_)* method:
223
+ To create the void transaction you must call *create* or *process* method:
217
224
 
218
225
  ```ruby
219
226
  # ...
220
227
  void = AlphaCard::Void.new(transaction_id: '12312312')
221
- void.create(account)
228
+ void.create
222
229
  ```
223
230
 
224
231
  ### Capture
225
232
 
226
233
  Represents capture transaction.
227
234
 
228
- _Required fields_:
235
+ _Required attributes_:
229
236
 
230
- * transaction_id : `String`
231
- * amount : `String` (format: `x.xx`)
237
+ * transaction_id : `String` or `Integer`
238
+ * amount : `String` (format: `xx.xx`)
239
+
240
+ _Optional attributes_:
241
+
242
+ * tracking_number : `String`
243
+ * shipping_carrier : `String`
244
+ * order_id : `String`
232
245
 
233
246
  _Constructor_:
234
247
 
235
248
  ```ruby
236
- AlphaCard::Capture.new(field_name: value, ...)
249
+ AlphaCard::Capture.new(property: value, ...)
237
250
  ```
238
251
 
239
- To create the capture transaction you must call *create(_alpha_card_account_)* method:
252
+ To create the capture transaction you must call *create* or *process* method:
240
253
 
241
254
  ```ruby
242
255
  # ...
243
256
  capture = AlphaCard::Capture.new(transaction_id: '12312312', amount: '5.05')
244
- capture.create(account)
257
+ capture.create
245
258
  ```
246
259
 
247
260
  ### Update
248
261
 
249
262
  Represents update transaction.
250
263
 
251
- _Required fields_:
264
+ _Required attributes_:
252
265
 
253
- * transaction_id : `String`
266
+ * transaction_id : `String` or `Integer`
254
267
 
255
- _Optional fields_:
268
+ _Optional attributes_:
256
269
  * shipping: `String`
257
270
  * shipping_postal: `String`
258
271
  * ship_from_postal: `String`
@@ -279,17 +292,29 @@ _Optional fields_:
279
292
  _Constructor_:
280
293
 
281
294
  ```ruby
282
- AlphaCard::Update.new(field_name: value, ...)
295
+ AlphaCard::Update.new(property: value, ...)
283
296
  ```
284
297
 
285
- To create update transaction you must call *create(_alpha_card_account_)* method:
298
+ To create update transaction you must call *create* or *process* method:
286
299
 
287
300
  ```ruby
288
301
  # ...
289
302
  update = AlphaCard::Update.new(tax: '10.02', shipping_carrier: 'ups', transaction_id: '66928')
290
- update.create(account)
303
+ update.process
291
304
  ```
292
305
 
306
+ ### Authorization
307
+
308
+ Has the same attributes and methods as `Sale` transaction.
309
+
310
+ ### Credit
311
+
312
+ Has the same attributes and methods as `Sale` transaction.
313
+
314
+ ### Validate
315
+
316
+ Has the same attributes and methods as `Sale` transaction, except `amount` — there is no need in it.
317
+
293
318
  ## Example of usage
294
319
 
295
320
  Create AlphaCard sale (pay for the order):
@@ -298,7 +323,9 @@ Create AlphaCard sale (pay for the order):
298
323
  require 'alpha_card'
299
324
 
300
325
  def create_payment
301
- account = AlphaCard::Account.new('demo', 'password')
326
+ # Setup merchant account credentials
327
+ AlphaCard::Account.username = 'demo'
328
+ AlphaCard::Account.password = 'password'
302
329
 
303
330
  billing = AlphaCard::Billing.new(email: 'test@example.com', phone: '+801311313111')
304
331
  shipping = AlphaCard::Shipping.new(address_1: '33 N str', city: 'New York', state: 'NY', zip_code: '132')
@@ -307,14 +334,17 @@ def create_payment
307
334
 
308
335
  # Format of amount: "XX.XX" ("%.2f" % Float)
309
336
  sale = AlphaCard::Sale.new(card_epiration_date: '0117', card_number: '4111111111111111', amount: '1.50', cvv: '123')
310
- success, response = sale.create(order, account)
311
- #=> [true, #<AlphaCard::AlphaCardResponse:0x1a0fda ...>]
312
- puts "Order payed successfully: transaction ID = #{response.transaction_id} if success
313
- rescue AlphaCard::AlphaCardError => e
314
- puts "Error message: #{e.response.message}"
315
- puts "CVV response: #{e.response.cvv_response}"
316
- puts "AVS response: #{e.response.avs_response}"
317
- false
337
+ response = sale.create(order)
338
+ #=> #<AlphaCard::Response:0x1a0fda ...>
339
+ if response.success?
340
+ puts "Order payed successfully: transaction ID = #{response.transaction_id}"
341
+ true
342
+ else
343
+ puts "Error message: #{e.response.message}"
344
+ puts "CVV response: #{e.response.cvv_response}"
345
+ puts "AVS response: #{e.response.avs_response}"
346
+ false
347
+ end
318
348
  end
319
349
  ```
320
350
 
@@ -323,26 +353,16 @@ end
323
353
  _Note_: take a look at the `amount` of the Order. It's format must be 'xx.xx'. All the information about variables formats
324
354
  can be found on _Alpha Card Payment Gateway Integration Portal_ -> _Direct Post API_ -> _Documentation_ -> _Transaction Variables_
325
355
 
326
- Naming convention of attributes (such as "ccexp" or "orderid") was saved for compatibility with AlphaCard API.
327
-
328
- To raise some exceptions do the next:
356
+ To simulate request that returns an error do the next:
329
357
 
330
358
  * to cause a declined message, pass an amount less than 1.00;
331
359
  * to trigger a fatal error message, pass an invalid card number;
332
360
  * to simulate an AVS match, pass 888 in the address1 field, 77777 for zip;
333
361
  * to simulate a CVV match, pass 999 in the cvv field.
334
362
 
335
- Example of exception:
336
-
337
- ```ruby
338
- ...
339
- 2.1.1 :019 > sale.create(order, account)
340
- AlphaCard::AlphaCardError: Invalid Credit Card Number REFID:127145481
341
- ```
342
-
343
363
  ## AlphaCard Response
344
364
 
345
- `AlphaCardResponse` contains all the necessary information about Alpha Card Gateway response. You can use the following API:
365
+ `AlphaCard::Response` contains all the necessary information about Alpha Card Gateway response. You can use the following API:
346
366
 
347
367
  * `.text` — textual response of the Alpha Card Gateway;
348
368
  * `.message` — response message be response code;
@@ -354,6 +374,16 @@ AlphaCard::AlphaCardError: Invalid Credit Card Number REFID:127145481
354
374
  * `.cvv_response` — CVV response message;
355
375
  * `.avs_response` — AVS response message.
356
376
 
377
+ ## Testing
378
+
379
+ It is recommended to mock Alpha Card gem functionality, but if you want to create a "real" specs, then you can use Alpha Card Services testing account:
380
+
381
+ ```ruby
382
+ AlphaCard::Account.use_demo_credentials!
383
+ ```
384
+
385
+ Or you can pass the next credentials with any request: `{ username: 'demo', password: 'password' }`
386
+
357
387
  ## Contributing
358
388
 
359
389
  You are very welcome to help improve alpha_card if you have suggestions for features that other people can use.