alpha_card 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/README.md +14 -4
- data/alpha_card.gemspec +5 -2
- data/lib/alpha_card.rb +12 -0
- data/lib/alpha_card/billing.rb +1 -0
- data/lib/alpha_card/errors/alpha_card_error.rb +8 -2
- data/lib/alpha_card/order.rb +1 -0
- data/lib/alpha_card/shipping.rb +4 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69ecf71ff5367ce0a63a519ade5ba21a8cdce81c
|
4
|
+
data.tar.gz: 582d9831fa7344b5c52ca4b1c93b30044c27ff24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9fd3179c4edad7500d6d280a56ab61fcd125e39e1469618271d951b94a53a837a1b4f5cf101b4a4793c170c974fb208b86bd5800ee1b6f848977df3f85bf3da
|
7
|
+
data.tar.gz: 91ce299981bb899e15bab63279ae58a7ef3575a3b525160d790328d406a899af0c9601df3c2fc2484c5bfd0403ae9cf55fbecb8c69ba52e0ad2562fa752bdf39
|
data/README.md
CHANGED
@@ -41,7 +41,8 @@ Dependencies required:
|
|
41
41
|
* rest_client;
|
42
42
|
* virtus (for nice OOP objects of AlphaCard).
|
43
43
|
|
44
|
-
|
44
|
+
|
45
|
+
## Alpha Card Objects
|
45
46
|
|
46
47
|
Alpha Card sales operates with next 5 objects:
|
47
48
|
|
@@ -51,9 +52,11 @@ Alpha Card sales operates with next 5 objects:
|
|
51
52
|
- Shipping
|
52
53
|
* Sale
|
53
54
|
|
55
|
+
Let us consider each of them.
|
56
|
+
|
54
57
|
### Account
|
55
58
|
|
56
|
-
Account represents credentials data to access Alpha Card
|
59
|
+
Account represents credentials data to access Alpha Card Gateway.
|
57
60
|
All sales will be created for the specified account.
|
58
61
|
|
59
62
|
_Required fields_:
|
@@ -77,6 +80,7 @@ _Unnecessary fields_:
|
|
77
80
|
* orderdescription : String
|
78
81
|
* ponumber : String
|
79
82
|
* tax : String
|
83
|
+
* ipaddress : String
|
80
84
|
* billing : AlphaCard::Billing
|
81
85
|
* shipping : AlphaCard::Shipping
|
82
86
|
|
@@ -95,6 +99,7 @@ _Unnecessary fields_:
|
|
95
99
|
* firstname : String
|
96
100
|
* lastname : String
|
97
101
|
* email : String
|
102
|
+
* fax : String
|
98
103
|
* phone : String
|
99
104
|
* company : String
|
100
105
|
* address1 : String
|
@@ -117,11 +122,15 @@ Specify Shipping information for Order.
|
|
117
122
|
|
118
123
|
_Unnecessary fields_:
|
119
124
|
|
125
|
+
* firstname : String
|
126
|
+
* lastname : String
|
127
|
+
* company : String
|
120
128
|
* address_1 : String
|
121
129
|
* address_2 : String
|
122
130
|
* city : String
|
123
131
|
* state : String
|
124
132
|
* zip_code : String
|
133
|
+
* country : String
|
125
134
|
* email : String
|
126
135
|
|
127
136
|
_Constructor_:
|
@@ -176,7 +185,8 @@ def create_payment
|
|
176
185
|
order.billing = billing
|
177
186
|
order.shipping = shipping
|
178
187
|
|
179
|
-
|
188
|
+
# Format of amount: "XX.XX" ("%.2f" % Float)
|
189
|
+
sale = AlphaCard::Sale.new({ccexp: '0117', ccnumber: '4111111111111111', amount: "1.50", cvv: '123'})
|
180
190
|
sale.create(order, account)
|
181
191
|
rescue AlphaCard::AlphaCardError => e
|
182
192
|
puts e.message
|
@@ -184,7 +194,7 @@ rescue AlphaCard::AlphaCardError => e
|
|
184
194
|
end
|
185
195
|
```
|
186
196
|
|
187
|
-
`Billing` and `
|
197
|
+
`Billing` and `Shipping` is an _optional_ parameters and can be not specified.
|
188
198
|
|
189
199
|
_Note_: take a look at the `amount` of the Order. It's format must be 'xx.xx'. All information about variables formats
|
190
200
|
can be found on _Alpha Card Payment Gateway Integration Portal_ -> _Direct Post API_ -> _Documentation_ -> _Transaction Variables_
|
data/alpha_card.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = 'alpha_card'
|
3
|
-
gem.version = '0.2.
|
4
|
-
gem.date = '2014-07-
|
3
|
+
gem.version = '0.2.1'
|
4
|
+
gem.date = '2014-07-11'
|
5
5
|
gem.summary = 'Alpha Card Services DirectPost API for Ruby'
|
6
6
|
gem.description = 'Gem for creating sales with Alpha Card Services DirectPost API'
|
7
7
|
gem.authors = ['Nikita Bulaj']
|
@@ -12,5 +12,8 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.license = 'MIT'
|
13
13
|
gem.required_ruby_version = '>= 1.9.3'
|
14
14
|
|
15
|
+
gem.add_dependency 'virtus', '~> 1.0'
|
16
|
+
gem.add_dependency 'rest_client', '~> 1.7'
|
17
|
+
|
15
18
|
gem.add_development_dependency "rspec", '~> 3'
|
16
19
|
end
|
data/lib/alpha_card.rb
CHANGED
@@ -65,6 +65,18 @@ module AlphaCard
|
|
65
65
|
# "responsetext"=>"SUCCESS", "authcode"=>"123", "transactionid"=>"123",
|
66
66
|
# "avsresponse"=>"", "cvvresponse"=>"N", "orderid"=>"", "type"=>"",
|
67
67
|
# "response_code"=>"100"}>
|
68
|
+
#
|
69
|
+
# account = AlphaCard::Account.new('demo', 'password')
|
70
|
+
# response = AlphaCard.request(
|
71
|
+
# {
|
72
|
+
# cexp: '0720',
|
73
|
+
# ccnumber: '123',
|
74
|
+
# amount: '10.00'
|
75
|
+
# },
|
76
|
+
# account
|
77
|
+
# )
|
78
|
+
#
|
79
|
+
# #=> AlphaCard::AlphaCardError: AlphaCard::AlphaCardError
|
68
80
|
def self.request(params = {}, account)
|
69
81
|
unless account.filled?
|
70
82
|
raise AlphaCardError.new('You must set credentials to create the sale!')
|
data/lib/alpha_card/billing.rb
CHANGED
@@ -2,14 +2,20 @@ module AlphaCard
|
|
2
2
|
##
|
3
3
|
# Common class for Alpha Card Gateway errors and exceptions.
|
4
4
|
class AlphaCardError < StandardError
|
5
|
+
# Alpha Card Gateway response.
|
6
|
+
# @attr_reader [AlphaCard::AlphaCardResponse] response
|
5
7
|
attr_reader :response
|
8
|
+
# Error message.
|
9
|
+
# @attr_reader [String] message
|
6
10
|
attr_reader :message
|
7
11
|
|
8
12
|
##
|
9
13
|
# <code>AlphaCard::AlphaCardError</code> constructor.
|
10
14
|
#
|
11
|
-
# @param [String]
|
12
|
-
#
|
15
|
+
# @param [String] response
|
16
|
+
# Error message
|
17
|
+
# @param [AlphaCard::AlphaCardResponse] response
|
18
|
+
# AlphaCard Gateway response
|
13
19
|
#
|
14
20
|
# @example
|
15
21
|
# AlphaCard::AlphaCardError.new
|
data/lib/alpha_card/order.rb
CHANGED
data/lib/alpha_card/shipping.rb
CHANGED
@@ -3,11 +3,15 @@ module AlphaCard
|
|
3
3
|
# Implementation of Alpha Card Services order shipping information.
|
4
4
|
# Contains all the shipping information (address, city, zip, etc).
|
5
5
|
class Shipping < AlphaCardObject
|
6
|
+
attribute :firstname, String
|
7
|
+
attribute :lastname, String
|
8
|
+
attribute :company, String
|
6
9
|
attribute :address_1, String
|
7
10
|
attribute :address_2, String
|
8
11
|
attribute :city, String
|
9
12
|
attribute :state, String
|
10
13
|
attribute :zip_code, String
|
14
|
+
attribute :country, String
|
11
15
|
attribute :email, String
|
12
16
|
end
|
13
17
|
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alpha_card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Bulaj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: virtus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest_client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: rspec
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|