atpay 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.md +31 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/atpay.gemspec +78 -0
- data/config/development.example.yml +9 -0
- data/lib/atpay.rb +11 -0
- data/lib/atpay/payment.rb +467 -0
- data/lib/atpay/request.xml.erb +41 -0
- data/lib/atpay/successful_response.html +0 -0
- data/spec/configure_spec.rb +21 -0
- data/spec/payment_spec.rb +286 -0
- data/spec/spec_helper.rb +15 -0
- metadata +167 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'crack'
|
4
|
+
gem 'httparty'
|
5
|
+
gem 'credit_card_validator', :git => 'git://github.com/hashrocket/credit_card_validator.git'
|
6
|
+
gem 'activesupport'
|
7
|
+
group :development do
|
8
|
+
gem "rspec", "~> 2.8.0"
|
9
|
+
gem "rdoc", "~> 3.12"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.8.3"
|
12
|
+
gem "debugger"
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Paul Kruger
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
= Atpay
|
2
|
+
|
3
|
+
Atpay.net Payment Class.
|
4
|
+
|
5
|
+
To user class
|
6
|
+
/config/initializers/atpay.rb
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
ATPAY.configure do |config|
|
10
|
+
config.username = 'username'
|
11
|
+
config.password = 'password'
|
12
|
+
config.host = 'http://test.com'
|
13
|
+
end
|
14
|
+
```
|
15
|
+
== Contributing to Atpay
|
16
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
17
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
18
|
+
* Fork the project.
|
19
|
+
* Copy config/development.example.yml to config/devlopment.yml
|
20
|
+
* Start a feature/bugfix branch.
|
21
|
+
* Commit and push until you are happy with your contribution.
|
22
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
23
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2012 Paul Kruger. See LICENSE.txt for further details.
|
28
|
+
|
29
|
+
Thanks to Josh TOYOTA for the origional class
|
30
|
+
|
31
|
+
Thanks to ♆Sir Dante Elrik(theInferno)♆ the for the configuration and module support
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
desc "Open an irb session preloaded with this library"
|
15
|
+
task :console do
|
16
|
+
sh "irb -rubygems -I lib -r atpay.rb"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'jeweler'
|
20
|
+
Jeweler::Tasks.new do |gem|
|
21
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
22
|
+
gem.name = "atpay"
|
23
|
+
gem.homepage = "http://github.com/saveologypaul/atpay"
|
24
|
+
gem.license = "MIT"
|
25
|
+
gem.summary = %Q{Atpay.net payment class}
|
26
|
+
gem.description = %Q{Atpay.net payment class}
|
27
|
+
gem.email = "devteam+pkruger+jtoyota@saveology.com"
|
28
|
+
gem.authors = ["Paul Kruger","Josh Toyota", "Dante Elrick", "Jon Turner"]
|
29
|
+
gem.files.include 'lib/**/*'
|
30
|
+
# dependencies defined in Gemfile
|
31
|
+
end
|
32
|
+
Jeweler::RubygemsDotOrgTasks.new
|
33
|
+
|
34
|
+
require 'rspec/core'
|
35
|
+
require 'rspec/core/rake_task'
|
36
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
37
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "atpay #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.4.0
|
data/atpay.gemspec
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "atpay"
|
8
|
+
s.version = "1.4.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Paul Kruger", "Josh Toyota", "Dante Elrick", "Jon Turner"]
|
12
|
+
s.date = "2012-06-25"
|
13
|
+
s.description = "Atpay.net payment class"
|
14
|
+
s.email = "devteam+pkruger+jtoyota@saveology.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"LICENSE.txt",
|
23
|
+
"README.md",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"atpay.gemspec",
|
27
|
+
"config/development.example.yml",
|
28
|
+
"lib/atpay.rb",
|
29
|
+
"lib/atpay/payment.rb",
|
30
|
+
"lib/atpay/request.xml.erb",
|
31
|
+
"lib/atpay/successful_response.html",
|
32
|
+
"spec/configure_spec.rb",
|
33
|
+
"spec/payment_spec.rb",
|
34
|
+
"spec/spec_helper.rb"
|
35
|
+
]
|
36
|
+
s.homepage = "http://github.com/saveologypaul/atpay"
|
37
|
+
s.licenses = ["MIT"]
|
38
|
+
s.require_paths = ["lib"]
|
39
|
+
s.rubygems_version = "1.8.17"
|
40
|
+
s.summary = "Atpay.net payment class"
|
41
|
+
|
42
|
+
if s.respond_to? :specification_version then
|
43
|
+
s.specification_version = 3
|
44
|
+
|
45
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
|
+
s.add_runtime_dependency(%q<crack>, [">= 0"])
|
47
|
+
s.add_runtime_dependency(%q<httparty>, [">= 0"])
|
48
|
+
s.add_runtime_dependency(%q<credit_card_validator>, [">= 0"])
|
49
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<crack>, [">= 0"])
|
57
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
58
|
+
s.add_dependency(%q<credit_card_validator>, [">= 0"])
|
59
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
64
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<crack>, [">= 0"])
|
68
|
+
s.add_dependency(%q<httparty>, [">= 0"])
|
69
|
+
s.add_dependency(%q<credit_card_validator>, [">= 0"])
|
70
|
+
s.add_dependency(%q<activesupport>, [">= 0"])
|
71
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
72
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
75
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
ATPAY_HOST: 'http://'
|
2
|
+
ATPAY_USERNAME: 'yourusername'
|
3
|
+
ATPAY_PASSWORD: 'yourpassword'
|
4
|
+
ATPAY_VALID_CARD_AVS: '111'
|
5
|
+
ATPAY_VALID_CARD_EXPIRE_DATE: '0199'
|
6
|
+
ATPAY_VALID_CARD_NAME_ON_CARD: 'test delete'
|
7
|
+
ATPAY_VALID_CARD_NUMBER: '1111111111111111'
|
8
|
+
ATPAY_TEST_ACCOUNT_ID: '111'
|
9
|
+
ATPAY_TEST_SUB_ACCOUNT_ID: '1'
|
data/lib/atpay.rb
ADDED
@@ -0,0 +1,467 @@
|
|
1
|
+
require 'active_support/core_ext/hash'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'crack'
|
4
|
+
require 'httparty'
|
5
|
+
require 'erb'
|
6
|
+
require 'credit_card_validator'
|
7
|
+
|
8
|
+
module ATPAY
|
9
|
+
class Payment
|
10
|
+
include HTTParty
|
11
|
+
attr_accessor :username, :password, :host
|
12
|
+
default_timeout 15
|
13
|
+
#user info
|
14
|
+
attr_accessor :first_name
|
15
|
+
attr_accessor :last_name
|
16
|
+
attr_accessor :email
|
17
|
+
attr_accessor :address
|
18
|
+
attr_accessor :address2
|
19
|
+
attr_accessor :city
|
20
|
+
attr_accessor :state
|
21
|
+
attr_accessor :zip
|
22
|
+
attr_accessor :phone
|
23
|
+
attr_accessor :ip_address
|
24
|
+
#card info
|
25
|
+
attr_accessor :name_on_card
|
26
|
+
attr_accessor :number
|
27
|
+
attr_accessor :credit_card_type
|
28
|
+
attr_accessor :cvv
|
29
|
+
attr_accessor :expiration_date
|
30
|
+
#charge info
|
31
|
+
attr_accessor :amount
|
32
|
+
attr_accessor :order_id
|
33
|
+
attr_accessor :free_text
|
34
|
+
#recurrring info
|
35
|
+
attr_accessor :recurring_payment
|
36
|
+
attr_accessor :base_amount
|
37
|
+
attr_accessor :first_installment_amount
|
38
|
+
attr_accessor :initial_pre_auth_amount
|
39
|
+
attr_accessor :first_installment_interval
|
40
|
+
attr_accessor :recurring_amount
|
41
|
+
attr_accessor :recurring_installment_interval_method
|
42
|
+
attr_accessor :recurring_installment_interval_method_additional_info
|
43
|
+
attr_accessor :account_id
|
44
|
+
attr_accessor :sub_account_id
|
45
|
+
attr_accessor :service_expiry_method
|
46
|
+
attr_accessor :service_expiry_method_additional_info
|
47
|
+
#results
|
48
|
+
attr_accessor :request
|
49
|
+
attr_accessor :response
|
50
|
+
attr_accessor :success
|
51
|
+
attr_accessor :transaction_id
|
52
|
+
#internal
|
53
|
+
attr_accessor :response_code, :errors, :error, :atpay_error, :error_id, :org_options, :dynamic_tags, :xml
|
54
|
+
|
55
|
+
def initialize
|
56
|
+
@username = ATPAY.username
|
57
|
+
@password = ATPAY.password
|
58
|
+
@host = ATPAY.host
|
59
|
+
@ip_address = '127.0.0.1'
|
60
|
+
@error = @first_name = @last_name = @email = @address = @address2 = @city = @state = @zip = @phone = @name_on_card = @number = @credit_card_type = @cvv = @expiration_date = @free_text = @recurring_installment_interval_method_additional_info = @account_id = @sub_account_id = @service_expiry_method = @service_expiry_method_additional_info = @request = @response = @transaction_id = @org_options = @dynamic_tags = @xml = @order_id = ''
|
61
|
+
@amount = @base_amount = @first_installment_amount = @initial_pre_auth_amount = @first_installment_interval = @recurring_amount = 0
|
62
|
+
@recurring_payment = @success = false
|
63
|
+
@recurring_installment_interval_method = 'Daily'
|
64
|
+
errors
|
65
|
+
end
|
66
|
+
|
67
|
+
def charge(options = {})
|
68
|
+
self.class.basic_auth(ATPAY.username, ATPAY.password)
|
69
|
+
@org_options = options
|
70
|
+
|
71
|
+
#user info
|
72
|
+
@first_name = options[:first_name] if options[:first_name]
|
73
|
+
@last_name = options[:last_name] if options[:last_name]
|
74
|
+
@email = options[:email] if options[:email]
|
75
|
+
@address = options[:address] if options[:address]
|
76
|
+
@address2 = options[:address2] if options[:address2]
|
77
|
+
@city = options[:city] if options[:city]
|
78
|
+
@state = options[:state] if options[:state]
|
79
|
+
@zip = options[:zip] if options[:zip]
|
80
|
+
@phone = options[:phone] if options[:phone]
|
81
|
+
@ip_address = options[:ip_address] if options[:ip_address]
|
82
|
+
|
83
|
+
#card info
|
84
|
+
@name_on_card = options[:name_on_card]
|
85
|
+
@number = options[:number]
|
86
|
+
@cvv = options[:cvv]
|
87
|
+
@expiration_date = options[:expiration_date]
|
88
|
+
@credit_card_type = options[:credit_card_type] if options[:credit_card_type]
|
89
|
+
|
90
|
+
#charge info
|
91
|
+
@amount = options[:amount] if options[:amount]
|
92
|
+
@order_id = options[:order_id] if options[:order_id]
|
93
|
+
@free_text = options[:free_text] if options[:free_text]
|
94
|
+
|
95
|
+
#recurring info
|
96
|
+
@recurring_payment = options[:recurring_payment] if options[:recurring_payment]
|
97
|
+
@base_amount = options[:base_amount] if options[:base_amount]
|
98
|
+
@first_installment_amount = options[:first_installment_amount] if options[:first_installment_amount]
|
99
|
+
@initial_pre_auth_amount = options[:initial_pre_auth_amount] if options[:initial_pre_auth_amount]
|
100
|
+
@first_installment_interval = options[:first_installment_interval] if options[:first_installment_interval]
|
101
|
+
@recurring_amount = options[:recurring_amount] if options[:recurring_amount]
|
102
|
+
@recurring_installment_interval_method = options[:recurring_installment_interval_method] if options[:recurring_installment_interval_method]
|
103
|
+
@recurring_installment_interval_additional_info = options[:recurring_installment_interval_additional_info] if options[:recurring_installment_interval_additional_info]
|
104
|
+
@account_id = options[:account_id] if options[:account_id]
|
105
|
+
@sub_account_id = options[:sub_account_id] if options[:sub_account_id]
|
106
|
+
@service_expiry_method = options[:service_expiry_method] if options[:service_expiry_method]
|
107
|
+
@service_expiry_method_additional_info = options[:service_expiry_method_additional_info] if options[:service_expiry_method_additional_info]
|
108
|
+
@dynamic_tags = dynamic_tags
|
109
|
+
send_payment_request
|
110
|
+
end
|
111
|
+
|
112
|
+
def credit_card_type
|
113
|
+
type = CreditCardValidator::Validator.card_type(@number)
|
114
|
+
card_types = HashWithIndifferentAccess.new({
|
115
|
+
:visa => 'Visa',
|
116
|
+
:master_card => 'MasterCard',
|
117
|
+
:diners_club => 'Diners',
|
118
|
+
:amex => 'AmericanExpress',
|
119
|
+
:discover => 'Discover'
|
120
|
+
})
|
121
|
+
card_types[type] || 'Empty'
|
122
|
+
end
|
123
|
+
|
124
|
+
def send_payment_request
|
125
|
+
fire_payment_request
|
126
|
+
handle_payment_response
|
127
|
+
success
|
128
|
+
end
|
129
|
+
|
130
|
+
def handle_payment_response
|
131
|
+
@success = false
|
132
|
+
result = {}
|
133
|
+
begin
|
134
|
+
result = Crack::XML.parse(@response.body)['soap:Envelope']['soap:Body']['RegularTransactionResponse']['RegularTransactionResult']
|
135
|
+
@success = (result['SuccessFlag'] == 'true')
|
136
|
+
rescue NoMethodError
|
137
|
+
end
|
138
|
+
if @success
|
139
|
+
@transaction_id = result['TransactionID']
|
140
|
+
return true
|
141
|
+
else
|
142
|
+
if @response.body =~ /Unauthorized: Access is denied due to invalid credentials/
|
143
|
+
@error = 'Access is denied due to invalid credentials'
|
144
|
+
else
|
145
|
+
@error_id = @response.parsed_response["Envelope"]["Body"]["RegularTransactionResponse"]["RegularTransactionResult"]["ErrorID"]
|
146
|
+
@error = "Sorry we were unable to process your card"
|
147
|
+
@atpay_error = @errors[@error_id.to_i] if @errors[@error_id.to_i].present?
|
148
|
+
end
|
149
|
+
return false
|
150
|
+
end
|
151
|
+
end
|
152
|
+
def soap_action
|
153
|
+
['http://transactions.atpay.net','/webservices/ATPayTxWS/RegularTransaction'].join('')
|
154
|
+
end
|
155
|
+
def url
|
156
|
+
[@host,'/TxWS/ATPayTxWS.asmx'].join('')
|
157
|
+
end
|
158
|
+
def fire_payment_request
|
159
|
+
begin
|
160
|
+
@request = @xml = render_xml
|
161
|
+
puts @xml
|
162
|
+
self.class.headers 'Content-Type' => 'text/xml; charset=utf-8',
|
163
|
+
'Content-Length' => @xml.length.to_s,
|
164
|
+
'SOAPAction' => soap_action
|
165
|
+
@response = self.class.post(url, :body => @xml)
|
166
|
+
puts @response.body
|
167
|
+
rescue => e
|
168
|
+
puts e
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def render_xml
|
173
|
+
@dynamic_tags = dynamic_tags
|
174
|
+
template = File.open(File.dirname(__FILE__)+'/request.xml.erb', 'r').read
|
175
|
+
ERB.new(template).result(binding)
|
176
|
+
end
|
177
|
+
|
178
|
+
def dynamic_tags
|
179
|
+
tags = {
|
180
|
+
'Amount' => amount,
|
181
|
+
'BaseAmount' => base_amount,
|
182
|
+
'CreditCardCVV2' => cvv,
|
183
|
+
'CreditCardExpirationDate' => expiration_date,
|
184
|
+
'CreditCardNameOnCard' => name_on_card,
|
185
|
+
'CreditCardNumber' => number,
|
186
|
+
'CreditCardType' => credit_card_type,
|
187
|
+
'CustomerDateTime' => Time.now.iso8601,
|
188
|
+
'EndUserBillingAddressPhoneNumber1' => phone,
|
189
|
+
'EndUserBillingAddressNumber' => '',
|
190
|
+
'EndUserBillingAddressStreet' => address + ' ' +address2,
|
191
|
+
'EndUserBillingAddressCity' => city,
|
192
|
+
'EndUserBillingAddressState' => state,
|
193
|
+
'EndUserBillingAddressZipPostalCode' => zip,
|
194
|
+
'EndUserEmailAddress' => email,
|
195
|
+
'EndUserFirstName' => first_name,
|
196
|
+
'EndUserIPAddress' => ip_address,
|
197
|
+
'EndUserLastName' => last_name,
|
198
|
+
'MerchantFreeText' => free_text,
|
199
|
+
'AccountID' => account_id,
|
200
|
+
'SubAccountID' => sub_account_id,
|
201
|
+
'ServiceExpiryMethod' => service_expiry_method,
|
202
|
+
'ServiceExpiryMethodAdditionalInfo' => service_expiry_method_additional_info,
|
203
|
+
}
|
204
|
+
recurring_tags = {
|
205
|
+
true => {
|
206
|
+
'RecurringBillingFlag' => recurring_payment,
|
207
|
+
'FirstInstallmentAmount' => first_installment_amount,
|
208
|
+
'InitialPreAuthAmount' => initial_pre_auth_amount,
|
209
|
+
'FirstInstallmentInterval' => first_installment_interval,
|
210
|
+
'RecurringAmount' => recurring_amount,
|
211
|
+
'RecurringInstallmentIntervalMethod' => recurring_installment_interval_method,
|
212
|
+
'RecurringInstallmentIntervalMethodAdditionalInfo' => recurring_installment_interval_method_additional_info,
|
213
|
+
},
|
214
|
+
|
215
|
+
false => {
|
216
|
+
'RecurringBillingFlag' => recurring_payment,
|
217
|
+
'FirstInstallmentAmount' => 0,
|
218
|
+
'InitialPreAuthAmount' => 0,
|
219
|
+
'FirstInstallmentInterval' => 0,
|
220
|
+
'RecurringAmount' => 0,
|
221
|
+
'RecurringInstallmentIntervalMethod' => 'Daily',
|
222
|
+
},
|
223
|
+
}
|
224
|
+
tags.update( recurring_tags[recurring_payment] )
|
225
|
+
end
|
226
|
+
|
227
|
+
def errors
|
228
|
+
@errors = {
|
229
|
+
0 => "OK",
|
230
|
+
10001 => "Blocked - issuer response",
|
231
|
+
10002 => "Stolen - issuer response",
|
232
|
+
10003 => "Contact credit card company - issuer response",
|
233
|
+
10004 => "General refusal - issuer response",
|
234
|
+
10005 => "Forged - issuer response",
|
235
|
+
10006 => "CVV2 value invalid",
|
236
|
+
10007 => "Connection to clearing interface unsuccessful",
|
237
|
+
10008 => "Error in request string to clearing interface",
|
238
|
+
10009 => "Invalid card",
|
239
|
+
10010 => "Request contradicts clearing interface configuration",
|
240
|
+
10011 => "Card expired",
|
241
|
+
10012 => "Error in feature that is not supposed to be in use",
|
242
|
+
10013 => "Incorrect secret code",
|
243
|
+
10014 => "Incorrect secret code - last try",
|
244
|
+
10016 => "Previous transaction cannot be cancelled (credit transaction or card number not identical)",
|
245
|
+
10017 => "Duplicate Transaction",
|
246
|
+
10018 => "Clearing interface application error",
|
247
|
+
10019 => "Timeout to clearing interface",
|
248
|
+
10020 => "System error",
|
249
|
+
10021 => "Cancellation transaction: Parent transaction was declined or not found",
|
250
|
+
10022 => "Cancellation transaction: transaction already processed through the acquirer",
|
251
|
+
10023 => "Cancellation transaction: transaction found but already cancelled",
|
252
|
+
10024 => "No authorization number found for this transaction",
|
253
|
+
10025 => "More than 4 days passed since charge transaction",
|
254
|
+
10029 => "Transaction type not allowed for this type of card",
|
255
|
+
10030 => "Error in request string",
|
256
|
+
10040 => "Deposit Trx not yet settled, trx cannot be credited",
|
257
|
+
10070 => "ECI or CAVV incorrect",
|
258
|
+
10100 => "Original transaction not found by MID",
|
259
|
+
10200 => "No Sufficient Funds",
|
260
|
+
10301 => "Amex - Approved (Express Rewards Program)",
|
261
|
+
10302 => "Bad Terminal ID",
|
262
|
+
10303 => "Card Network Error",
|
263
|
+
10304 => "Deny - Account Canceled",
|
264
|
+
10305 => "Deny - New card issued",
|
265
|
+
10306 => "Exceeds withdrawal limit",
|
266
|
+
10307 => "Honor with ID",
|
267
|
+
10308 => "Insufficient funds",
|
268
|
+
10309 => "Invalid ABA",
|
269
|
+
10310 => "Invalid Address",
|
270
|
+
10311 => "Invalid amount",
|
271
|
+
10312 => "Invalid AVS",
|
272
|
+
10313 => "Invalid Card Format",
|
273
|
+
10314 => "Invalid Card type",
|
274
|
+
10315 => "Invalid DDA",
|
275
|
+
10316 => "Invalid Entry Type",
|
276
|
+
10317 => "Invalid Merchant ID",
|
277
|
+
10318 => "Invalid messge format",
|
278
|
+
10319 => "Invalid Password",
|
279
|
+
10320 => "Invalid TID",
|
280
|
+
10321 => "Invalid Transaction Type",
|
281
|
+
10322 => "Invalid ZIP and Address",
|
282
|
+
10323 => "Invalid zipcode",
|
283
|
+
10324 => "Master Merchant not found",
|
284
|
+
10325 => "Merchant ID error",
|
285
|
+
10326 => "Partial Approval",
|
286
|
+
10327 => "Record Not Found",
|
287
|
+
10328 => "Re-enter transaction",
|
288
|
+
10329 => "Refund denied",
|
289
|
+
10330 => "Suspected Fraud",
|
290
|
+
10331 => "System error SD",
|
291
|
+
10332 => "Transaction cannot be completed; violation of law.",
|
292
|
+
10333 => "Transaction not allowed at terminal",
|
293
|
+
10334 => "Transaction not permitted to cardholder",
|
294
|
+
10335 => "VIP Approval",
|
295
|
+
10336 => "ACH Negative file",
|
296
|
+
10337 => "Auth cancelled or revoked",
|
297
|
+
10338 => "Problem with original Authorization",
|
298
|
+
10340 => "Failed - International transaction",
|
299
|
+
10350 => "Invalid Data - General",
|
300
|
+
10351 => "Invalid or incorrect account data",
|
301
|
+
10352 => "Invalid or incorrect bank data",
|
302
|
+
10353 => "Invalid or incorrect check data",
|
303
|
+
10354 => "Invalid or incorrect user data",
|
304
|
+
10360 => "FX Error",
|
305
|
+
10400 => "Cardholder Details Field invalid",
|
306
|
+
10401 => "Cardholder Shipping Details Field invalid",
|
307
|
+
10402 => "Merchant Details Field invalid",
|
308
|
+
10403 => "Amount field invalid",
|
309
|
+
10404 => "Transaction field invalid",
|
310
|
+
10405 => "Item details field invalid",
|
311
|
+
11001 => "SVS Payee Billing Account does not exist in the database.",
|
312
|
+
11002 => "SVS Payee Billing Account does not correspond the currency.",
|
313
|
+
11003 => "SVS Payer Billing Account does not exist in the database.",
|
314
|
+
11004 => "SVS Payer Billing Account does not correspond the currency.",
|
315
|
+
11005 => "Acquirer Billing Account does not exist in the database.",
|
316
|
+
11006 => "Aquirer Billing Account does not correspond the currency.",
|
317
|
+
11007 => "Not enough money for the withdrawal operation. The account balance is less than transaction amount.",
|
318
|
+
11008 => "Billing Account is locked for withdrawal operations.",
|
319
|
+
11009 => "SVS Payee Billing Account is suspended.",
|
320
|
+
11010 => "SVS Payer Billing Account is suspended.",
|
321
|
+
11011 => "Acquirer Billing Account is suspended.",
|
322
|
+
11015 => "Name on account does not equal the customer full name.",
|
323
|
+
11016 => "Merchant External Service execution failed.",
|
324
|
+
11021 => "Merchant did not process the transaction and returned response 'Error'.",
|
325
|
+
11022 => "The system does not support this currency",
|
326
|
+
11023 => "Payee billing account is not a customer account",
|
327
|
+
11024 => "Transactions are not allowed between TEST and LIVE accounts.",
|
328
|
+
11026 => "Billing Account belongs to the user from country forbidden for payment/payout",
|
329
|
+
11027 => "Payee and Payer skins are different",
|
330
|
+
11029 => "Billing Account is locked for submit operations.",
|
331
|
+
11030 => "This option is currently not available.",
|
332
|
+
11031 => "Customer account is currently locked because of velocity check.",
|
333
|
+
11100 => "ACH Direct service failed",
|
334
|
+
11101 => "ACH Direct did not process the transaction and returned 'Error'",
|
335
|
+
11102 => "IDVerify service failed",
|
336
|
+
11103 => "IDVerify did not process the transaction and returned 'Error'",
|
337
|
+
11104 => "ACH processing service returned fatal error code.",
|
338
|
+
11105 => "ACH processing service returned a formatting error.",
|
339
|
+
11106 => "Transaction is rejected by ACH processing service.",
|
340
|
+
11107 => "Credit Card processing service is unavailable",
|
341
|
+
11108 => "Credit Card processing service did not process the transaction and returned 'Error'",
|
342
|
+
11109 => "Rejected by Credit Card External Service",
|
343
|
+
11110 => "Credit Card processing service is unavailable",
|
344
|
+
11111 => "Credit Card processing service did not process the transaction and returned 'Error'",
|
345
|
+
11112 => "Rejected by Credit Card External Service",
|
346
|
+
11113 => "EFT processing service failed",
|
347
|
+
11114 => "EFT processing service did not process the transaction and returned 'Error'",
|
348
|
+
11115 => "Transaction is rejected by EFT/PAD processing service.",
|
349
|
+
11116 => "Enterpayment service failed",
|
350
|
+
11117 => "Enterpayment did not process the transaction and returned 'Error'",
|
351
|
+
11118 => "Transaction is rejected by CC processing service.",
|
352
|
+
11119 => "Transaction is pending. Please check status of the transaction later.",
|
353
|
+
11120 => "BlueWire processing service is unavailable",
|
354
|
+
11121 => "BlueWire processing service did not process the transaction and returned 'Error'",
|
355
|
+
11122 => "Rejected by BlueWire External Service",
|
356
|
+
11123 => "Transaction is rejected by CC processing service.",
|
357
|
+
11124 => "DataCash processing service is unavailable",
|
358
|
+
11125 => "DataCash processing service did not process the transaction and returned 'Error'",
|
359
|
+
11126 => "Rejected by DataCash External Service",
|
360
|
+
11127 => "Median processing service is unavailable",
|
361
|
+
11128 => "Median processing service did not process the transaction and returned 'Error'",
|
362
|
+
11129 => "Rejected by Median External Service",
|
363
|
+
11131 => "JetPay service failed",
|
364
|
+
11132 => "JetPay did not process the transaction and returned 'Error'",
|
365
|
+
11133 => "Transaction is rejected by JetPay processing service",
|
366
|
+
11134 => "PaymenTech service failed",
|
367
|
+
11135 => "Transaction is rejected by PaymenTech processing service",
|
368
|
+
11136 => "PaymenTech did not process the transaction and returned 'Error'",
|
369
|
+
11137 => "ConnectNpay service failed",
|
370
|
+
11138 => "Transaction is rejected by ConnectNPay processing service",
|
371
|
+
11139 => "ConnectNPay did not process the transaction and returned 'Error'",
|
372
|
+
11140 => "MES service failed",
|
373
|
+
11141 => "Transaction is rejected by MES processing service",
|
374
|
+
11142 => "MES did not process the transaction and returned 'Error'",
|
375
|
+
11197 => "Transaction Timeout",
|
376
|
+
11198 => "Old Processor System Error",
|
377
|
+
11199 => "System Error of Acquirer/Processor",
|
378
|
+
20001 => "Customer could not be recognized",
|
379
|
+
20002 => "Not permitted transaction amount",
|
380
|
+
20003 => "Unauthorized user request",
|
381
|
+
20006 => "The data of request does not match any service plan",
|
382
|
+
20008 => "Requested service plan not allowed",
|
383
|
+
20013 => "Illegal transaction packet parameter value",
|
384
|
+
20014 => "Credit card is expired or expiration date is invalid",
|
385
|
+
20015 => "Negative DB",
|
386
|
+
20022 => "DB failure when loading offline transaction parameters",
|
387
|
+
20051 => "CVV2 contains non digit chars",
|
388
|
+
20052 => "CCType and CCNumber do not match",
|
389
|
+
20066 => "Transaction type not allowed for account",
|
390
|
+
20100 => "Transaction already cancelled",
|
391
|
+
20101 => "Submit Instruction Type does not match Parent Instruction Type",
|
392
|
+
20102 => "Expiration date for submit cancel expired",
|
393
|
+
20103 => "Transaction already deposited",
|
394
|
+
20104 => "Expiration date for submit debit expired",
|
395
|
+
20105 => "Cannot run submit credit for non debit original transaction",
|
396
|
+
20106 => "Transaction already credited",
|
397
|
+
20107 => "Expiration date for submit credit expired",
|
398
|
+
20108 => "Query Transaction can not be deferred",
|
399
|
+
20109 => "The amount of submit transaction is not equal to the amount of the Parent Trx",
|
400
|
+
20110 => "The submit Operation Type does not match the Operation Type of the Parent Trx",
|
401
|
+
20111 => "Cannot credit chargeback or retrieval transaction",
|
402
|
+
20112 => "Wrong credit card expiration date.",
|
403
|
+
20113 => "Total sum of refunds exceed deposit amount",
|
404
|
+
20153 => "Transaction already revoked",
|
405
|
+
20154 => "Transaction has a final status and can not be updated.",
|
406
|
+
20199 => "Authorization Transaction Already collected for capturing process",
|
407
|
+
20200 => "Transaction rejected by clearing system",
|
408
|
+
20300 => "Transaction rejected by ThreeDSecure",
|
409
|
+
20400 => "Transaction declined",
|
410
|
+
20500 => "FDS external service execution failed",
|
411
|
+
20700 => "Transaction rejected by FDS when FDS response was not allowed",
|
412
|
+
21111 => "Old gateway error code",
|
413
|
+
25001 => "Transaction failed to load and validate parent transaction information",
|
414
|
+
25002 => "QueryByCustTxID result: Original transaction not found",
|
415
|
+
30001 => "Chargeback already charged back",
|
416
|
+
30002 => "Retrieval already retrieved",
|
417
|
+
30003 => "Second CHB in file.",
|
418
|
+
30004 => "Amount of chargeback or retrieval is different more than 20% from original deposit amount.",
|
419
|
+
30005 => "Parent Transaction Of CHB Not Found",
|
420
|
+
30006 => "Currency mismatch of CHB.",
|
421
|
+
30007 => "Deposit already received chargeback, credit is not allowed",
|
422
|
+
444444 => "An unknown error was received from the processor",
|
423
|
+
50001 => "Transaction deleted by the operator ion the Operator Site",
|
424
|
+
50002 => "Transaction rejected by the operator in the Operator Site",
|
425
|
+
60001 => "Customer originated transaction ID must be unique",
|
426
|
+
60002 => "Transaction cancelled due to time out",
|
427
|
+
60003 => "Transaction is pending. Try query transaction status later",
|
428
|
+
60004 => "Transaction not found",
|
429
|
+
60005 => "Country code is wrong or unknown",
|
430
|
+
70001 => "Insufficient or Uncollected Funds",
|
431
|
+
70002 => "Invalid or closed account",
|
432
|
+
70003 => "No authorization from account holder for action",
|
433
|
+
70004 => "Account holder deceased",
|
434
|
+
70005 => "Action not permitted on this account",
|
435
|
+
70006 => "Account on Hold",
|
436
|
+
70050 => "Invalid company data",
|
437
|
+
70100 => "Prenote Not Received",
|
438
|
+
70101 => "Returned Per ODFI",
|
439
|
+
70102 => "Check Safekeeping Return",
|
440
|
+
70103 => "Account with branch of another financial institution",
|
441
|
+
70104 => "RDFI Does not Participate",
|
442
|
+
70105 => "ODFI Permits Late Return",
|
443
|
+
70106 => "RDFI Does not permit transaction",
|
444
|
+
70107 => "Return issue",
|
445
|
+
70108 => "Currency or Cross border issue",
|
446
|
+
70109 => "Stop payment on item",
|
447
|
+
70110 => "Item and ACH entry presented for payment",
|
448
|
+
70111 => "Issue with source documents",
|
449
|
+
70112 => "ODFI does not participate or has limited participation",
|
450
|
+
70200 => "Duplicate Entry",
|
451
|
+
70201 => "Invalid or incomplete transaction data",
|
452
|
+
70202 => "Invalid or incomplete transaction data",
|
453
|
+
70203 => "Transaction has expired",
|
454
|
+
70204 => "Invalid Password",
|
455
|
+
70500 => "PP: Account is restricted / Refund not allowed",
|
456
|
+
70501 => "Transaction refused because of an invalid argument. See additional error messages for details",
|
457
|
+
70502 => "PP: Invalid action for re-authorization transaction",
|
458
|
+
70503 => "PP: Order already voided or expired",
|
459
|
+
70504 => "Maximum number of authorization allowed for the order is reached.",
|
460
|
+
70505 => "The authorization is being processed.",
|
461
|
+
70506 => "One or more payment requests failed. Check individual payment responses for more information.",
|
462
|
+
88888 => "SOAP request parameter or values are not correct",
|
463
|
+
99999 => "System Error"
|
464
|
+
}
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<soap:Body>
|
4
|
+
<RegularTransaction xmlns="http://transactions.atpay.net/webservices/ATPayTxWS/">
|
5
|
+
<RegularTransactionRequestPacket>
|
6
|
+
<AccessManagementFlag>false</AccessManagementFlag>
|
7
|
+
<AccessManagementType>None</AccessManagementType>
|
8
|
+
<BackOfficeFileId>0</BackOfficeFileId>
|
9
|
+
<BaseCurrencyType>USD</BaseCurrencyType>
|
10
|
+
<BillingPurpose>RegularCharge</BillingPurpose>
|
11
|
+
<CurrencyType>USD</CurrencyType>
|
12
|
+
<CurrencyConversionFee>0</CurrencyConversionFee>
|
13
|
+
<CustomerOriginatedTechnologyType>MsDotNet</CustomerOriginatedTechnologyType>
|
14
|
+
<CustomerOriginatedTxID>0</CustomerOriginatedTxID>
|
15
|
+
<CustomerOriginatedTxBatchNumber>0</CustomerOriginatedTxBatchNumber>
|
16
|
+
<EndUserBillingAddressCountry>US</EndUserBillingAddressCountry>
|
17
|
+
<EndUserBillingAddressSameAsShippingAddress>true</EndUserBillingAddressSameAsShippingAddress>
|
18
|
+
<InstructionType>Authorization</InstructionType>
|
19
|
+
<NumberOfTries>1</NumberOfTries>
|
20
|
+
<OperationType>Debit</OperationType>
|
21
|
+
<PaymentMethodType>CreditCard</PaymentMethodType>
|
22
|
+
<PaymentType>Regular</PaymentType>
|
23
|
+
<ProcessingType>Processing</ProcessingType>
|
24
|
+
<RequestType>Regular</RequestType>
|
25
|
+
<ScrubbingFlag>false</ScrubbingFlag>
|
26
|
+
<ServicePurchasedCategory>None</ServicePurchasedCategory>
|
27
|
+
<ServicePurchasedSubCategory>None</ServicePurchasedSubCategory>
|
28
|
+
<ServicePurchasedType>RegularTransaction</ServicePurchasedType>
|
29
|
+
<SkinID>2</SkinID>
|
30
|
+
<ThreeDSecureFlags>NoThreeD</ThreeDSecureFlags>
|
31
|
+
<TransactionCode>Internet</TransactionCode>
|
32
|
+
<TxRecurringBillingID>0</TxRecurringBillingID>
|
33
|
+
<UserLevelID>1</UserLevelID>
|
34
|
+
<WhiteListIndicator>false</WhiteListIndicator>
|
35
|
+
<% @dynamic_tags.each do |tag,val| %>
|
36
|
+
<<%= tag %>><%= val %></<%= tag %>>
|
37
|
+
<% end %>
|
38
|
+
</RegularTransactionRequestPacket>
|
39
|
+
</RegularTransaction>
|
40
|
+
</soap:Body>
|
41
|
+
</soap:Envelope>
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
describe ATPAY do
|
3
|
+
it "should respond to configure" do
|
4
|
+
subject.respond_to?(:configure).should be
|
5
|
+
end
|
6
|
+
|
7
|
+
context "should yeild the contents of block with self as the argument" do
|
8
|
+
before do
|
9
|
+
ATPAY.configure do |config|
|
10
|
+
config.username = 'username'
|
11
|
+
config.password = 'password'
|
12
|
+
config.host = 'http://test.com'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
it "should be able to set attributes" do
|
16
|
+
subject.username.should == 'username'
|
17
|
+
subject.password.should == 'password'
|
18
|
+
subject.host.should == 'http://test.com'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,286 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "Atpay" do
|
4
|
+
describe "Payment" do
|
5
|
+
before do
|
6
|
+
ATPAY.configure do |config|
|
7
|
+
config.username = invalid_username
|
8
|
+
config.password = invalid_password
|
9
|
+
config.host = host
|
10
|
+
end
|
11
|
+
end
|
12
|
+
let(:successful_response){ File.open(File::dirname(__FILE__) << './lib/successful_response','r').read }
|
13
|
+
let(:username) { ENV['ATPAY_USERNAME'] }
|
14
|
+
let(:password) { ENV['ATPAY_PASSWORD'] }
|
15
|
+
let(:host) { ENV['ATPAY_HOST'] }
|
16
|
+
let(:account_id) { ENV['ATPAY_TEST_ACCOUNT_ID'] }
|
17
|
+
let(:sub_account_id) { ENV['ATPAY_TEST_SUB_ACCOUNT_ID'] }
|
18
|
+
let(:invalid_username) { "testusername" }
|
19
|
+
let(:invalid_password) { "testpassword" }
|
20
|
+
|
21
|
+
let(:test_name_on_card) { 'Test User' }
|
22
|
+
let(:test_card_number) { '4111111111111111' }
|
23
|
+
let(:test_cvv) { '400' }
|
24
|
+
let(:test_expiration_date) { '1013' }
|
25
|
+
|
26
|
+
let(:valid_name_on_card) { ENV['ATPAY_VALID_NAME_ON_CARD'] }
|
27
|
+
let(:valid_card_number) { ENV['ATPAY_VALID_CARD_NUMBER'] }
|
28
|
+
let(:valid_cvv) { ENV['ATPAY_VALID_CARD_CVV'] }
|
29
|
+
let(:valid_expiration_date) { ENV['ATPAY_VALID_CARD_EXPIRE_DATE'] }
|
30
|
+
|
31
|
+
let(:additional_params) {
|
32
|
+
{
|
33
|
+
:email => 'test@123.com',
|
34
|
+
:order_id => '4444444'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
let(:free_text){
|
38
|
+
"Lead=3333; OPR=4000; AFF=1092; SKU=55555; EMAIL=test@123.com"
|
39
|
+
}
|
40
|
+
let(:payment_options) {
|
41
|
+
{
|
42
|
+
:name_on_card => test_name_on_card,
|
43
|
+
:number => test_card_number,
|
44
|
+
:cvv => test_cvv,
|
45
|
+
:expiration_date => test_expiration_date,
|
46
|
+
:email => 'test@123.com',
|
47
|
+
:order_id => '4444444',
|
48
|
+
:free_text => free_text,
|
49
|
+
:first_name => 'Jacob',
|
50
|
+
:last_name => 'Smith',
|
51
|
+
:email => 'test@123.com',
|
52
|
+
:address => '123 home rd',
|
53
|
+
:address2 => 'Suite 3',
|
54
|
+
:city => 'Hollywood',
|
55
|
+
:state => 'FL',
|
56
|
+
:zip => '33019',
|
57
|
+
:phone => '5554443434',
|
58
|
+
:ip_address => '10.10.10.22',
|
59
|
+
:amount => 10.00,
|
60
|
+
:account_id => account_id,
|
61
|
+
:sub_account_id => sub_account_id,
|
62
|
+
:service_expiry_method => '',
|
63
|
+
:service_expiry_method_additional_info => ''
|
64
|
+
}
|
65
|
+
}
|
66
|
+
let(:recurring_payment_options) {
|
67
|
+
{
|
68
|
+
:recurring_payment => true,
|
69
|
+
:name_on_card => test_name_on_card,
|
70
|
+
:number => test_card_number,
|
71
|
+
:cvv => test_cvv,
|
72
|
+
:expiration_date => test_expiration_date,
|
73
|
+
:email => 'test@123.com',
|
74
|
+
:order_id => '4444444',
|
75
|
+
:free_text => free_text,
|
76
|
+
:first_name => 'Jacob',
|
77
|
+
:last_name => 'Smith',
|
78
|
+
:email => 'test@123.com',
|
79
|
+
:address => '123 home rd',
|
80
|
+
:address2 => 'Suite 3',
|
81
|
+
:city => 'Hollywood',
|
82
|
+
:state => 'FL',
|
83
|
+
:zip => '33019',
|
84
|
+
:phone => '5554443434',
|
85
|
+
:ip_address => '127.0.0.1',
|
86
|
+
:amount => 0,
|
87
|
+
:recurring_amount => 0,
|
88
|
+
:base_amount => 0,
|
89
|
+
:first_installment_amount => 0,
|
90
|
+
:initial_pre_auth_amount => 0,
|
91
|
+
:first_installment_interval => 0,
|
92
|
+
:recurring_installment_interval_method => 'Daily',
|
93
|
+
:recurring_installment_interval_additional_info => '',
|
94
|
+
:account_id => account_id,
|
95
|
+
:sub_account_id => sub_account_id,
|
96
|
+
:service_expiry_method => '',
|
97
|
+
:service_expiry_method_additional_info => ''
|
98
|
+
}
|
99
|
+
}
|
100
|
+
subject { ATPAY::Payment.new }
|
101
|
+
it "should initialize" do
|
102
|
+
subject.username.should == invalid_username
|
103
|
+
subject.password.should == invalid_password
|
104
|
+
subject.host.should == host
|
105
|
+
subject.first_name.should == ''
|
106
|
+
subject.last_name.should == ''
|
107
|
+
subject.email.should == ''
|
108
|
+
subject.address.should == ''
|
109
|
+
subject.address2.should == ''
|
110
|
+
subject.city.should == ''
|
111
|
+
subject.state.should == ''
|
112
|
+
subject.zip.should == ''
|
113
|
+
subject.phone.should == ''
|
114
|
+
subject.ip_address.should == '127.0.0.1'
|
115
|
+
subject.name_on_card.should == ''
|
116
|
+
subject.number.should == ''
|
117
|
+
subject.credit_card_type.should == 'Empty'
|
118
|
+
subject.cvv.should == ''
|
119
|
+
subject.expiration_date.should == ''
|
120
|
+
subject.amount.should == 0
|
121
|
+
subject.free_text.should == ''
|
122
|
+
subject.recurring_payment.should be_false
|
123
|
+
subject.base_amount.should == 0
|
124
|
+
subject.first_installment_amount.should == 0
|
125
|
+
subject.initial_pre_auth_amount.should == 0
|
126
|
+
subject.first_installment_interval.should == 0
|
127
|
+
subject.recurring_amount.should == 0
|
128
|
+
subject.recurring_installment_interval_method.should == 'Daily'
|
129
|
+
subject.recurring_installment_interval_method_additional_info.should == ''
|
130
|
+
subject.account_id.should == ''
|
131
|
+
subject.sub_account_id.should == ''
|
132
|
+
subject.service_expiry_method.should == ''
|
133
|
+
subject.service_expiry_method_additional_info.should == ''
|
134
|
+
subject.request.should == ''
|
135
|
+
subject.response.should == ''
|
136
|
+
subject.success.should be_false
|
137
|
+
subject.transaction_id.should == ''
|
138
|
+
end
|
139
|
+
it "should accept a payment request" do
|
140
|
+
subject.charge payment_options
|
141
|
+
subject.recurring_payment.should be_false
|
142
|
+
end
|
143
|
+
it "should default to standard payment" do
|
144
|
+
subject.charge payment_options
|
145
|
+
subject.recurring_payment.should be_false
|
146
|
+
subject.name_on_card.should == test_name_on_card
|
147
|
+
subject.number.should == test_card_number
|
148
|
+
subject.cvv.should == test_cvv
|
149
|
+
subject.expiration_date.should == test_expiration_date
|
150
|
+
subject.credit_card_type.should == 'Visa'
|
151
|
+
subject.email.should == 'test@123.com'
|
152
|
+
subject.order_id.should == '4444444'
|
153
|
+
subject.free_text.should == free_text
|
154
|
+
subject.first_name.should == 'Jacob'
|
155
|
+
subject.last_name.should == 'Smith'
|
156
|
+
subject.email.should == 'test@123.com'
|
157
|
+
subject.address.should == '123 home rd'
|
158
|
+
subject.address2.should == 'Suite 3'
|
159
|
+
subject.city.should == 'Hollywood'
|
160
|
+
subject.state.should == 'FL'
|
161
|
+
subject.zip.should == '33019'
|
162
|
+
subject.phone.should == '5554443434'
|
163
|
+
subject.ip_address.should == '10.10.10.22'
|
164
|
+
subject.amount.should == 10.00
|
165
|
+
subject.account_id.should == account_id
|
166
|
+
subject.sub_account_id.should == sub_account_id
|
167
|
+
subject.service_expiry_method.should == ''
|
168
|
+
subject.service_expiry_method_additional_info.should == ''
|
169
|
+
end
|
170
|
+
it "should accept a reccuring payment request" do
|
171
|
+
subject.charge recurring_payment_options
|
172
|
+
subject.recurring_payment.should be_true
|
173
|
+
end
|
174
|
+
it "invalid username or password should deny access" do
|
175
|
+
subject.charge(payment_options).should be_false
|
176
|
+
subject.response.code.should == 401
|
177
|
+
subject.error.should == 'Access is denied due to invalid credentials'
|
178
|
+
subject.transaction_id.should == ''
|
179
|
+
end
|
180
|
+
end
|
181
|
+
describe "Payment with valid data" do
|
182
|
+
let(:username) { ENV['ATPAY_USERNAME'] }
|
183
|
+
let(:password) { ENV['ATPAY_PASSWORD'] }
|
184
|
+
let(:host) { ENV['ATPAY_HOST'] }
|
185
|
+
let(:account_id) { ENV['ATPAY_TEST_ACCOUNT_ID'] }
|
186
|
+
let(:sub_account_id) { ENV['ATPAY_TEST_SUB_ACCOUNT_ID'] }
|
187
|
+
|
188
|
+
let(:test_name_on_card) { 'Test User' }
|
189
|
+
let(:test_card_number) { '4111111111111111' }
|
190
|
+
let(:test_cvv) { '400' }
|
191
|
+
let(:test_expiration_date) { '10/2013' }
|
192
|
+
|
193
|
+
let(:valid_name_on_card) { ENV['ATPAY_VALID_NAME_ON_CARD'] }
|
194
|
+
let(:valid_card_number) { ENV['ATPAY_VALID_CARD_NUMBER'] }
|
195
|
+
let(:valid_cvv) { ENV['ATPAY_VALID_CARD_CVV'] }
|
196
|
+
let(:valid_expiration_date) { ENV['ATPAY_VALID_CARD_EXPIRE_DATE'] }
|
197
|
+
|
198
|
+
let(:additional_params) {
|
199
|
+
{
|
200
|
+
:email => 'test@123.com',
|
201
|
+
:order_id => '4444444'
|
202
|
+
}
|
203
|
+
}
|
204
|
+
let(:free_text){
|
205
|
+
"Lead=3333; OPR=4000; AFF=1092; SKU=55555; EMAIL=test@123.com"
|
206
|
+
}
|
207
|
+
let(:payment_options) {
|
208
|
+
{
|
209
|
+
:name_on_card => test_name_on_card,
|
210
|
+
:number => test_card_number,
|
211
|
+
:cvv => test_cvv,
|
212
|
+
:expiration_date => test_expiration_date,
|
213
|
+
:email => 'test@123.com',
|
214
|
+
:order_id => '4444444',
|
215
|
+
:free_text => free_text,
|
216
|
+
:first_name => 'Jacob',
|
217
|
+
:last_name => 'Smith',
|
218
|
+
:email => 'test@123.com',
|
219
|
+
:address => '123 home rd',
|
220
|
+
:address2 => 'Suite 3',
|
221
|
+
:city => 'Hollywood',
|
222
|
+
:state => 'FL',
|
223
|
+
:zip => '33019',
|
224
|
+
:phone => '5554443434',
|
225
|
+
:ip_address => '10.10.10.22',
|
226
|
+
:amount => 10.00,
|
227
|
+
:account_id => account_id,
|
228
|
+
:sub_account_id => sub_account_id,
|
229
|
+
:service_expiry_method => 'NoEndDate',
|
230
|
+
:service_expiry_method_additional_info => ''
|
231
|
+
}
|
232
|
+
}
|
233
|
+
let(:recurring_payment_options) {
|
234
|
+
{
|
235
|
+
:recurring_payment => true,
|
236
|
+
:name_on_card => test_name_on_card,
|
237
|
+
:number => test_card_number,
|
238
|
+
:cvv => test_cvv,
|
239
|
+
:expiration_date => test_expiration_date,
|
240
|
+
:email => 'test@123.com',
|
241
|
+
:order_id => '4444444',
|
242
|
+
:free_text => free_text,
|
243
|
+
:first_name => 'Jacob',
|
244
|
+
:last_name => 'Smith',
|
245
|
+
:email => 'test@123.com',
|
246
|
+
:address => '123 home rd',
|
247
|
+
:address2 => 'Suite 3',
|
248
|
+
:city => 'Hollywood',
|
249
|
+
:state => 'FL',
|
250
|
+
:zip => '33019',
|
251
|
+
:phone => '5554443434',
|
252
|
+
:ip_address => '127.0.0.1',
|
253
|
+
:amount => 0,
|
254
|
+
:recurring_amount => 0,
|
255
|
+
:base_amount => 0,
|
256
|
+
:first_installment_amount => 0,
|
257
|
+
:initial_pre_auth_amount => 0,
|
258
|
+
:first_installment_interval => 0,
|
259
|
+
:recurring_installment_interval_method => 'Daily',
|
260
|
+
:recurring_installment_interval_additional_info => '',
|
261
|
+
:account_id => account_id,
|
262
|
+
:sub_account_id => sub_account_id,
|
263
|
+
:service_expiry_method => 'NoEndDate',
|
264
|
+
:service_expiry_method_additional_info => ''
|
265
|
+
}
|
266
|
+
}
|
267
|
+
before do
|
268
|
+
ATPAY.configure do |config|
|
269
|
+
config.username = username
|
270
|
+
config.password = password
|
271
|
+
config.host = host
|
272
|
+
end
|
273
|
+
end
|
274
|
+
subject { ATPAY::Payment.new }
|
275
|
+
it "valid request should return true with a transaction_id" do
|
276
|
+
payment_options[:name_on_card] = valid_name_on_card
|
277
|
+
payment_options[:number] = valid_card_number
|
278
|
+
payment_options[:cvv] = valid_cvv
|
279
|
+
payment_options[:expiration_date] = valid_expiration_date
|
280
|
+
response = subject.charge(payment_options)
|
281
|
+
response.should be_true
|
282
|
+
subject.transaction_id.should_not == ''
|
283
|
+
subject.error.should == ''
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'atpay'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
dev = File.join('config', 'development.yml')
|
12
|
+
YAML.load(File.open(dev)).each do |key, value|
|
13
|
+
ENV[key.to_s] = value
|
14
|
+
end if File.exists?(dev)
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atpay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paul Kruger
|
9
|
+
- Josh Toyota
|
10
|
+
- Dante Elrick
|
11
|
+
- Jon Turner
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
date: 2012-06-25 00:00:00.000000000Z
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: crack
|
19
|
+
requirement: &2161085780 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0'
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: *2161085780
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: httparty
|
30
|
+
requirement: &2161085300 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *2161085300
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: credit_card_validator
|
41
|
+
requirement: &2161084800 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *2161084800
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: activesupport
|
52
|
+
requirement: &2161084320 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *2161084320
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: &2161083840 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.8.0
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *2161083840
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rdoc
|
74
|
+
requirement: &2161083360 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '3.12'
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *2161083360
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: &2161082880 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.0.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: *2161082880
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: jeweler
|
96
|
+
requirement: &2161082380 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.8.3
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: *2161082380
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: debugger
|
107
|
+
requirement: &2161081840 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: *2161081840
|
116
|
+
description: Atpay.net payment class
|
117
|
+
email: devteam+pkruger+jtoyota@saveology.com
|
118
|
+
executables: []
|
119
|
+
extensions: []
|
120
|
+
extra_rdoc_files:
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
files:
|
124
|
+
- .document
|
125
|
+
- Gemfile
|
126
|
+
- LICENSE.txt
|
127
|
+
- README.md
|
128
|
+
- Rakefile
|
129
|
+
- VERSION
|
130
|
+
- atpay.gemspec
|
131
|
+
- config/development.example.yml
|
132
|
+
- lib/atpay.rb
|
133
|
+
- lib/atpay/payment.rb
|
134
|
+
- lib/atpay/request.xml.erb
|
135
|
+
- lib/atpay/successful_response.html
|
136
|
+
- spec/configure_spec.rb
|
137
|
+
- spec/payment_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
homepage: http://github.com/saveologypaul/atpay
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
153
|
+
- 0
|
154
|
+
hash: 1447726661468406198
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 1.8.17
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Atpay.net payment class
|
167
|
+
test_files: []
|