activemerchant 1.5.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +14 -0
- data/CONTRIBUTORS +4 -0
- data/lib/active_merchant.rb +1 -9
- data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +2 -2
- data/lib/active_merchant/billing/gateways/bogus.rb +12 -8
- data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +1 -1
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -0
- data/lib/active_merchant/billing/gateways/sage.rb +2 -2
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +3 -3
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/{lib → common}/connection.rb +2 -0
- data/lib/active_merchant/{lib → common}/country.rb +1 -1
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/{lib → common}/posts_data.rb +0 -0
- data/lib/active_merchant/{lib → common}/requires_parameters.rb +0 -0
- data/lib/active_merchant/{lib → common}/utils.rb +0 -0
- data/lib/active_merchant/{lib → common}/validateable.rb +0 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +50 -44
- data.tar.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +0 -736
- data/lib/active_merchant/lib/error.rb +0 -4
- data/lib/active_merchant/lib/post_data.rb +0 -22
- metadata.gz.sig +0 -3
@@ -0,0 +1,26 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
class ActiveMerchantError < StandardError #:nodoc:
|
3
|
+
end
|
4
|
+
|
5
|
+
class ConnectionError < ActiveMerchantError # :nodoc:
|
6
|
+
end
|
7
|
+
|
8
|
+
class RetriableConnectionError < ConnectionError # :nodoc:
|
9
|
+
end
|
10
|
+
|
11
|
+
class ResponseError < ActiveMerchantError # :nodoc:
|
12
|
+
attr_reader :response
|
13
|
+
|
14
|
+
def initialize(response, message = nil)
|
15
|
+
@response = response
|
16
|
+
@message = message
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class ClientCertificateError < ActiveMerchantError # :nodoc
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
class PostData < Hash
|
5
|
+
class_inheritable_accessor :required_fields, :instance_writer => false
|
6
|
+
self.required_fields = []
|
7
|
+
|
8
|
+
def []=(key, value)
|
9
|
+
return if value.blank? && !required?(key)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_post_data
|
14
|
+
collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :to_s, :to_post_data
|
18
|
+
|
19
|
+
private
|
20
|
+
def required?(key)
|
21
|
+
required_fields.include?(key)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_merchant'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
class OutboundHosts
|
5
|
+
def self.list
|
6
|
+
uris = Set.new
|
7
|
+
|
8
|
+
Dir['lib/**/*.rb'].each do |file|
|
9
|
+
content = File.read(file)
|
10
|
+
|
11
|
+
content.each_line do |line|
|
12
|
+
next if line =~ /homepage_url/
|
13
|
+
|
14
|
+
if line =~ /("|')(https:\/\/.*)("|')/
|
15
|
+
uri = URI.parse($2)
|
16
|
+
uris << [uri.host, uri.port]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
uris.each do |uri|
|
22
|
+
puts "#{uri.first} #{uri.last}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,58 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 6
|
9
|
+
- 0
|
10
|
+
version: 1.6.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Tobias Luetke
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain:
|
11
|
-
-
|
12
|
-
|
13
|
-
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRMwEQYDVQQDDApjb2R5
|
14
|
-
ZmF1c2VyMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNj
|
15
|
-
b20wHhcNMDcwMjIyMTcyMTI3WhcNMDgwMjIyMTcyMTI3WjBBMRMwEQYDVQQDDApj
|
16
|
-
b2R5ZmF1c2VyMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZ
|
17
|
-
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6T4Iqt5iWvAlU
|
18
|
-
iXI6L8UO0URQhIC65X/gJ9hL/x4lwSl/ckVm/R/bPrJGmifT+YooFv824N3y/TIX
|
19
|
-
25o/lZtRj1TUZJK4OCb0aVzosQVxBHSe6rLmxO8cItNTMOM9wn3thaITFrTa1DOQ
|
20
|
-
O3wqEjvW2L6VMozVfK1MfjL9IGgy0rCnl+2g4Gh4jDDpkLfnMG5CWI6cTCf3C1ye
|
21
|
-
ytOpWgi0XpOEy8nQWcFmt/KCQ/kFfzBo4QxqJi54b80842EyvzWT9OB7Oew/CXZG
|
22
|
-
F2yIHtiYxonz6N09vvSzq4CvEuisoUFLKZnktndxMEBKwJU3XeSHAbuS7ix40OKO
|
23
|
-
WKuI54fHAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
24
|
-
BBR9QQpefI3oDCAxiqJW/3Gg6jI6qjANBgkqhkiG9w0BAQUFAAOCAQEAs0lX26O+
|
25
|
-
HpyMp7WL+SgZuM8k76AjfOHuKajl2GEn3S8pWYGpsa0xu07HtehJhKLiavrfUYeE
|
26
|
-
qlFtyYMUyOh6/1S2vfkH6VqjX7mWjoi7XKHW/99fkMS40B5SbN+ypAUst+6c5R84
|
27
|
-
w390mjtLHpdDE6WQYhS6bFvBN53vK6jG3DLyCJc0K9uMQ7gdHWoxq7RnG92ncQpT
|
28
|
-
ThpRA+fky5Xt2Q63YJDnJpkYAz79QIama1enSnd4jslKzSl89JS2luq/zioPe/Us
|
29
|
-
hbyalWR1+HrhgPoSPq7nk+s2FQUBJ9UZFK1lgMzho/4fZgzJwbu+cO8SNuaLS/bj
|
30
|
-
hPaSTyVU0yCSnw==
|
31
|
-
-----END CERTIFICATE-----
|
32
|
-
|
33
|
-
date: 2010-02-14 00:00:00 -05:00
|
17
|
+
- gem-public_cert.pem
|
18
|
+
date: 2010-07-06 00:00:00 -04:00
|
34
19
|
default_executable:
|
35
20
|
dependencies:
|
36
21
|
- !ruby/object:Gem::Dependency
|
37
22
|
name: activesupport
|
38
|
-
|
39
|
-
|
40
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
41
26
|
requirements:
|
42
27
|
- - ">="
|
43
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 2
|
44
34
|
version: 2.3.2
|
45
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
46
37
|
- !ruby/object:Gem::Dependency
|
47
38
|
name: builder
|
48
|
-
|
49
|
-
|
50
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
51
42
|
requirements:
|
52
43
|
- - ">="
|
53
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 15
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 0
|
54
50
|
version: 2.0.0
|
55
|
-
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
56
53
|
description: Active Merchant is a simple payment abstraction library used in and sponsored by Shopify. It is written by Tobias Luetke, Cody Fauser, and contributors. The aim of the project is to feel natural to Ruby users and to abstract as many parts as possible away from the user to offer a consistent interface across all supported gateways.
|
57
54
|
email: tobi@leetsoft.com
|
58
55
|
executables: []
|
@@ -78,7 +75,6 @@ files:
|
|
78
75
|
- lib/active_merchant/billing/gateway.rb
|
79
76
|
- lib/active_merchant/billing/gateways/authorize_net.rb
|
80
77
|
- lib/active_merchant/billing/gateways/authorize_net_cim.rb
|
81
|
-
- lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig
|
82
78
|
- lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
|
83
79
|
- lib/active_merchant/billing/gateways/beanstream.rb
|
84
80
|
- lib/active_merchant/billing/gateways/beanstream_interac.rb
|
@@ -92,6 +88,7 @@ files:
|
|
92
88
|
- lib/active_merchant/billing/gateways/eway.rb
|
93
89
|
- lib/active_merchant/billing/gateways/exact.rb
|
94
90
|
- lib/active_merchant/billing/gateways/first_pay.rb
|
91
|
+
- lib/active_merchant/billing/gateways/garanti.rb
|
95
92
|
- lib/active_merchant/billing/gateways/instapay.rb
|
96
93
|
- lib/active_merchant/billing/gateways/jetpay.rb
|
97
94
|
- lib/active_merchant/billing/gateways/linkpoint.rb
|
@@ -182,17 +179,20 @@ files:
|
|
182
179
|
- lib/active_merchant/billing/integrations.rb
|
183
180
|
- lib/active_merchant/billing/response.rb
|
184
181
|
- lib/active_merchant/billing.rb
|
185
|
-
- lib/active_merchant/
|
186
|
-
- lib/active_merchant/
|
187
|
-
- lib/active_merchant/
|
188
|
-
- lib/active_merchant/
|
189
|
-
- lib/active_merchant/
|
190
|
-
- lib/active_merchant/
|
191
|
-
- lib/active_merchant/
|
192
|
-
- lib/active_merchant/
|
182
|
+
- lib/active_merchant/common/connection.rb
|
183
|
+
- lib/active_merchant/common/country.rb
|
184
|
+
- lib/active_merchant/common/error.rb
|
185
|
+
- lib/active_merchant/common/post_data.rb
|
186
|
+
- lib/active_merchant/common/posts_data.rb
|
187
|
+
- lib/active_merchant/common/requires_parameters.rb
|
188
|
+
- lib/active_merchant/common/utils.rb
|
189
|
+
- lib/active_merchant/common/validateable.rb
|
190
|
+
- lib/active_merchant/common.rb
|
193
191
|
- lib/active_merchant.rb
|
192
|
+
- lib/activemerchant.rb
|
194
193
|
- lib/certs/cacert.pem
|
195
194
|
- lib/support/gateway_support.rb
|
195
|
+
- lib/support/outbound_hosts.rb
|
196
196
|
has_rdoc: true
|
197
197
|
homepage: http://activemerchant.org/
|
198
198
|
licenses: []
|
@@ -203,21 +203,27 @@ rdoc_options: []
|
|
203
203
|
require_paths:
|
204
204
|
- lib
|
205
205
|
required_ruby_version: !ruby/object:Gem::Requirement
|
206
|
+
none: false
|
206
207
|
requirements:
|
207
208
|
- - ">="
|
208
209
|
- !ruby/object:Gem::Version
|
210
|
+
hash: 3
|
211
|
+
segments:
|
212
|
+
- 0
|
209
213
|
version: "0"
|
210
|
-
version:
|
211
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
none: false
|
212
216
|
requirements:
|
213
217
|
- - ">="
|
214
218
|
- !ruby/object:Gem::Version
|
219
|
+
hash: 3
|
220
|
+
segments:
|
221
|
+
- 0
|
215
222
|
version: "0"
|
216
|
-
version:
|
217
223
|
requirements: []
|
218
224
|
|
219
225
|
rubyforge_project: activemerchant
|
220
|
-
rubygems_version: 1.3.
|
226
|
+
rubygems_version: 1.3.7
|
221
227
|
signing_key:
|
222
228
|
specification_version: 3
|
223
229
|
summary: Framework and tools for dealing with credit card transactions.
|
data.tar.gz.sig
DELETED
Binary file
|
@@ -1,736 +0,0 @@
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
2
|
-
module Billing #:nodoc:
|
3
|
-
# ==== Customer Information Manager (CIM)
|
4
|
-
#
|
5
|
-
# The Authorize.Net Customer Information Manager (CIM) is an optional additional service that allows you to store sensitive payment information on
|
6
|
-
# Authorize.Net's servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI)
|
7
|
-
# Data Security Standard compliance, since customer data is no longer stored locally.
|
8
|
-
#
|
9
|
-
# To use the AuthorizeNetCimGateway CIM must be enabled for your account.
|
10
|
-
#
|
11
|
-
# Information about CIM is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/].
|
12
|
-
# Information about the CIM API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/]
|
13
|
-
#
|
14
|
-
# ==== Login and Password
|
15
|
-
#
|
16
|
-
# The login and password are not the username and password you use to
|
17
|
-
# login to the Authorize.Net Merchant Interface. Instead, you will
|
18
|
-
# use the API Login ID as the login and Transaction Key as the
|
19
|
-
# password.
|
20
|
-
#
|
21
|
-
# ==== How to Get Your API Login ID and Transaction Key
|
22
|
-
#
|
23
|
-
# 1. Log into the Merchant Interface
|
24
|
-
# 2. Select Settings from the Main Menu
|
25
|
-
# 3. Click on API Login ID and Transaction Key in the Security section
|
26
|
-
# 4. Type in the answer to the secret question configured on setup
|
27
|
-
# 5. Click Submit
|
28
|
-
class AuthorizeNetCimGateway < Gateway
|
29
|
-
|
30
|
-
class_inheritable_accessor :test_url, :live_url
|
31
|
-
|
32
|
-
self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
|
33
|
-
self.live_url = 'https://api.authorize.net/xml/v1/request.api'
|
34
|
-
|
35
|
-
AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
|
36
|
-
|
37
|
-
CIM_ACTIONS = {
|
38
|
-
:create_customer_profile => 'createCustomerProfile',
|
39
|
-
:create_customer_payment_profile => 'createCustomerPaymentProfile',
|
40
|
-
:create_customer_shipping_address => 'createCustomerShippingAddress',
|
41
|
-
:get_customer_profile => 'getCustomerProfile',
|
42
|
-
:get_customer_payment_profile => 'getCustomerPaymentProfile',
|
43
|
-
:get_customer_shipping_address => 'getCustomerShippingAddress',
|
44
|
-
:delete_customer_profile => 'deleteCustomerProfile',
|
45
|
-
:delete_customer_payment_profile => 'deleteCustomerPaymentProfile',
|
46
|
-
:delete_customer_shipping_address => 'deleteCustomerShippingAddress',
|
47
|
-
:update_customer_profile => 'updateCustomerProfile',
|
48
|
-
:update_customer_payment_profile => 'updateCustomerPaymentProfile',
|
49
|
-
:update_customer_shipping_address => 'updateCustomerShippingAddress',
|
50
|
-
:create_customer_profile_transaction => 'createCustomerProfileTransaction',
|
51
|
-
:validate_customer_payment_profile => 'validateCustomerPaymentProfile'
|
52
|
-
}
|
53
|
-
|
54
|
-
CIM_TRANSACTION_TYPES = {
|
55
|
-
:auth_capture => 'profileTransAuthCapture',
|
56
|
-
:auth_only => 'profileTransAuthOnly',
|
57
|
-
:capture_only => 'profileTransCaptureOnly'
|
58
|
-
}
|
59
|
-
|
60
|
-
CIM_VALIDATION_MODES = {
|
61
|
-
:none => 'none',
|
62
|
-
:test => 'testMode',
|
63
|
-
:live => 'liveMode'
|
64
|
-
}
|
65
|
-
|
66
|
-
BANK_ACCOUNT_TYPES = {
|
67
|
-
:checking => 'checking',
|
68
|
-
:savings => 'savings',
|
69
|
-
:business_checking => 'businessChecking'
|
70
|
-
}
|
71
|
-
|
72
|
-
ECHECK_TYPES = {
|
73
|
-
:ccd => 'CCD',
|
74
|
-
:ppd => 'PPD'
|
75
|
-
}
|
76
|
-
|
77
|
-
self.homepage_url = 'http://www.authorize.net/'
|
78
|
-
self.display_name = 'Authorize.Net CIM'
|
79
|
-
self.supported_countries = ['US']
|
80
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
81
|
-
|
82
|
-
# Creates a new AuthorizeNetCimGateway
|
83
|
-
#
|
84
|
-
# The gateway requires that a valid API Login ID and Transaction Key be passed
|
85
|
-
# in the +options+ hash.
|
86
|
-
#
|
87
|
-
# ==== Options
|
88
|
-
#
|
89
|
-
# * <tt>:login</tt> -- The Authorize.Net API Login ID (REQUIRED)
|
90
|
-
# * <tt>:password</tt> -- The Authorize.Net Transaction Key. (REQUIRED)
|
91
|
-
# * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
|
92
|
-
# Otherwise, perform transactions against the production server.
|
93
|
-
def initialize(options = {})
|
94
|
-
requires!(options, :login, :password)
|
95
|
-
@options = options
|
96
|
-
super
|
97
|
-
end
|
98
|
-
|
99
|
-
# Creates a new customer profile along with any customer payment profiles and customer shipping addresses
|
100
|
-
# for the customer profile.
|
101
|
-
#
|
102
|
-
# Returns a Response with the Customer Profile ID of the new customer profile in the authorization field.
|
103
|
-
# It is *CRITICAL* that you save this ID. There is no way to retrieve this through the API. You will not
|
104
|
-
# be able to create another Customer Profile with the same information.
|
105
|
-
#
|
106
|
-
# ==== Options
|
107
|
-
#
|
108
|
-
# TODO
|
109
|
-
def create_customer_profile(options)
|
110
|
-
# TODO Add requires
|
111
|
-
request = build_request(:create_customer_profile, options)
|
112
|
-
commit(:create_customer_profile, request)
|
113
|
-
end
|
114
|
-
|
115
|
-
# Creates a new customer payment profile for an existing customer profile.
|
116
|
-
#
|
117
|
-
# ==== Options
|
118
|
-
#
|
119
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
|
120
|
-
# * <tt>:payment_profile</tt> -- A hash containing the elements of the new payment profile (REQUIRED)
|
121
|
-
#
|
122
|
-
# ==== Payment Profile
|
123
|
-
#
|
124
|
-
# * <tt>:payment</tt> -- A hash containing information on payment. Either :credit_card or :bank_account (REQUIRED)
|
125
|
-
def create_customer_payment_profile(options)
|
126
|
-
requires!(options, :customer_profile_id)
|
127
|
-
requires!(options, :payment_profile)
|
128
|
-
requires!(options[:payment_profile], :payment)
|
129
|
-
|
130
|
-
request = build_request(:create_customer_payment_profile, options)
|
131
|
-
commit(:create_customer_payment_profile, request)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Creates a new customer shipping address for an existing customer profile.
|
135
|
-
#
|
136
|
-
# ==== Options
|
137
|
-
#
|
138
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer the payment profile will be added to. (REQUIRED)
|
139
|
-
# * <tt>:address</tt> -- A hash containing the elements of the shipping address (REQUIRED)
|
140
|
-
def create_customer_shipping_address(options)
|
141
|
-
requires!(options, :customer_profile_id)
|
142
|
-
requires!(options, :address)
|
143
|
-
|
144
|
-
request = build_request(:create_customer_shipping_address, options)
|
145
|
-
commit(:create_customer_shipping_address, request)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Deletes an existing customer profile along with all associated customer payment profiles and customer shipping addresses.
|
149
|
-
#
|
150
|
-
# ==== Options
|
151
|
-
#
|
152
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to be deleted. (REQUIRED)
|
153
|
-
def delete_customer_profile(options)
|
154
|
-
requires!(options, :customer_profile_id)
|
155
|
-
|
156
|
-
request = build_request(:delete_customer_profile, options)
|
157
|
-
commit(:delete_customer_profile, request)
|
158
|
-
end
|
159
|
-
|
160
|
-
# Deletes a customer payment profile from an existing customer profile.
|
161
|
-
#
|
162
|
-
# ==== Options
|
163
|
-
#
|
164
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
|
165
|
-
# * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be deleted. (REQUIRED)
|
166
|
-
def delete_customer_payment_profile(options)
|
167
|
-
requires!(options, :customer_profile_id)
|
168
|
-
requires!(options, :customer_payment_profile_id)
|
169
|
-
|
170
|
-
request = build_request(:delete_customer_payment_profile, options)
|
171
|
-
commit(:delete_customer_payment_profile, request)
|
172
|
-
end
|
173
|
-
|
174
|
-
# Deletes a customer shipping address from an existing customer profile.
|
175
|
-
#
|
176
|
-
# ==== Options
|
177
|
-
#
|
178
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be deleted. (REQUIRED)
|
179
|
-
# * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be deleted. (REQUIRED)
|
180
|
-
def delete_customer_shipping_address(options)
|
181
|
-
requires!(options, :customer_profile_id)
|
182
|
-
requires!(options, :customer_address_id)
|
183
|
-
|
184
|
-
request = build_request(:delete_customer_shipping_address, options)
|
185
|
-
commit(:delete_customer_shipping_address, request)
|
186
|
-
end
|
187
|
-
|
188
|
-
# Retrieves an existing customer profile along with all the associated customer payment profiles and customer shipping addresses.
|
189
|
-
#
|
190
|
-
# Returns a Response whose params hash contains all the profile information.
|
191
|
-
#
|
192
|
-
# ==== Options
|
193
|
-
#
|
194
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to retrieve. (REQUIRED)
|
195
|
-
def get_customer_profile(options)
|
196
|
-
requires!(options, :customer_profile_id)
|
197
|
-
|
198
|
-
request = build_request(:get_customer_profile, options)
|
199
|
-
commit(:get_customer_profile, request)
|
200
|
-
end
|
201
|
-
|
202
|
-
# Retrieve a customer payment profile for an existing customer profile.
|
203
|
-
#
|
204
|
-
# Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card
|
205
|
-
# numbers will be masked.
|
206
|
-
#
|
207
|
-
# ==== Options
|
208
|
-
#
|
209
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
|
210
|
-
# * <tt>:customer_payment_profile_id</tt> -- The Payment Profile ID of the payment profile to be retrieved. (REQUIRED)
|
211
|
-
def get_customer_payment_profile(options)
|
212
|
-
requires!(options, :customer_profile_id)
|
213
|
-
requires!(options, :customer_payment_profile_id)
|
214
|
-
|
215
|
-
request = build_request(:get_customer_payment_profile, options)
|
216
|
-
commit(:get_customer_payment_profile, request)
|
217
|
-
end
|
218
|
-
|
219
|
-
# Retrieve a customer shipping address for an existing customer profile.
|
220
|
-
#
|
221
|
-
# Returns a Response whose params hash contains all the shipping address information.
|
222
|
-
#
|
223
|
-
# ==== Options
|
224
|
-
#
|
225
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
|
226
|
-
# * <tt>:customer_address_id</tt> -- The Shipping Address ID of the shipping address to be retrieved. (REQUIRED)
|
227
|
-
def get_customer_shipping_address(options)
|
228
|
-
requires!(options, :customer_profile_id)
|
229
|
-
requires!(options, :customer_address_id)
|
230
|
-
|
231
|
-
request = build_request(:get_customer_shipping_address, options)
|
232
|
-
commit(:get_customer_shipping_address, request)
|
233
|
-
end
|
234
|
-
|
235
|
-
# Updates an existing customer profile.
|
236
|
-
#
|
237
|
-
# Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
|
238
|
-
# Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the
|
239
|
-
# elements you wish to change.
|
240
|
-
#
|
241
|
-
# ==== Options
|
242
|
-
#
|
243
|
-
# * <tt>:profile</tt> -- A hash containing the values the Customer Profile should be updated to. (REQUIRED)
|
244
|
-
#
|
245
|
-
# ==== Profile
|
246
|
-
#
|
247
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer profile to update. (REQUIRED)
|
248
|
-
def update_customer_profile(options)
|
249
|
-
requires!(options, :profile)
|
250
|
-
requires!(options[:profile], :customer_profile_id)
|
251
|
-
|
252
|
-
request = build_request(:update_customer_profile, options)
|
253
|
-
commit(:update_customer_profile, request)
|
254
|
-
end
|
255
|
-
|
256
|
-
# Updates a customer payment profile for an existing customer profile.
|
257
|
-
#
|
258
|
-
# Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
|
259
|
-
# Authorize.Net. You will most likely want to first get the profile hash using get_customer_payment_profile and then only
|
260
|
-
# change the elements you wish to change.
|
261
|
-
#
|
262
|
-
# ==== Options
|
263
|
-
#
|
264
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
|
265
|
-
# * <tt>:payment_profile</tt> -- A hash containing the values the Customer Payment Profile should be updated to. (REQUIRED)
|
266
|
-
#
|
267
|
-
# ==== Payment Profile
|
268
|
-
#
|
269
|
-
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
|
270
|
-
def update_customer_payment_profile(options)
|
271
|
-
requires!(options, :customer_profile_id, :payment_profile)
|
272
|
-
requires!(options[:payment_profile], :customer_payment_profile_id)
|
273
|
-
|
274
|
-
request = build_request(:update_customer_payment_profile, options)
|
275
|
-
commit(:update_customer_payment_profile, request)
|
276
|
-
end
|
277
|
-
|
278
|
-
# Updates a customer shipping address for an existing customer profile.
|
279
|
-
#
|
280
|
-
# Warning: if you do not provide a parameter in the <tt>:address</tt> hash, it is automatically set to nil at
|
281
|
-
# Authorize.Net. You will most likely want to first get the profile hash using get_customer_shipping_address and then only
|
282
|
-
# change the elements you wish to change.
|
283
|
-
#
|
284
|
-
# ==== Options
|
285
|
-
#
|
286
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
|
287
|
-
# * <tt>:address</tt> -- A hash containing the values the Customer Shipping Address should be updated to. (REQUIRED)
|
288
|
-
#
|
289
|
-
# ==== Address
|
290
|
-
#
|
291
|
-
# * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
|
292
|
-
def update_customer_shipping_address(options)
|
293
|
-
requires!(options, :customer_profile_id, :address)
|
294
|
-
requires!(options[:address], :customer_address_id)
|
295
|
-
|
296
|
-
request = build_request(:update_customer_shipping_address, options)
|
297
|
-
commit(:update_customer_shipping_address, request)
|
298
|
-
end
|
299
|
-
|
300
|
-
# Creates a new payment transaction from an existing customer profile
|
301
|
-
#
|
302
|
-
# This is what is used to charge a customer whose information you have stored in a Customer Profile.
|
303
|
-
#
|
304
|
-
# Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
|
305
|
-
#
|
306
|
-
# ==== Options
|
307
|
-
#
|
308
|
-
# * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
|
309
|
-
#
|
310
|
-
# ==== Transaction
|
311
|
-
#
|
312
|
-
# * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, or <tt>:auth_capture</tt>. (REQUIRED)
|
313
|
-
# * <tt>:amount</tt> -- The amount for the tranaction. Formatted with a decimal. For example "4.95" (REQUIRED)
|
314
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
|
315
|
-
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (REQUIRED)
|
316
|
-
def create_customer_profile_transaction(options)
|
317
|
-
requires!(options, :transaction)
|
318
|
-
requires!(options[:transaction], :type, :amount, :customer_profile_id, :customer_payment_profile_id)
|
319
|
-
|
320
|
-
request = build_request(:create_customer_profile_transaction, options)
|
321
|
-
commit(:create_customer_profile_transaction, request)
|
322
|
-
end
|
323
|
-
|
324
|
-
# Verifies an existing customer payment profile by generating a test transaction
|
325
|
-
#
|
326
|
-
# Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
|
327
|
-
#
|
328
|
-
# ==== Options
|
329
|
-
#
|
330
|
-
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
|
331
|
-
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to be verified. (REQUIRED)
|
332
|
-
# * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Shipping Address to be verified.
|
333
|
-
# * <tt>:validation_mode</tt> -- <tt>:live</tt> or <tt>:test</tt> In Test Mode, only field validation is performed.
|
334
|
-
# In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.01. If successful, the transaction is immediately voided. (REQUIRED)
|
335
|
-
def validate_customer_payment_profile(options)
|
336
|
-
requires!(options, :customer_profile_id, :customer_payment_profile_id, :validation_mode)
|
337
|
-
|
338
|
-
request = build_request(:validate_customer_payment_profile, options)
|
339
|
-
commit(:validate_customer_payment_profile, request)
|
340
|
-
end
|
341
|
-
|
342
|
-
private
|
343
|
-
|
344
|
-
def expdate(credit_card)
|
345
|
-
sprintf('%04d-%02d', credit_card.year, credit_card.month)
|
346
|
-
end
|
347
|
-
|
348
|
-
def build_request(action, options = {})
|
349
|
-
unless CIM_ACTIONS.include?(action)
|
350
|
-
raise StandardError, "Invalid Customer Information Manager Action: #{action}"
|
351
|
-
end
|
352
|
-
|
353
|
-
xml = Builder::XmlMarkup.new(:indent => 2)
|
354
|
-
xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
|
355
|
-
xml.tag!("#{CIM_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_CIM_NAMESPACE) do
|
356
|
-
add_merchant_authentication(xml)
|
357
|
-
# Merchant-assigned reference ID for the request
|
358
|
-
xml.tag!('refId', options[:ref_id]) if options[:ref_id]
|
359
|
-
send("build_#{action}_request", xml, options)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
# Contains the merchant’s payment gateway account authentication information
|
364
|
-
def add_merchant_authentication(xml)
|
365
|
-
xml.tag!('merchantAuthentication') do
|
366
|
-
xml.tag!('name', @options[:login])
|
367
|
-
xml.tag!('transactionKey', @options[:password])
|
368
|
-
end
|
369
|
-
end
|
370
|
-
|
371
|
-
def build_create_customer_profile_request(xml, options)
|
372
|
-
add_profile(xml, options[:profile])
|
373
|
-
|
374
|
-
xml.target!
|
375
|
-
end
|
376
|
-
|
377
|
-
def build_create_customer_payment_profile_request(xml, options)
|
378
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
379
|
-
|
380
|
-
xml.tag!('paymentProfile') do
|
381
|
-
add_payment_profile(xml, options[:payment_profile])
|
382
|
-
end
|
383
|
-
|
384
|
-
xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
|
385
|
-
|
386
|
-
xml.target!
|
387
|
-
end
|
388
|
-
|
389
|
-
def build_create_customer_shipping_address_request(xml, options)
|
390
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
391
|
-
|
392
|
-
xml.tag!('address') do
|
393
|
-
add_address(xml, options[:address])
|
394
|
-
end
|
395
|
-
|
396
|
-
xml.target!
|
397
|
-
end
|
398
|
-
|
399
|
-
def build_delete_customer_profile_request(xml, options)
|
400
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
401
|
-
xml.target!
|
402
|
-
end
|
403
|
-
|
404
|
-
def build_delete_customer_payment_profile_request(xml, options)
|
405
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
406
|
-
xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
|
407
|
-
xml.target!
|
408
|
-
end
|
409
|
-
|
410
|
-
def build_delete_customer_shipping_address_request(xml, options)
|
411
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
412
|
-
xml.tag!('customerAddressId', options[:customer_address_id])
|
413
|
-
xml.target!
|
414
|
-
end
|
415
|
-
|
416
|
-
def build_get_customer_profile_request(xml, options)
|
417
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
418
|
-
xml.target!
|
419
|
-
end
|
420
|
-
|
421
|
-
def build_get_customer_payment_profile_request(xml, options)
|
422
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
423
|
-
xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
|
424
|
-
xml.target!
|
425
|
-
end
|
426
|
-
|
427
|
-
def build_get_customer_shipping_address_request(xml, options)
|
428
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
429
|
-
xml.tag!('customerAddressId', options[:customer_address_id])
|
430
|
-
xml.target!
|
431
|
-
end
|
432
|
-
|
433
|
-
def build_update_customer_profile_request(xml, options)
|
434
|
-
add_profile(xml, options[:profile], true)
|
435
|
-
|
436
|
-
xml.target!
|
437
|
-
end
|
438
|
-
|
439
|
-
def build_update_customer_payment_profile_request(xml, options)
|
440
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
441
|
-
|
442
|
-
xml.tag!('paymentProfile') do
|
443
|
-
add_payment_profile(xml, options[:payment_profile])
|
444
|
-
end
|
445
|
-
|
446
|
-
xml.target!
|
447
|
-
end
|
448
|
-
|
449
|
-
def build_update_customer_shipping_address_request(xml, options)
|
450
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
451
|
-
|
452
|
-
xml.tag!('address') do
|
453
|
-
add_address(xml, options[:address])
|
454
|
-
end
|
455
|
-
|
456
|
-
xml.target!
|
457
|
-
end
|
458
|
-
|
459
|
-
def build_create_customer_profile_transaction_request(xml, options)
|
460
|
-
add_transaction(xml, options[:transaction])
|
461
|
-
xml.tag!('extraOptions', "x_test_request=TRUE") if @options[:test]
|
462
|
-
|
463
|
-
xml.target!
|
464
|
-
end
|
465
|
-
|
466
|
-
def build_validate_customer_payment_profile_request(xml, options)
|
467
|
-
xml.tag!('customerProfileId', options[:customer_profile_id])
|
468
|
-
xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
|
469
|
-
xml.tag!('customerShippingAddressId', options[:customer_address_id]) if options[:customer_address_id]
|
470
|
-
xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
|
471
|
-
|
472
|
-
xml.target!
|
473
|
-
end
|
474
|
-
|
475
|
-
# :merchant_customer_id (Optional)
|
476
|
-
# :description (Optional)
|
477
|
-
# :email (Optional)
|
478
|
-
# :payment_profiles (Optional)
|
479
|
-
def add_profile(xml, profile, update = false)
|
480
|
-
xml.tag!('profile') do
|
481
|
-
# Merchant assigned ID for the customer. Up to 20 characters. (optional)
|
482
|
-
xml.tag!('merchantCustomerId', profile[:merchant_customer_id]) if profile[:merchant_customer_id]
|
483
|
-
# Description of the customer. Up to 255 Characters (optional)
|
484
|
-
xml.tag!('description', profile[:description]) if profile[:description]
|
485
|
-
# Email Address for the customer. Up to 255 Characters (optional)
|
486
|
-
xml.tag!('email', profile[:email]) if profile[:email]
|
487
|
-
|
488
|
-
if update
|
489
|
-
xml.tag!('customerProfileId', profile[:customer_profile_id])
|
490
|
-
else
|
491
|
-
add_payment_profiles(xml, profile[:payment_profiles]) if profile[:payment_profiles]
|
492
|
-
add_ship_to_list(xml, profile[:ship_to_list]) if profile[:ship_to_list]
|
493
|
-
end
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
def add_transaction(xml, transaction)
|
498
|
-
unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
|
499
|
-
raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
|
500
|
-
end
|
501
|
-
|
502
|
-
xml.tag!('transaction') do
|
503
|
-
xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
|
504
|
-
# The amount to be billed to the customer
|
505
|
-
xml.tag!('amount', transaction[:amount])
|
506
|
-
xml.tag!('customerProfileId', transaction[:customer_profile_id])
|
507
|
-
xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
|
508
|
-
xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
|
509
|
-
add_order(xml, transaction[:order]) if transaction[:order]
|
510
|
-
end
|
511
|
-
end
|
512
|
-
end
|
513
|
-
|
514
|
-
def add_order(xml, order)
|
515
|
-
xml.tag!('order') do
|
516
|
-
xml.tag!('invoiceNumber', order[:invoice_number]) if order[:invoice_number]
|
517
|
-
xml.tag!('description', order[:description]) if order[:description]
|
518
|
-
xml.tag!('purchaseOrderNumber', order[:purchase_order_number]) if order[:purchase_order_number]
|
519
|
-
end
|
520
|
-
end
|
521
|
-
|
522
|
-
def add_payment_profiles(xml, payment_profiles)
|
523
|
-
xml.tag!('paymentProfiles') do
|
524
|
-
add_payment_profile(xml, payment_profiles)
|
525
|
-
end
|
526
|
-
end
|
527
|
-
|
528
|
-
# :customer_type => 'individual or business', # Optional
|
529
|
-
# :bill_to => @address,
|
530
|
-
# :payment => @payment
|
531
|
-
def add_payment_profile(xml, payment_profile)
|
532
|
-
# 'individual' or 'business' (optional)
|
533
|
-
xml.tag!('customerType', payment_profile[:customer_type]) if payment_profile[:customer_type]
|
534
|
-
|
535
|
-
if payment_profile[:bill_to]
|
536
|
-
xml.tag!('billTo') do
|
537
|
-
add_address(xml, payment_profile[:bill_to])
|
538
|
-
end
|
539
|
-
end
|
540
|
-
|
541
|
-
if payment_profile[:payment]
|
542
|
-
xml.tag!('payment') do
|
543
|
-
add_credit_card(xml, payment_profile[:payment][:credit_card]) if payment_profile[:payment].has_key?(:credit_card)
|
544
|
-
add_bank_account(xml, payment_profile[:payment][:bank_account]) if payment_profile[:payment].has_key?(:bank_account)
|
545
|
-
add_drivers_license(xml, payment_profile[:payment][:drivers_license]) if payment_profile[:payment].has_key?(:drivers_license)
|
546
|
-
# This element is only required for Wells Fargo SecureSource eCheck.Net merchants
|
547
|
-
# The customer's Social Security Number or Tax ID
|
548
|
-
xml.tag!('taxId', payment_profile[:payment]) if payment_profile[:payment].has_key?(:tax_id)
|
549
|
-
end
|
550
|
-
end
|
551
|
-
|
552
|
-
xml.tag!('customerPaymentProfileId', payment_profile[:customer_payment_profile_id]) if payment_profile[:customer_payment_profile_id]
|
553
|
-
end
|
554
|
-
|
555
|
-
def add_ship_to_list(xml, ship_to_list)
|
556
|
-
xml.tag!('shipToList') do
|
557
|
-
add_address(xml, ship_to_list)
|
558
|
-
end
|
559
|
-
end
|
560
|
-
|
561
|
-
def add_address(xml, address)
|
562
|
-
xml.tag!('firstName', address[:first_name])
|
563
|
-
xml.tag!('lastName', address[:last_name])
|
564
|
-
xml.tag!('company', address[:company])
|
565
|
-
xml.tag!('address', address[:address1]) if address[:address1]
|
566
|
-
xml.tag!('address', address[:address]) if address[:address]
|
567
|
-
xml.tag!('city', address[:city])
|
568
|
-
xml.tag!('state', address[:state])
|
569
|
-
xml.tag!('zip', address[:zip])
|
570
|
-
xml.tag!('country', address[:country])
|
571
|
-
xml.tag!('phoneNumber', address[:phone_number]) if address[:phone_number]
|
572
|
-
xml.tag!('faxNumber', address[:fax_number]) if address[:fax_number]
|
573
|
-
|
574
|
-
xml.tag!('customerAddressId', address[:customer_address_id]) if address[:customer_address_id]
|
575
|
-
end
|
576
|
-
|
577
|
-
# Adds customer’s credit card information
|
578
|
-
# Note: This element should only be included
|
579
|
-
# when the payment method is credit card.
|
580
|
-
def add_credit_card(xml, credit_card)
|
581
|
-
return unless credit_card
|
582
|
-
xml.tag!('creditCard') do
|
583
|
-
# The credit card number used for payment of the subscription
|
584
|
-
xml.tag!('cardNumber', credit_card.number)
|
585
|
-
# The expiration date of the credit card used for the subscription
|
586
|
-
xml.tag!('expirationDate', expdate(credit_card))
|
587
|
-
xml.tag!('cardCode', credit_card.verification_value) if credit_card.verification_value?
|
588
|
-
end
|
589
|
-
end
|
590
|
-
|
591
|
-
# Adds customer’s bank account information
|
592
|
-
# Note: This element should only be included
|
593
|
-
# when the payment method is bank account.
|
594
|
-
def add_bank_account(xml, bank_account)
|
595
|
-
raise StandardError, "Invalid Bank Account Type: #{bank_account[:account_type]}" unless BANK_ACCOUNT_TYPES.include?(bank_account[:account_type])
|
596
|
-
raise StandardError, "Invalid eCheck Type: #{bank_account[:echeck_type]}" unless ECHECK_TYPES.include?(bank_account[:echeck_type])
|
597
|
-
|
598
|
-
xml.tag!('bankAccount') do
|
599
|
-
# The type of bank account
|
600
|
-
xml.tag!('accountType', BANK_ACCOUNT_TYPES[bank_account[:account_type]])
|
601
|
-
# The routing number of the customer’s bank
|
602
|
-
xml.tag!('routingNumber', bank_account[:routing_number])
|
603
|
-
# The bank account number
|
604
|
-
xml.tag!('accountNumber', bank_account[:account_number])
|
605
|
-
# The full name of the individual associated
|
606
|
-
# with the bank account number
|
607
|
-
xml.tag!('nameOnAccount', bank_account[:name_on_account])
|
608
|
-
# The type of electronic check transaction
|
609
|
-
xml.tag!('echeckType', ECHECK_TYPES[bank_account[:echeck_type]])
|
610
|
-
# The full name of the individual associated
|
611
|
-
# with the bank account number (optional)
|
612
|
-
xml.tag!('bankName', bank_account[:bank_name]) if bank_account[:bank_name]
|
613
|
-
end
|
614
|
-
end
|
615
|
-
|
616
|
-
# Adds customer’s driver's license information
|
617
|
-
# Note: This element is only required for
|
618
|
-
# Wells Fargo SecureSource eCheck.Net merchants
|
619
|
-
def add_drivers_license(xml, drivers_license)
|
620
|
-
xml.tag!('driversLicense') do
|
621
|
-
# The state of the customer's driver's license
|
622
|
-
# A valid two character state code
|
623
|
-
xml.tag!('state', drivers_license[:state])
|
624
|
-
# The customer’s driver's license number
|
625
|
-
xml.tag!('number', drivers_license[:number])
|
626
|
-
# The date of birth listed on the customer's driver's license
|
627
|
-
# YYYY-MM-DD
|
628
|
-
xml.tag!('dateOfBirth', drivers_license[:date_of_birth])
|
629
|
-
end
|
630
|
-
end
|
631
|
-
|
632
|
-
def commit(action, request)
|
633
|
-
url = test? ? test_url : live_url
|
634
|
-
xml = ssl_post(url, request, "Content-Type" => "text/xml")
|
635
|
-
|
636
|
-
response_params = parse(action, xml)
|
637
|
-
|
638
|
-
message = response_params['messages']['message']['text']
|
639
|
-
test_mode = test? || message =~ /Test Mode/
|
640
|
-
success = response_params['messages']['result_code'] == 'Ok'
|
641
|
-
|
642
|
-
response = Response.new(success, message, response_params,
|
643
|
-
:test => test_mode,
|
644
|
-
:authorization => response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil)
|
645
|
-
)
|
646
|
-
|
647
|
-
response.params['direct_response'] = parse_direct_response(response) if response.params['direct_response']
|
648
|
-
response
|
649
|
-
end
|
650
|
-
|
651
|
-
def parse_direct_response(response)
|
652
|
-
direct_response = {'raw' => response.params['direct_response']}
|
653
|
-
direct_response_fields = response.params['direct_response'].split(',')
|
654
|
-
|
655
|
-
direct_response.merge(
|
656
|
-
{
|
657
|
-
'response_code' => direct_response_fields[0],
|
658
|
-
'response_subcode' => direct_response_fields[1],
|
659
|
-
'response_reason_code' => direct_response_fields[2],
|
660
|
-
'message' => direct_response_fields[3],
|
661
|
-
'approval_code' => direct_response_fields[4],
|
662
|
-
'avs_response' => direct_response_fields[5],
|
663
|
-
'transaction_id' => direct_response_fields[6],
|
664
|
-
'invoice_number' => direct_response_fields[7],
|
665
|
-
'order_description' => direct_response_fields[8],
|
666
|
-
'amount' => direct_response_fields[9],
|
667
|
-
'method' => direct_response_fields[10],
|
668
|
-
'transaction_type' => direct_response_fields[11],
|
669
|
-
'customer_id' => direct_response_fields[12],
|
670
|
-
'first_name' => direct_response_fields[13],
|
671
|
-
'last_name' => direct_response_fields[14],
|
672
|
-
'company' => direct_response_fields[15],
|
673
|
-
'address' => direct_response_fields[16],
|
674
|
-
'city' => direct_response_fields[17],
|
675
|
-
'state' => direct_response_fields[18],
|
676
|
-
'zip_code' => direct_response_fields[19],
|
677
|
-
'country' => direct_response_fields[20],
|
678
|
-
'phone' => direct_response_fields[21],
|
679
|
-
'fax' => direct_response_fields[22],
|
680
|
-
'email_address' => direct_response_fields[23],
|
681
|
-
'ship_to_first_name' => direct_response_fields[24],
|
682
|
-
'ship_to_last_name' => direct_response_fields[25],
|
683
|
-
'ship_to_company' => direct_response_fields[26],
|
684
|
-
'ship_to_address' => direct_response_fields[27],
|
685
|
-
'ship_to_city' => direct_response_fields[28],
|
686
|
-
'ship_to_state' => direct_response_fields[29],
|
687
|
-
'ship_to_zip_code' => direct_response_fields[30],
|
688
|
-
'ship_to_country' => direct_response_fields[31],
|
689
|
-
'tax' => direct_response_fields[32],
|
690
|
-
'duty' => direct_response_fields[33],
|
691
|
-
'freight' => direct_response_fields[34],
|
692
|
-
'tax_exempt' => direct_response_fields[35],
|
693
|
-
'purchase_order_number' => direct_response_fields[36],
|
694
|
-
'md5_hash' => direct_response_fields[37],
|
695
|
-
'card_code' => direct_response_fields[38],
|
696
|
-
'cardholder_authentication_verification_response' => direct_response_fields[39]
|
697
|
-
}
|
698
|
-
)
|
699
|
-
end
|
700
|
-
|
701
|
-
def parse(action, xml)
|
702
|
-
xml = REXML::Document.new(xml)
|
703
|
-
root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
|
704
|
-
REXML::XPath.first(xml, "//ErrorResponse")
|
705
|
-
if root
|
706
|
-
response = parse_element(root)
|
707
|
-
end
|
708
|
-
|
709
|
-
response
|
710
|
-
end
|
711
|
-
|
712
|
-
def parse_element(node)
|
713
|
-
if node.has_elements?
|
714
|
-
response = {}
|
715
|
-
node.elements.each{ |e|
|
716
|
-
key = e.name.underscore
|
717
|
-
value = parse_element(e)
|
718
|
-
if response.has_key?(key)
|
719
|
-
if response[key].is_a?(Array)
|
720
|
-
response[key].push(value)
|
721
|
-
else
|
722
|
-
response[key] = [response[key], value]
|
723
|
-
end
|
724
|
-
else
|
725
|
-
response[key] = parse_element(e)
|
726
|
-
end
|
727
|
-
}
|
728
|
-
else
|
729
|
-
response = node.text
|
730
|
-
end
|
731
|
-
|
732
|
-
response
|
733
|
-
end
|
734
|
-
end
|
735
|
-
end
|
736
|
-
end
|