alpha_card 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.travis.yml +1 -5
- data/CHANGELOG.md +54 -0
- data/Gemfile.lock +25 -37
- data/LICENSE +1 -1
- data/README.md +207 -67
- data/ROADMAP.md +12 -0
- data/alpha_card.gemspec +5 -4
- data/lib/alpha_card.rb +11 -6
- data/lib/alpha_card/alpha_card_object.rb +59 -3
- data/lib/alpha_card/alpha_card_response.rb +99 -16
- data/lib/alpha_card/data/avs_responses.yml +20 -0
- data/lib/alpha_card/data/credit_card_codes.yml +1 -1
- data/lib/alpha_card/data/cvv_responses.yml +5 -0
- data/lib/alpha_card/data/response_messages.yml +33 -0
- data/lib/alpha_card/errors/alpha_card_error.rb +1 -1
- data/lib/alpha_card/errors/invalid_object_error.rb +8 -0
- data/lib/alpha_card/objects/account.rb +1 -1
- data/lib/alpha_card/objects/billing.rb +15 -4
- data/lib/alpha_card/objects/capture.rb +51 -0
- data/lib/alpha_card/objects/order.rb +41 -4
- data/lib/alpha_card/objects/refund.rb +20 -0
- data/lib/alpha_card/objects/sale.rb +32 -22
- data/lib/alpha_card/objects/shipping.rb +15 -4
- data/lib/alpha_card/objects/update.rb +54 -0
- data/lib/alpha_card/objects/void.rb +45 -0
- data/lib/alpha_card/version.rb +18 -2
- data/spec/alpha_card/objects/account_spec.rb +20 -0
- data/spec/alpha_card/objects/capture_spec.rb +51 -0
- data/spec/alpha_card/objects/deprecated_methods_spec.rb +32 -0
- data/spec/alpha_card/objects/refund_spec.rb +35 -0
- data/spec/alpha_card/objects/sale_spec.rb +143 -0
- data/spec/alpha_card/objects/update_spec.rb +36 -0
- data/spec/alpha_card/objects/void_spec.rb +48 -0
- data/spec/alpha_card/response_spec.rb +111 -0
- data/spec/spec_helper.rb +7 -2
- metadata +44 -9
- data/spec/alpha_card/alpha_card_account_spec.rb +0 -18
- data/spec/alpha_card/alpha_card_response_spec.rb +0 -63
- data/spec/alpha_card/alpha_card_spec.rb +0 -123
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e5ac24025977d5cd2c3406cba14ebde613b4f7b
|
4
|
+
data.tar.gz: 7696ce4ea24336d3214c056e612a7e5a068940fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3666ded11769f172c69f8dee353a22a762daa403e850a46fc82174b968fee31339a6b101fd9cf7a0885a4b0c4c667aee8ad748e58e7b6558e9d848b60d823a8a
|
7
|
+
data.tar.gz: 453305dfd596b13e12ce9ea3064cd188806ba429bf9d5d51c9573cf022d646e592c1ebeaf18fce331dd5cd19f7b8330f8a79f6dd16885aa914e3a5c3d8bf1485
|
data/.travis.yml
CHANGED
@@ -3,15 +3,11 @@ before_install: gem install bundler
|
|
3
3
|
bundler_args: --without yard guard benchmarks
|
4
4
|
script: "rake spec"
|
5
5
|
rvm:
|
6
|
-
- 1.9.3
|
7
6
|
- 2.0.0
|
8
|
-
- 2.1.0
|
9
|
-
- 2.1.1
|
10
|
-
- 2.1.2
|
11
7
|
- 2.1.5
|
12
8
|
- 2.2.4
|
13
9
|
- 2.3.0
|
14
|
-
- jruby-
|
10
|
+
- jruby-9.0.0.0
|
15
11
|
- ruby-head
|
16
12
|
matrix:
|
17
13
|
allow_failures:
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# AlphaCard gem Changelog
|
2
|
+
|
3
|
+
Reverse Chronological Order:
|
4
|
+
|
5
|
+
## `0.3.0` (2016-09-22)
|
6
|
+
|
7
|
+
https://github.com/nbulaj/alpha_card/compare/0.2.6...0.3.0
|
8
|
+
|
9
|
+
* Dropped support of Ruby 1.9.3
|
10
|
+
* New AlphaCard transactions: `Void`, `Refund`, `Capture`, `Update`
|
11
|
+
* New AlphaCard transactions variables
|
12
|
+
* New AlphaCard transactions variables naming (**old is deprecated**)
|
13
|
+
* Improved transactions `.create` method to return response (not only the success indicator)
|
14
|
+
* Sale transaction request params fix
|
15
|
+
* Code refactoring
|
16
|
+
* Specs improvements
|
17
|
+
* Documentation improvements
|
18
|
+
|
19
|
+
## `0.2.6` (2016-03-24)
|
20
|
+
|
21
|
+
https://github.com/nbulaj/alpha_card/compare/0.2.4...0.2.6
|
22
|
+
|
23
|
+
* Documentation improvements
|
24
|
+
* `rest-client` removed from gem dependencies
|
25
|
+
* Code style fixes
|
26
|
+
* Code refactoring
|
27
|
+
|
28
|
+
## `0.2.4` (2015-07-24)
|
29
|
+
|
30
|
+
* Code style fixes
|
31
|
+
* New TravisCI tests strategies
|
32
|
+
* Dependencies update
|
33
|
+
|
34
|
+
## `0.2.2` (2015-07-11)
|
35
|
+
|
36
|
+
* New transaction variables
|
37
|
+
* `Shipping` object request params fixed
|
38
|
+
|
39
|
+
## `0.2.0` (2014-07-09)
|
40
|
+
|
41
|
+
* `AlphaCardError`
|
42
|
+
* Better errors handling
|
43
|
+
|
44
|
+
## `0.1.9` (2014-07-02)
|
45
|
+
|
46
|
+
* Errors handling
|
47
|
+
* COde refactoring
|
48
|
+
* Specs
|
49
|
+
* Documentation improvements
|
50
|
+
* Fixes
|
51
|
+
|
52
|
+
## `0.1.0` (2014-06-25)
|
53
|
+
|
54
|
+
* First stable release
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
alpha_card (0.
|
4
|
+
alpha_card (0.3.0)
|
5
|
+
rack (~> 1.2, >= 1.2)
|
5
6
|
virtus (~> 1.0, >= 1.0.5)
|
6
7
|
|
7
8
|
GEM
|
@@ -13,59 +14,45 @@ GEM
|
|
13
14
|
thread_safe (~> 0.3, >= 0.3.1)
|
14
15
|
coercible (1.0.0)
|
15
16
|
descendants_tracker (~> 0.0.1)
|
16
|
-
coveralls (0.8.
|
17
|
-
json (
|
18
|
-
|
19
|
-
simplecov (~> 0.11.0)
|
17
|
+
coveralls (0.8.15)
|
18
|
+
json (>= 1.8, < 3)
|
19
|
+
simplecov (~> 0.12.0)
|
20
20
|
term-ansicolor (~> 1.3)
|
21
21
|
thor (~> 0.19.1)
|
22
|
-
tins (
|
22
|
+
tins (>= 1.6.0, < 2)
|
23
23
|
descendants_tracker (0.0.4)
|
24
24
|
thread_safe (~> 0.3, >= 0.3.1)
|
25
25
|
diff-lcs (1.2.5)
|
26
26
|
docile (1.1.5)
|
27
|
-
domain_name (0.5.25)
|
28
|
-
unf (>= 0.0.5, < 1.0.0)
|
29
27
|
equalizer (0.0.11)
|
30
|
-
|
31
|
-
|
32
|
-
ice_nine (0.11.1)
|
33
|
-
json (1.8.3)
|
34
|
-
mime-types (2.99)
|
35
|
-
netrc (0.11.0)
|
28
|
+
ice_nine (0.11.2)
|
29
|
+
json (2.0.2)
|
36
30
|
rack (1.6.4)
|
37
31
|
rack-test (0.6.3)
|
38
32
|
rack (>= 1.0)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
rspec (3.
|
44
|
-
rspec-
|
45
|
-
|
46
|
-
rspec-mocks (~> 3.4.0)
|
47
|
-
rspec-core (3.4.1)
|
48
|
-
rspec-support (~> 3.4.0)
|
49
|
-
rspec-expectations (3.4.0)
|
33
|
+
rspec (3.5.0)
|
34
|
+
rspec-core (~> 3.5.0)
|
35
|
+
rspec-expectations (~> 3.5.0)
|
36
|
+
rspec-mocks (~> 3.5.0)
|
37
|
+
rspec-core (3.5.3)
|
38
|
+
rspec-support (~> 3.5.0)
|
39
|
+
rspec-expectations (3.5.0)
|
50
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-mocks (3.
|
41
|
+
rspec-support (~> 3.5.0)
|
42
|
+
rspec-mocks (3.5.0)
|
53
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
54
|
-
rspec-support (~> 3.
|
55
|
-
rspec-support (3.
|
56
|
-
simplecov (0.
|
44
|
+
rspec-support (~> 3.5.0)
|
45
|
+
rspec-support (3.5.0)
|
46
|
+
simplecov (0.12.0)
|
57
47
|
docile (~> 1.1.0)
|
58
|
-
json (
|
48
|
+
json (>= 1.8, < 3)
|
59
49
|
simplecov-html (~> 0.10.0)
|
60
50
|
simplecov-html (0.10.0)
|
61
51
|
term-ansicolor (1.3.2)
|
62
52
|
tins (~> 1.0)
|
63
53
|
thor (0.19.1)
|
64
54
|
thread_safe (0.3.5)
|
65
|
-
tins (1.
|
66
|
-
unf (0.1.4)
|
67
|
-
unf_ext
|
68
|
-
unf_ext (0.0.7.1)
|
55
|
+
tins (1.12.0)
|
69
56
|
virtus (1.0.5)
|
70
57
|
axiom-types (~> 0.1)
|
71
58
|
coercible (~> 1.0)
|
@@ -74,13 +61,14 @@ GEM
|
|
74
61
|
|
75
62
|
PLATFORMS
|
76
63
|
ruby
|
64
|
+
x86-mingw32
|
77
65
|
|
78
66
|
DEPENDENCIES
|
79
67
|
alpha_card!
|
80
68
|
coveralls
|
81
69
|
rack-test
|
82
|
-
rspec (~> 3)
|
70
|
+
rspec (~> 3.5)
|
83
71
|
virtus
|
84
72
|
|
85
73
|
BUNDLED WITH
|
86
|
-
1.
|
74
|
+
1.12.5
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
# Ruby lib for creating payments with Alpha Card Services
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/alpha_card.svg)](http://badge.fury.io/rb/alpha_card)
|
3
|
+
[![Build Status](https://travis-ci.org/nbulaj/alpha_card.svg?branch=master)](https://travis-ci.org/nbulaj/alpha_card)
|
3
4
|
[![Dependency Status](https://gemnasium.com/nbulaj/alpha_card.svg)](https://gemnasium.com/nbulaj/alpha_card)
|
4
5
|
[![Code Climate](https://codeclimate.com/github/nbulaj/alpha_card/badges/gpa.svg)](https://codeclimate.com/github/nbulaj/alpha_card)
|
5
6
|
[![Coverage Status](https://coveralls.io/repos/nbulaj/alpha_card/badge.svg)](https://coveralls.io/r/nbulaj/alpha_card)
|
6
|
-
[![Build Status](https://travis-ci.org/nbulaj/alpha_card.svg?branch=master)](https://travis-ci.org/nbulaj/alpha_card)
|
7
7
|
[![Inline docs](http://inch-ci.org/github/nbulaj/alpha_card.png?branch=master)](http://inch-ci.org/github/nbulaj/alpha_card)
|
8
8
|
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](#license)
|
9
|
-
[![Gem](https://img.shields.io/gem/dt/alpha_card.svg)]()
|
10
9
|
|
11
10
|
This gem can help your Ruby or Ruby on Rails application to integrate with Alpha Card Service, Inc.
|
12
11
|
|
@@ -16,13 +15,12 @@ http://www.alphacardservices.com/
|
|
16
15
|
Payment Gateway Integration Portal:
|
17
16
|
https://secure.alphacardgateway.com/merchants/resources/integration/integration_portal.php
|
18
17
|
|
19
|
-
|
20
18
|
## Installation
|
21
19
|
|
22
20
|
If using bundler, first add 'alpha_card' to your Gemfile:
|
23
21
|
|
24
22
|
```ruby
|
25
|
-
gem
|
23
|
+
gem 'alpha_card', '~> 0.3'
|
26
24
|
```
|
27
25
|
|
28
26
|
And run:
|
@@ -39,30 +37,33 @@ gem install alpha_card
|
|
39
37
|
|
40
38
|
Dependencies required:
|
41
39
|
|
42
|
-
*
|
40
|
+
* ruby >= 2.0.0;
|
43
41
|
|
42
|
+
## Alpha Card Objects & Transactions
|
44
43
|
|
45
|
-
|
44
|
+
Alpha Card operates with next objects:
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
* Account (represent your Alpha Card credentials)
|
50
|
-
* Order
|
46
|
+
* Account
|
47
|
+
* Order
|
51
48
|
- Billing
|
52
49
|
- Shipping
|
53
|
-
*
|
50
|
+
* Sale
|
51
|
+
* Refund
|
52
|
+
* Void
|
53
|
+
* Capture
|
54
|
+
* Update
|
54
55
|
|
55
56
|
Let us consider each of them.
|
56
57
|
|
57
58
|
### Account
|
58
59
|
|
59
60
|
Account represents credentials data to access Alpha Card Gateway.
|
60
|
-
All
|
61
|
+
All transactions (`sale`, `refund`, etc) will be created for the specified account.
|
61
62
|
|
62
63
|
_Required fields_:
|
63
64
|
|
64
|
-
*
|
65
|
-
*
|
65
|
+
* username : `String`
|
66
|
+
* password : `String`
|
66
67
|
|
67
68
|
_Constructor_:
|
68
69
|
|
@@ -74,15 +75,15 @@ AlphaCard::Account.new(username, password)
|
|
74
75
|
|
75
76
|
Order represents itself.
|
76
77
|
|
77
|
-
|
78
|
+
_Optional fields_:
|
78
79
|
|
79
|
-
*
|
80
|
-
*
|
81
|
-
*
|
82
|
-
*
|
83
|
-
*
|
84
|
-
*
|
85
|
-
*
|
80
|
+
* id : `String`
|
81
|
+
* description : `String`
|
82
|
+
* po_number : `String`
|
83
|
+
* tax : `String`
|
84
|
+
* ip_address : `String` (format: `xxx.xxx.xxx.xxx`)
|
85
|
+
* billing : `AlphaCard::Billing`
|
86
|
+
* shipping : `AlphaCard::Shipping`
|
86
87
|
|
87
88
|
_Constructor_:
|
88
89
|
|
@@ -94,21 +95,21 @@ AlphaCard::Order.new(field_name: value, ...)
|
|
94
95
|
|
95
96
|
Specify Billing information for Order.
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
*
|
100
|
-
*
|
101
|
-
*
|
102
|
-
*
|
103
|
-
*
|
104
|
-
*
|
105
|
-
*
|
106
|
-
*
|
107
|
-
*
|
108
|
-
*
|
109
|
-
*
|
110
|
-
*
|
111
|
-
*
|
98
|
+
_Optional fields_:
|
99
|
+
|
100
|
+
* first_name : `String`
|
101
|
+
* last_name : `String`
|
102
|
+
* email : `String`
|
103
|
+
* fax : `String`
|
104
|
+
* phone : `String`
|
105
|
+
* company : `String`
|
106
|
+
* address_1 : `String`
|
107
|
+
* address_2 : `String`
|
108
|
+
* city : `String`
|
109
|
+
* state : `String` (format: `CC`)
|
110
|
+
* zip : `String`
|
111
|
+
* country : `String` (format: `CC`. Country codes are as shown in [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166))
|
112
|
+
* website : `String`
|
112
113
|
|
113
114
|
_Constructor_:
|
114
115
|
|
@@ -120,18 +121,18 @@ AlphaCard::Billing.new(field_name: value, ...)
|
|
120
121
|
|
121
122
|
Specify Shipping information for Order.
|
122
123
|
|
123
|
-
|
124
|
+
_Optional fields_:
|
124
125
|
|
125
|
-
*
|
126
|
-
*
|
127
|
-
*
|
128
|
-
*
|
129
|
-
*
|
130
|
-
*
|
131
|
-
*
|
132
|
-
*
|
133
|
-
*
|
134
|
-
*
|
126
|
+
* first_name : `String`
|
127
|
+
* last_name : `String`
|
128
|
+
* company : `String`
|
129
|
+
* address_1 : `String`
|
130
|
+
* address_2 : `String`
|
131
|
+
* city : `String`
|
132
|
+
* state : `String` (format: `CC`)
|
133
|
+
* zip_code : `String`
|
134
|
+
* country : `String` (format: `CC`. Country codes are as shown in [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166))
|
135
|
+
* email : `String`
|
135
136
|
|
136
137
|
_Constructor_:
|
137
138
|
|
@@ -145,12 +146,14 @@ Sale is the main object of the Alpha Card Services. It processes fees associated
|
|
145
146
|
|
146
147
|
_Required fields_:
|
147
148
|
|
148
|
-
*
|
149
|
-
*
|
150
|
-
*
|
149
|
+
* card_expiration_date : `String` (format: `MMYY`)
|
150
|
+
* card_number : `String`
|
151
|
+
* amount : `String` (format: `x.xx`)
|
151
152
|
|
152
|
-
|
153
|
-
*
|
153
|
+
_Optional fields_:
|
154
|
+
* cvv : `String`
|
155
|
+
* payment : `String` (default: `'creditcard'`, values: `'creditcard'` or `'check'`)
|
156
|
+
* customer_receipt : `String` (values `'true'` or `'false'`)
|
154
157
|
|
155
158
|
_Constructor_:
|
156
159
|
|
@@ -161,16 +164,135 @@ AlphaCard::Sale.new(field_name: value, ...)
|
|
161
164
|
To create the payment you must call *create(_alpha_card_order_, _alpha_card_account_)* method:
|
162
165
|
|
163
166
|
```ruby
|
164
|
-
...
|
167
|
+
# ...
|
165
168
|
sale = AlphaCard::Sale.new(amount: 10)
|
166
|
-
sale.create(order, account)
|
169
|
+
success, alpha_card_response = sale.create(order, account)
|
170
|
+
|
171
|
+
# => [true, #<AlphaCard::AlphaCardResponse:0x1a0fda ...>]
|
167
172
|
```
|
168
173
|
|
169
174
|
This method returns _true_ if sale was created successfully and raise an `AlphaCardError` exception if some of the fields is invalid.
|
170
175
|
|
176
|
+
### Refund
|
177
|
+
|
178
|
+
Represents refund transaction.
|
179
|
+
|
180
|
+
_Required fields_:
|
181
|
+
|
182
|
+
* transaction_id : `String`
|
183
|
+
|
184
|
+
_Optional fields_:
|
185
|
+
|
186
|
+
* amount : `String` (format: `x.xx`)
|
187
|
+
|
188
|
+
_Constructor_:
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
AlphaCard::Refund.new(field_name: value, ...)
|
192
|
+
```
|
193
|
+
|
194
|
+
To create the refund transaction you must call *create(_alpha_card_account_)* method:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
# ...
|
198
|
+
refund = AlphaCard::Refund.new(transaction_id: '12312312', amount: 10)
|
199
|
+
refund.create(account)
|
200
|
+
```
|
201
|
+
|
202
|
+
### Void
|
203
|
+
|
204
|
+
Represents void transaction.
|
205
|
+
|
206
|
+
_Required fields_:
|
207
|
+
|
208
|
+
* transaction_id : `String`
|
209
|
+
|
210
|
+
_Constructor_:
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
AlphaCard::Void.new(field_name: value, ...)
|
214
|
+
```
|
215
|
+
|
216
|
+
To create the void transaction you must call *create(_alpha_card_account_)* method:
|
217
|
+
|
218
|
+
```ruby
|
219
|
+
# ...
|
220
|
+
void = AlphaCard::Void.new(transaction_id: '12312312')
|
221
|
+
void.create(account)
|
222
|
+
```
|
223
|
+
|
224
|
+
### Capture
|
225
|
+
|
226
|
+
Represents capture transaction.
|
227
|
+
|
228
|
+
_Required fields_:
|
229
|
+
|
230
|
+
* transaction_id : `String`
|
231
|
+
* amount : `String` (format: `x.xx`)
|
232
|
+
|
233
|
+
_Constructor_:
|
234
|
+
|
235
|
+
```ruby
|
236
|
+
AlphaCard::Capture.new(field_name: value, ...)
|
237
|
+
```
|
238
|
+
|
239
|
+
To create the capture transaction you must call *create(_alpha_card_account_)* method:
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
# ...
|
243
|
+
capture = AlphaCard::Capture.new(transaction_id: '12312312', amount: '5.05')
|
244
|
+
capture.create(account)
|
245
|
+
```
|
246
|
+
|
247
|
+
### Update
|
248
|
+
|
249
|
+
Represents update transaction.
|
250
|
+
|
251
|
+
_Required fields_:
|
252
|
+
|
253
|
+
* transaction_id : `String`
|
254
|
+
|
255
|
+
_Optional fields_:
|
256
|
+
* shipping: `String`
|
257
|
+
* shipping_postal: `String`
|
258
|
+
* ship_from_postal: `String`
|
259
|
+
* shipping_country: `String`
|
260
|
+
* shipping_carrier: `String` (values: `'ups'`, `'fedex'`, `'dhl'` or `'usps'`)
|
261
|
+
* shipping_date: `String` (format: `YYYYMMDD`)
|
262
|
+
* order_description: `String`
|
263
|
+
* order_date: `String`
|
264
|
+
* customer_receipt: `String` (values: `'true'` or `'false'`)
|
265
|
+
* po_number: `String`
|
266
|
+
* summary_commodity_code: `String`
|
267
|
+
* duty_amount: `String` (format: `x.xx`)
|
268
|
+
* discount_amount: `String` (format: `x.xx`)
|
269
|
+
* tax: `String` (format: `x.xx`)
|
270
|
+
* national_tax_amount: `String` (format: `x.xx`)
|
271
|
+
* alternate_tax_amount: `String` (format: `x.xx`)
|
272
|
+
* alternate_tax_id: `String`
|
273
|
+
* vat_tax_amount: `String`
|
274
|
+
* vat_tax_rate: `String`
|
275
|
+
* vat_invoice_reference_number: `String`
|
276
|
+
* customer_vat_registration: `String`
|
277
|
+
* merchant_vat_registration: `String`
|
278
|
+
|
279
|
+
_Constructor_:
|
280
|
+
|
281
|
+
```ruby
|
282
|
+
AlphaCard::Update.new(field_name: value, ...)
|
283
|
+
```
|
284
|
+
|
285
|
+
To create update transaction you must call *create(_alpha_card_account_)* method:
|
286
|
+
|
287
|
+
```ruby
|
288
|
+
# ...
|
289
|
+
update = AlphaCard::Update.new(tax: '10.02', shipping_carrier: 'ups', transaction_id: '66928')
|
290
|
+
update.create(account)
|
291
|
+
```
|
292
|
+
|
171
293
|
## Example of usage
|
172
294
|
|
173
|
-
Create AlphaCard sale:
|
295
|
+
Create AlphaCard sale (pay for the order):
|
174
296
|
|
175
297
|
```ruby
|
176
298
|
require 'alpha_card'
|
@@ -178,33 +300,37 @@ require 'alpha_card'
|
|
178
300
|
def create_payment
|
179
301
|
account = AlphaCard::Account.new('demo', 'password')
|
180
302
|
|
181
|
-
billing = AlphaCard::Billing.new(
|
182
|
-
shipping = AlphaCard::Shipping.new(
|
303
|
+
billing = AlphaCard::Billing.new(email: 'test@example.com', phone: '+801311313111')
|
304
|
+
shipping = AlphaCard::Shipping.new(address_1: '33 N str', city: 'New York', state: 'NY', zip_code: '132')
|
183
305
|
|
184
|
-
order = AlphaCard::Order.new(
|
306
|
+
order = AlphaCard::Order.new(id: 1, description: 'Test order', billing: billing, shipping: shipping)
|
185
307
|
|
186
308
|
# Format of amount: "XX.XX" ("%.2f" % Float)
|
187
|
-
sale = AlphaCard::Sale.new(
|
188
|
-
sale.create(order, account)
|
309
|
+
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
|
189
313
|
rescue AlphaCard::AlphaCardError => e
|
190
|
-
puts e.message
|
314
|
+
puts "Error message: #{e.response.message}"
|
315
|
+
puts "CVV response: #{e.response.cvv_response}"
|
316
|
+
puts "AVS response: #{e.response.avs_response}"
|
191
317
|
false
|
192
318
|
end
|
193
319
|
```
|
194
320
|
|
195
321
|
`Billing` and `Shipping` is an _optional_ parameters and can be not specified.
|
196
322
|
|
197
|
-
_Note_: take a look at the `amount` of the Order. It's format must be 'xx.xx'. All information about variables formats
|
323
|
+
_Note_: take a look at the `amount` of the Order. It's format must be 'xx.xx'. All the information about variables formats
|
198
324
|
can be found on _Alpha Card Payment Gateway Integration Portal_ -> _Direct Post API_ -> _Documentation_ -> _Transaction Variables_
|
199
325
|
|
200
326
|
Naming convention of attributes (such as "ccexp" or "orderid") was saved for compatibility with AlphaCard API.
|
201
327
|
|
202
328
|
To raise some exceptions do the next:
|
203
329
|
|
204
|
-
*
|
205
|
-
*
|
206
|
-
*
|
207
|
-
*
|
330
|
+
* to cause a declined message, pass an amount less than 1.00;
|
331
|
+
* to trigger a fatal error message, pass an invalid card number;
|
332
|
+
* to simulate an AVS match, pass 888 in the address1 field, 77777 for zip;
|
333
|
+
* to simulate a CVV match, pass 999 in the cvv field.
|
208
334
|
|
209
335
|
Example of exception:
|
210
336
|
|
@@ -214,6 +340,20 @@ Example of exception:
|
|
214
340
|
AlphaCard::AlphaCardError: Invalid Credit Card Number REFID:127145481
|
215
341
|
```
|
216
342
|
|
343
|
+
## AlphaCard Response
|
344
|
+
|
345
|
+
`AlphaCardResponse` contains all the necessary information about Alpha Card Gateway response. You can use the following API:
|
346
|
+
|
347
|
+
* `.text` — textual response of the Alpha Card Gateway;
|
348
|
+
* `.message` — response message be response code;
|
349
|
+
* `.transaction_id` — payment gateway transaction ID;
|
350
|
+
* `.order_id` — original order ID passed in the transaction request;
|
351
|
+
* `.code` — numeric mapping of processor responses;
|
352
|
+
* `.auth_code` — transaction authorization code;
|
353
|
+
* `.success?`, `.error?`, `.declined?` — state of the request;
|
354
|
+
* `.cvv_response` — CVV response message;
|
355
|
+
* `.avs_response` — AVS response message.
|
356
|
+
|
217
357
|
## Contributing
|
218
358
|
|
219
359
|
You are very welcome to help improve alpha_card if you have suggestions for features that other people can use.
|