spree-alpha-card 0.0.3 → 0.0.4
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/Gemfile.lock +3 -7
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/app/models/spree/gateway/alpha_card_gateway.rb +29 -3
- data/lib/spree/alpha_card/version.rb +1 -1
- data/spec/models/spree/gateway/alpha_card_gateway_spec.rb +5 -1
- data/spec/spec_helper.rb +0 -1
- data/spree-alpha-card.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 349006a766b1d844c89a4805dfc579bcf703206e
|
4
|
+
data.tar.gz: 6d4591fcd12425afd13e29edd58d99203d7c3c8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff9eeb9d4495ba9355f9133b82cf5360df66bd3405082148b26d4a0f5cd93c0199fd01549a1d9909a00e234f01459bfa53276b5af52a6a04c11effe332712b94
|
7
|
+
data.tar.gz: 93a52368941eaa1a2b768564098fff68cc3111a62f5c600a69ec779c419bf8183e812040c81925ac81dc8f58038a53156e0e59d55304bf4205d56e83d448cc54
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
spree-alpha-card (0.0.
|
4
|
+
spree-alpha-card (0.0.3)
|
5
5
|
alpha_card (~> 0.2.5)
|
6
6
|
spree_core (>= 3.0.0)
|
7
7
|
|
@@ -189,10 +189,6 @@ GEM
|
|
189
189
|
http-cookie (>= 1.0.2, < 2.0)
|
190
190
|
mime-types (>= 1.16, < 3.0)
|
191
191
|
netrc (~> 0.7)
|
192
|
-
rspec-activemodel-mocks (1.0.1)
|
193
|
-
activemodel (>= 3.0)
|
194
|
-
activesupport (>= 3.0)
|
195
|
-
rspec-mocks (>= 2.99, < 4.0)
|
196
192
|
rspec-core (3.2.3)
|
197
193
|
rspec-support (~> 3.2.0)
|
198
194
|
rspec-expectations (3.2.1)
|
@@ -293,7 +289,7 @@ DEPENDENCIES
|
|
293
289
|
factory_girl
|
294
290
|
pg
|
295
291
|
rake
|
296
|
-
rspec-
|
292
|
+
rspec-mocks
|
297
293
|
rspec-rails
|
298
294
|
sass-rails (~> 4.0.2)
|
299
295
|
spree-alpha-card!
|
@@ -302,4 +298,4 @@ DEPENDENCIES
|
|
302
298
|
webmock
|
303
299
|
|
304
300
|
BUNDLED WITH
|
305
|
-
1.10.
|
301
|
+
1.10.6
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# spree-alpha-card
|
2
|
+
|
3
|
+
An Alpha Card Payment Gateway for [Spree](https://spreecommerce.com/).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add the gem to your `Gemfile`:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'spree-alpha-card'
|
12
|
+
```
|
13
|
+
|
14
|
+
Then run `bundle` & (re-)start your Rails application.
|
15
|
+
|
16
|
+
|
17
|
+
## Configuration
|
18
|
+
|
19
|
+
Navigate to your _Spree Administration_ area, then click on _Configurations_, then _Payment Methods_. To add Alpha Card, click on _New Payment Method_, select _Spree::Gateway::AlphaCardGateway_ & give it a display _name_, e.g. "Alpha Card". Click _Create_.
|
20
|
+
|
21
|
+
Now enter your credentials for Alpha Card in the fields _Login_ & _Password_. Click _Update_ & test your new payment method.
|
22
|
+
|
23
|
+
|
24
|
+
## Tests
|
25
|
+
|
26
|
+
To run the test suite, you have to have a Rails app with Spree installed. To do so, run the rake task:
|
27
|
+
|
28
|
+
# only once
|
29
|
+
rake test_app
|
30
|
+
|
31
|
+
Run the test suite with:
|
32
|
+
|
33
|
+
rspec
|
34
|
+
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# Alpha Card Payment Gateway
|
3
3
|
#
|
4
4
|
#
|
5
|
-
# TODO include
|
5
|
+
# TODO include shipping address fields
|
6
6
|
#
|
7
7
|
# cvv: not provided by Spree?
|
8
8
|
#
|
@@ -53,6 +53,7 @@ module Spree
|
|
53
53
|
}
|
54
54
|
add_money! opts, money, options
|
55
55
|
add_credit_card! opts, credit_card
|
56
|
+
add_bill_address! opts
|
56
57
|
|
57
58
|
request opts, 'purchase'
|
58
59
|
end
|
@@ -97,12 +98,34 @@ module Spree
|
|
97
98
|
opts.merge! ccnumber: cc.number, ccexp: exp
|
98
99
|
end
|
99
100
|
|
101
|
+
def add_bill_address! opts
|
102
|
+
order_number, _ = opts[:orderid].split('-')
|
103
|
+
order = Spree::Order.find_by number: order_number
|
104
|
+
|
105
|
+
if order
|
106
|
+
address = order.bill_address
|
107
|
+
opts.merge!(
|
108
|
+
firstname: address.firstname,
|
109
|
+
lastname: address.lastname,
|
110
|
+
address1: address.address1,
|
111
|
+
address2: address.address2,
|
112
|
+
city: address.city,
|
113
|
+
state: address.state.abbr,
|
114
|
+
zip: address.zipcode,
|
115
|
+
country: address.country.iso,
|
116
|
+
phone: address.phone,
|
117
|
+
)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
100
121
|
def request opts, originator
|
101
122
|
begin
|
102
123
|
res = provider.request opts, account
|
103
124
|
ActiveMerchant::Billing::Response.new res.success?, "AlphaCardGateway##{originator}: #{res.text}", res.data, response_params(res.data)
|
104
125
|
rescue ::AlphaCard::AlphaCardError => e
|
105
|
-
|
126
|
+
options = response_params(e.response.data)
|
127
|
+
message = "Alpha Card: #{e.message} #{options[:avs_result].try(:message)}".strip
|
128
|
+
ActiveMerchant::Billing::Response.new false, message, e.response.data, options
|
106
129
|
end
|
107
130
|
end
|
108
131
|
|
@@ -110,10 +133,13 @@ module Spree
|
|
110
133
|
options = {
|
111
134
|
test: test?,
|
112
135
|
authorization: data['authcode'].presence,
|
113
|
-
avs_result: data['avsresponse'].presence,
|
114
136
|
cvv_result: data['cvvresponse'].presence,
|
115
137
|
}
|
116
138
|
|
139
|
+
if data['avsresponse'].present?
|
140
|
+
options[:avs_result] = ActiveMerchant::Billing::AVSResult.new code: data['avsresponse']
|
141
|
+
end
|
142
|
+
|
117
143
|
unless data['response_code'] == '100'
|
118
144
|
options[:error_code] = data['response_code']
|
119
145
|
end
|
@@ -69,6 +69,10 @@ RSpec.describe Spree::Gateway::AlphaCardGateway do
|
|
69
69
|
}
|
70
70
|
end
|
71
71
|
|
72
|
+
before :each do
|
73
|
+
allow(Spree::Order).to receive(:find_by!).and_return nil
|
74
|
+
end
|
75
|
+
|
72
76
|
it 'purchases successfully' do
|
73
77
|
response = VCR.use_cassette("simple purchase") do
|
74
78
|
provider.purchase 256_67, cc, opts
|
@@ -129,7 +133,7 @@ RSpec.describe Spree::Gateway::AlphaCardGateway do
|
|
129
133
|
|
130
134
|
end
|
131
135
|
|
132
|
-
context '#
|
136
|
+
context '#void' do
|
133
137
|
|
134
138
|
it 'fails to void since implementation is missing' do
|
135
139
|
response = provider.void
|
data/spec/spec_helper.rb
CHANGED
data/spree-alpha-card.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'factory_girl'
|
24
24
|
spec.add_development_dependency 'pg'
|
25
25
|
spec.add_development_dependency 'rake'
|
26
|
-
spec.add_development_dependency 'rspec-
|
26
|
+
spec.add_development_dependency 'rspec-mocks'
|
27
27
|
spec.add_development_dependency 'rspec-rails'
|
28
28
|
spec.add_development_dependency 'sass-rails', '~> 4.0.2'
|
29
29
|
spec.add_development_dependency 'sqlite3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree-alpha-card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Kluge
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: rspec-
|
70
|
+
name: rspec-mocks
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- ".gitignore"
|
203
203
|
- Gemfile
|
204
204
|
- Gemfile.lock
|
205
|
+
- README.md
|
205
206
|
- Rakefile
|
206
207
|
- app/models/spree/gateway/alpha_card_gateway.rb
|
207
208
|
- lib/spree-alpha-card.rb
|
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
236
|
version: '0'
|
236
237
|
requirements: []
|
237
238
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.4.5
|
239
|
+
rubygems_version: 2.4.5.1
|
239
240
|
signing_key:
|
240
241
|
specification_version: 4
|
241
242
|
summary: Alpha Card Payment Gateway for Spree
|