spree_usa_epay 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,187 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ spree_usa_epay (1.0.0)
5
+ savon
6
+ spree_core (>= 1.0.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ actionmailer (3.1.3)
12
+ actionpack (= 3.1.3)
13
+ mail (~> 2.3.0)
14
+ actionpack (3.1.3)
15
+ activemodel (= 3.1.3)
16
+ activesupport (= 3.1.3)
17
+ builder (~> 3.0.0)
18
+ erubis (~> 2.7.0)
19
+ i18n (~> 0.6)
20
+ rack (~> 1.3.5)
21
+ rack-cache (~> 1.1)
22
+ rack-mount (~> 0.8.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.0.3)
25
+ active_utils (1.0.3)
26
+ activesupport (>= 2.3.11)
27
+ i18n
28
+ activemerchant (1.20.1)
29
+ active_utils (>= 1.0.1)
30
+ activesupport (>= 2.3.11)
31
+ braintree (>= 2.0.0)
32
+ builder (>= 2.0.0)
33
+ i18n
34
+ json (>= 1.5.1)
35
+ money (<= 3.7.1)
36
+ activemodel (3.1.3)
37
+ activesupport (= 3.1.3)
38
+ builder (~> 3.0.0)
39
+ i18n (~> 0.6)
40
+ activerecord (3.1.3)
41
+ activemodel (= 3.1.3)
42
+ activesupport (= 3.1.3)
43
+ arel (~> 2.2.1)
44
+ tzinfo (~> 0.3.29)
45
+ activeresource (3.1.3)
46
+ activemodel (= 3.1.3)
47
+ activesupport (= 3.1.3)
48
+ activesupport (3.1.3)
49
+ multi_json (~> 1.0)
50
+ acts_as_list (0.1.4)
51
+ akami (1.0.0)
52
+ gyoku (>= 0.4.0)
53
+ arel (2.2.3)
54
+ braintree (2.13.4)
55
+ builder (>= 2.0.0)
56
+ builder (3.0.0)
57
+ cocaine (0.2.1)
58
+ deface (0.7.2)
59
+ nokogiri (~> 1.5.0)
60
+ rails (>= 3.0.9)
61
+ diff-lcs (1.1.3)
62
+ erubis (2.7.0)
63
+ ffaker (1.12.1)
64
+ gyoku (0.4.4)
65
+ builder (>= 2.1.2)
66
+ highline (1.6.8)
67
+ hike (1.2.1)
68
+ httpi (0.9.6)
69
+ rack
70
+ i18n (0.6.0)
71
+ jquery-rails (1.0.19)
72
+ railties (~> 3.0)
73
+ thor (~> 0.14)
74
+ json (1.6.5)
75
+ kaminari (0.13.0)
76
+ actionpack (>= 3.0.0)
77
+ activesupport (>= 3.0.0)
78
+ railties (>= 3.0.0)
79
+ mail (2.3.0)
80
+ i18n (>= 0.4.0)
81
+ mime-types (~> 1.16)
82
+ treetop (~> 1.4.8)
83
+ meta_search (1.1.1)
84
+ actionpack (~> 3.1.0)
85
+ activerecord (~> 3.1.0)
86
+ activesupport (~> 3.1.0)
87
+ polyamorous (~> 0.5.0)
88
+ mime-types (1.17.2)
89
+ money (3.7.1)
90
+ i18n (~> 0.4)
91
+ multi_json (1.1.0)
92
+ nested_set (1.6.8)
93
+ activerecord (>= 3.0.0)
94
+ railties (>= 3.0.0)
95
+ nokogiri (1.5.0)
96
+ nori (1.1.0)
97
+ paperclip (2.5.0)
98
+ activerecord (>= 2.3.0)
99
+ activesupport (>= 2.3.2)
100
+ cocaine (>= 0.0.2)
101
+ mime-types
102
+ polyamorous (0.5.0)
103
+ activerecord (~> 3.0)
104
+ polyglot (0.3.3)
105
+ rack (1.3.6)
106
+ rack-cache (1.1)
107
+ rack (>= 0.4)
108
+ rack-mount (0.8.3)
109
+ rack (>= 1.0.0)
110
+ rack-ssl (1.3.2)
111
+ rack
112
+ rack-test (0.6.1)
113
+ rack (>= 1.0)
114
+ rails (3.1.3)
115
+ actionmailer (= 3.1.3)
116
+ actionpack (= 3.1.3)
117
+ activerecord (= 3.1.3)
118
+ activeresource (= 3.1.3)
119
+ activesupport (= 3.1.3)
120
+ bundler (~> 1.0)
121
+ railties (= 3.1.3)
122
+ railties (3.1.3)
123
+ actionpack (= 3.1.3)
124
+ activesupport (= 3.1.3)
125
+ rack-ssl (~> 1.3.2)
126
+ rake (>= 0.8.7)
127
+ rdoc (~> 3.4)
128
+ thor (~> 0.14.6)
129
+ rake (0.9.2.2)
130
+ rdoc (3.12)
131
+ json (~> 1.4)
132
+ rspec (2.8.0)
133
+ rspec-core (~> 2.8.0)
134
+ rspec-expectations (~> 2.8.0)
135
+ rspec-mocks (~> 2.8.0)
136
+ rspec-core (2.8.0)
137
+ rspec-expectations (2.8.0)
138
+ diff-lcs (~> 1.1.2)
139
+ rspec-mocks (2.8.0)
140
+ rspec-rails (2.8.1)
141
+ actionpack (>= 3.0)
142
+ activesupport (>= 3.0)
143
+ railties (>= 3.0)
144
+ rspec (~> 2.8.0)
145
+ savon (0.9.9)
146
+ akami (~> 1.0)
147
+ builder (>= 2.1.2)
148
+ gyoku (>= 0.4.0)
149
+ httpi (~> 0.9)
150
+ nokogiri (>= 1.4.0)
151
+ nori (~> 1.1)
152
+ wasabi (~> 2.1)
153
+ spree_core (1.0.0)
154
+ activemerchant (= 1.20.1)
155
+ acts_as_list (= 0.1.4)
156
+ deface (>= 0.7.2)
157
+ ffaker (~> 1.12.0)
158
+ highline (= 1.6.8)
159
+ jquery-rails (>= 1.0.18, <= 1.0.19)
160
+ kaminari (>= 0.13.0)
161
+ meta_search (= 1.1.1)
162
+ nested_set (= 1.6.8)
163
+ paperclip (= 2.5.0)
164
+ rails (>= 3.1.1, <= 3.1.3)
165
+ state_machine (= 1.1.1)
166
+ stringex (~> 1.3.0)
167
+ sprockets (2.0.3)
168
+ hike (~> 1.2)
169
+ rack (~> 1.0)
170
+ tilt (~> 1.1, != 1.3.0)
171
+ state_machine (1.1.1)
172
+ stringex (1.3.2)
173
+ thor (0.14.6)
174
+ tilt (1.3.3)
175
+ treetop (1.4.10)
176
+ polyglot
177
+ polyglot (>= 0.3.1)
178
+ tzinfo (0.3.31)
179
+ wasabi (2.1.0)
180
+ nokogiri (>= 1.4.0)
181
+
182
+ PLATFORMS
183
+ ruby
184
+
185
+ DEPENDENCIES
186
+ rspec-rails
187
+ spree_usa_epay!
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2011 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ SpreeUsaEpay
2
+ ============
3
+
4
+ *Please see the Versionfile for branches to use with older versions for Spree*
5
+
6
+ If use use the spree command line tool to install Spree to your project, it will
7
+ add spree_usa_epay to your Gemfile with the proper git references.
8
+
9
+ You can add this gem manually:
10
+
11
+ gem 'spree_usa_epay', :git => 'git@github.com:spree/spree_usa_epay.git'
12
+
13
+
14
+ Once installed, the USA Epay Gateway should be available as a provider when defining Payment Methods in Spree.
15
+
16
+ 4. Navigate to /admin/payment_methods and create a new payment method
17
+
18
+ 5. Give it a name and select "Gateway::UsaEpay" as the provider. (see screenshot)
19
+
20
+ 6. Save the payment method and it will refresh with additional options
21
+
22
+ 7. Add your Source Key and Pin. You must create your Source Key with a
23
+ Pin on the USA Epay website. They say the pin is optional, but
24
+ spree_usa_epay requires it.
25
+
26
+ 8. If you are using a Source Key on sandbox.usaepay.com check the "Test Mode" checkbox, otherwise
27
+ leave it unchecked to use the production EPay servers.
28
+
29
+ You can read additional information on Setting up Payment Gateways on http://guides.spreecommerce.com/payment_gateways.html
30
+
31
+ Example
32
+ =======
33
+
34
+ Example goes here.
35
+
36
+ Testing
37
+ -------
38
+
39
+ Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
40
+
41
+ $ bundle exec rake test app
42
+ $ bundle exec rspec spec
43
+
44
+ Copyright (c) 2011 Spree Commerce, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+
7
+ RSpec::Core::RakeTask.new
8
+
9
+ task :default => [:spec]
10
+
11
+ spec = eval(File.read('spree_usa_epay.gemspec'))
12
+
13
+ Gem::PackageTask.new(spec) do |p|
14
+ p.gem_spec = spec
15
+ end
16
+
17
+ desc "Release to gemcutter"
18
+ task :release => :package do
19
+ require 'rake/gemcutter'
20
+ Rake::Gemcutter::Tasks.new(spec).define
21
+ Rake::Task['gem:push'].invoke
22
+ end
23
+
24
+ desc "Generates a dummy app for testing"
25
+ task :test_app do
26
+ ENV['LIB_NAME'] = 'spree_usa_epay'
27
+ Rake::Task['common:test_app'].invoke
28
+ end
data/Versionfile ADDED
@@ -0,0 +1,13 @@
1
+ # This file is used to designate compatibilty with different versions of Spree
2
+ # Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
3
+
4
+ # Examples
5
+ #
6
+ # "0.70.x" => { :branch => "master"}
7
+ # "0.60.x" => { :branch => "0-60-stable" }
8
+ # "0.40.x" => { :tag => "v1.0.0", :version => "1.0.0" }
9
+ #
10
+
11
+ "1.0.x" => { :branch => "master" }
12
+ "0.70.x" => { :branch => "0-70-stable"}
13
+ "0.60.x" => { :branch => "0-60-stable"}
@@ -0,0 +1,25 @@
1
+ module Spree
2
+ class Gateway::UsaEpay < Gateway
3
+ preference :source_key, :string
4
+ preference :pin, :string
5
+
6
+ def provider_class
7
+ SpreeUsaEpay::Client
8
+ end
9
+
10
+ def payment_profiles_supported?
11
+ true
12
+ end
13
+
14
+ def create_profile(payment)
15
+ amount = (payment.amount * 100).round
16
+ creditcard = payment.source
17
+ if creditcard.gateway_customer_profile_id.nil?
18
+ profile_id = provider.add_customer(amount, creditcard, creditcard.gateway_options(payment))
19
+ creditcard.update_attributes(:gateway_customer_profile_id => profile_id,
20
+ :gateway_payment_profile_id => 0)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ # Add your extension routes here
3
+ end
@@ -0,0 +1,29 @@
1
+ module SpreeUsaEpay
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_javascripts
6
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_usa_epay\n"
7
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_usa_epay\n"
8
+ end
9
+
10
+ def add_stylesheets
11
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_usa_epay\n", :before => /\*\//, :verbose => true
12
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_usa_epay\n", :before => /\*\//, :verbose => true
13
+ end
14
+
15
+ def add_migrations
16
+ run 'bundle exec rake railties:install:migrations FROM=spree_usa_epay'
17
+ end
18
+
19
+ def run_migrations
20
+ res = ask "Would you like to run the migrations now? [Y/n]"
21
+ if res == "" || res.downcase == "y"
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts "Skiping rake db:migrate, don't forget to run it!"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,215 @@
1
+ module SpreeUsaEpay
2
+ class Client
3
+ attr_accessor :source_key, :pin, :test_mode
4
+
5
+ def initialize(options)
6
+ @source_key = options[:source_key]
7
+ @pin = options[:pin]
8
+ @test_mode = options[:test_mode]
9
+ @client = Savon::Client.new(soap_url)
10
+ end
11
+
12
+ def request(name, body)
13
+ begin
14
+ @client.request name do
15
+ soap.body = body
16
+ end
17
+ rescue Exception => e
18
+ raise Spree::Core::GatewayError.new(e.message)
19
+ end
20
+ end
21
+
22
+ def authorize(amount, creditcard, gateway_options)
23
+ if creditcard.gateway_customer_profile_id?
24
+ run_customer_transaction('AuthOnly', amount, creditcard, gateway_options)
25
+ else
26
+ token = security_token(gateway_options)
27
+ request = transaction_request_object(amount, creditcard, gateway_options)
28
+ response = request(:run_auth_only, { "Token" => token, "Params" => request })
29
+ billing_response response[:run_auth_only_response][:run_auth_only_return]
30
+ end
31
+ end
32
+
33
+
34
+ def purchase(amount, creditcard, gateway_options)
35
+ token = security_token(gateway_options)
36
+ request = transaction_request_object(amount, creditcard, gateway_options)
37
+
38
+ response = request(:run_transaction, { "Token" => token, "Params" => request })
39
+ billing_response response[:run_transaction_response][:run_transaction_return]
40
+ end
41
+
42
+ def add_customer(amount, creditcard, gateway_options)
43
+ token = security_token(gateway_options)
44
+ customer = customer_data(amount, creditcard, gateway_options)
45
+
46
+ response = request(:add_customer, { "Token" => token, "CustomerData" => customer })
47
+ response[:add_customer_response][:add_customer_return]
48
+ end
49
+
50
+ #http://wiki.usaepay.com/developer/soap-1.4/methods/runcustomertransaction
51
+ def capture(payment, creditcard, gateway_options)
52
+ amount = (payment.amount * 100).round
53
+ run_customer_transaction('Sale', amount, creditcard, gateway_options)
54
+ end
55
+
56
+ def credit(amount, creditcard, response_code, gateway_options)
57
+ if creditcard.gateway_customer_profile_id?
58
+ run_customer_transaction('Credit', amount, creditcard, gateway_options)
59
+ else
60
+ token = security_token(gateway_options)
61
+ request = transaction_request_object(amount, creditcard, gateway_options)
62
+
63
+ response = request(:run_credit, { "Token" => token, "Params" => request })
64
+ billing_response response[:run_credit_response][:run_credit_return]
65
+ end
66
+ end
67
+
68
+ def void(response_code, gateway_options)
69
+ response = request(:void_transaction, { "Token" => security_token(gateway_options), "RefNum" => response_code })
70
+ success = response[:void_transaction_response][:void_transaction_return] #just returns true
71
+ ActiveMerchant::Billing::Response.new(success, "", {}, {})
72
+ end
73
+
74
+ private
75
+
76
+ def soap_url
77
+ if @test_mode
78
+ "https://sandbox.usaepay.com/soap/gate/DFBAABC3/usaepay.wsdl"
79
+ else
80
+ "https://www.usaepay.com/soap/gate/DFBAABC3/usaepay.wsdl"
81
+ end
82
+ end
83
+
84
+ #http://wiki.usaepay.com/developer/soap-1.4/methods/runcustomertransaction
85
+ # Commands are Sale, AuthOnly, Credit, Check and CheckCredit
86
+ def run_customer_transaction(command, amount, creditcard, gateway_options)
87
+ return unless creditcard.gateway_customer_profile_id?
88
+
89
+ token = security_token(gateway_options)
90
+ request = customer_transaction_request(amount, creditcard, gateway_options)
91
+ request['Command'] = command
92
+
93
+ response = request(:run_customer_transaction,{"Token" => token,
94
+ "CustNum" => creditcard.gateway_customer_profile_id,
95
+ "PaymentMethodID" => creditcard.gateway_payment_profile_id,
96
+ "Parameters" => request })
97
+ billing_response response[:run_customer_transaction_response][:run_customer_transaction_return]
98
+ end
99
+
100
+ def billing_response(response)
101
+ options = {
102
+ :authorization => response[:ref_num],
103
+ :avs_result => { :code => response[:avs_result_code] },
104
+ :cvv_result => response[:card_code_result],
105
+ :test => @test_mode
106
+ }
107
+
108
+ case response[:result_code].to_s
109
+ when "A"
110
+ success = true
111
+ message = response[:result]
112
+ when "D"
113
+ success = false
114
+ message = response[:result]
115
+ when "E"
116
+ success = false
117
+ message = response[:error]
118
+ else
119
+ success = false
120
+ message = "Unexpected result_code from USA Epay"
121
+ end
122
+
123
+ ActiveMerchant::Billing::Response.new(success, message, {}, options)
124
+ end
125
+
126
+ #http://wiki.usaepay.com/developer/soap-1.4/objects/uesecuritytoken
127
+ def security_token(gateway_options)
128
+ t = Time.now
129
+ hash = Hash.new
130
+ hash["Seed"] = "#{t.year}#{t.month}#{t.day}#{t.hour}#{rand(1000)}"
131
+ hash["Type"] = 'sha1'
132
+
133
+ prehash = "#{@source_key}#{hash["Seed"]}#{@pin.to_s.strip}"
134
+ hash["HashValue"] = Digest::SHA1.hexdigest(prehash).to_s
135
+
136
+ token = Hash.new
137
+ token["ClientIP"] = gateway_options[:ip]
138
+ token["PinHash"] = hash
139
+ token["SourceKey"] = @source_key
140
+ token
141
+ end
142
+
143
+ #http://wiki.usaepay.com/developer/soap-1.4/objects/transactionrequestobject
144
+ def transaction_request_object(amount, creditcard, gateway_options)
145
+ { 'AccountHolder' => creditcard.name,
146
+ 'ClientIP' => gateway_options[:ip],
147
+ 'Details' => transaction_details(amount, creditcard, gateway_options),
148
+ 'BillingAddress' => address_hash(creditcard, gateway_options, :billing_address),
149
+ 'ShippingAddress' => address_hash(creditcard, gateway_options, :shipping_address),
150
+ 'CreditCardData' => {
151
+ 'CardNumber' => creditcard.number,
152
+ 'CardExpiration' => expiration_date(creditcard),
153
+ 'AvsStreet' => gateway_options[:billing_address][:address1],
154
+ 'AvsZip' => gateway_options[:billing_address][:zip],
155
+ 'CardCode' => creditcard.verification_value } }
156
+ end
157
+
158
+ #http://wiki.usaepay.com/developer/soap-1.4/objects/transactiondetail
159
+ def transaction_details(amount, creditcard, gateway_options)
160
+ { 'Description' => gateway_options[:customer],
161
+ 'Amount' => double_money(amount),
162
+ 'Tax' => double_money(gateway_options[:tax]),
163
+ 'Subtotal' => double_money(gateway_options[:subtotal]),
164
+ 'Shipping' => double_money(gateway_options[:shipping]),
165
+ 'OrderID' => gateway_options[:order_id] }
166
+ end
167
+
168
+ #http://wiki.usaepay.com/developer/soap-1.4/objects/customerobject
169
+ def customer_data(amount, creditcard, gateway_options)
170
+ { 'Amount' => double_money(amount),
171
+ 'Enabled' => false,
172
+ 'BillingAddress' => address_hash(creditcard, gateway_options, :billing_address),
173
+ 'PaymentMethods' => ['PaymentMethod' => { 'MethodType' => 'CreditCard',
174
+ 'MethodName' => creditcard.cc_type,
175
+ "SecondarySort" => 1,
176
+ 'CardNumber' => creditcard.number,
177
+ 'CardExpiration' => expiration_date(creditcard),
178
+ 'CardCode' => creditcard.verification_value,
179
+ 'AvsStreet' => gateway_options[:billing_address][:address1],
180
+ 'AvsZip' => gateway_options[:billing_address][:zip]
181
+ }] }
182
+ end
183
+
184
+ #http://wiki.usaepay.com/developer/soap-1.4/objects/customertransactionrequest
185
+ def customer_transaction_request(amount, creditcard, gateway_options)
186
+ { 'Command' => 'Sale',
187
+ 'ClientIP' => gateway_options[:ip],
188
+ 'isRecurring' => false,
189
+ 'Details' => transaction_details(amount, creditcard, gateway_options) }
190
+ end
191
+
192
+ def double_money(value)
193
+ (value.to_f/100.00).round(2)
194
+ end
195
+
196
+ def address_hash(creditcard, gateway_options, address_key)
197
+ { 'FirstName' => creditcard.first_name,
198
+ 'LastName' => creditcard.last_name,
199
+ 'Email' => gateway_options[:email],
200
+ 'Phone' => gateway_options[address_key][:phone],
201
+ 'Street' => gateway_options[address_key][:address1],
202
+ 'Street2' => gateway_options[address_key][:address2],
203
+ 'City' => gateway_options[address_key][:city],
204
+ 'State' => gateway_options[address_key][:state],
205
+ 'Country' => gateway_options[address_key][:country],
206
+ 'Zip' => gateway_options[address_key][:zip] }
207
+ end
208
+
209
+ def expiration_date(creditcard)
210
+ ("%.2i" % creditcard.month) + creditcard.year[2,2]
211
+ end
212
+
213
+ end
214
+ end
215
+
@@ -0,0 +1,17 @@
1
+ module SpreeUsaEpay
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_usa_epay'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ initializer "spree.usa_epay.payment_methods" do |app|
13
+ app.config.spree.payment_methods << Spree::Gateway::UsaEpay
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,4 @@
1
+ require 'spree_core'
2
+ require 'spree_usa_epay/engine'
3
+ require 'spree_usa_epay/client'
4
+ require 'savon'
data/script/rails ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+
5
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
6
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
7
+
@@ -0,0 +1,31 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+
7
+
8
+ require 'rspec/rails'
9
+
10
+ # Requires supporting ruby files with custom matchers and macros, etc,
11
+ # in spec/support/ and its subdirectories.
12
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
13
+
14
+ RSpec.configure do |config|
15
+ # == Mock Framework
16
+ #
17
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
18
+ #
19
+ # config.mock_with :mocha
20
+ # config.mock_with :flexmock
21
+ # config.mock_with :rr
22
+ config.mock_with :rspec
23
+
24
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
25
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
26
+
27
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
28
+ # examples within a transaction, remove the following line or assign false
29
+ # instead of true.
30
+ config.use_transactional_fixtures = true
31
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ Gem::Specification.new do |s|
3
+ s.platform = Gem::Platform::RUBY
4
+ s.name = 'spree_usa_epay'
5
+ s.version = '1.0.0'
6
+ s.summary = 'Spree Payment Gateway for USA ePay'
7
+ s.description = 'Wrapper for SOAP USA ePay Web Service'
8
+ s.required_ruby_version = '>= 1.8.7'
9
+
10
+ s.authors = ["Chris Mar"]
11
+ s.email = 'support@spreecommerce.com'
12
+ s.homepage = 'http://www.spreecommerce.com'
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.require_path = 'lib'
17
+ s.requirements << 'none'
18
+
19
+ s.add_dependency('spree_core', '>=1.0.0')
20
+ s.add_dependency 'savon'
21
+ s.add_development_dependency 'rspec-rails'
22
+ end
23
+
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_usa_epay
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chris Mar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: spree_core
16
+ requirement: &70310986613340 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70310986613340
25
+ - !ruby/object:Gem::Dependency
26
+ name: savon
27
+ requirement: &70310986612920 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70310986612920
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec-rails
38
+ requirement: &70310986612400 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70310986612400
47
+ description: Wrapper for SOAP USA ePay Web Service
48
+ email: support@spreecommerce.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE
58
+ - README.md
59
+ - Rakefile
60
+ - Versionfile
61
+ - app/models/spree/gateway/usa_epay.rb
62
+ - config/routes.rb
63
+ - lib/generators/spree_usa_epay/install/install_generator.rb
64
+ - lib/spree_usa_epay.rb
65
+ - lib/spree_usa_epay/client.rb
66
+ - lib/spree_usa_epay/engine.rb
67
+ - script/rails
68
+ - spec/spec_helper.rb
69
+ - spree_usa_epay.gemspec
70
+ homepage: http://www.spreecommerce.com
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: 1.8.7
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ segments:
89
+ - 0
90
+ hash: -2580038373875603488
91
+ requirements:
92
+ - none
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.10
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Spree Payment Gateway for USA ePay
98
+ test_files:
99
+ - spec/spec_helper.rb