activemerchant 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +15 -0
- data/Rakefile +1 -1
- data/lib/active_merchant/billing/credit_card.rb +1 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +3 -3
- data/lib/active_merchant/billing/gateway.rb +12 -3
- data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
- data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1 -1
- data/lib/active_merchant/billing/gateways/data_cash.rb +1 -1
- data/lib/active_merchant/billing/gateways/linkpoint.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +4 -3
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +3 -15
- data/lib/active_merchant/billing/gateways/protx.rb +3 -3
- data/lib/active_merchant/billing/gateways/realex.rb +1 -1
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +155 -0
- data/lib/active_merchant/lib/country.rb +2 -1
- data/test/fixtures.yml +4 -0
- data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
- data/test/remote/gateways/remote_paypal_test.rb +7 -7
- data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
- data/test/unit/credit_card_test.rb +20 -3
- data/test/unit/gateways/gateway_test.rb +11 -1
- data/test/unit/gateways/payflow_test.rb +1 -1
- data/test/unit/gateways/paypal_test.rb +0 -20
- data/test/unit/gateways/secure_pay_au_test.rb +150 -0
- metadata +5 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
= ActiveMerchant CHANGELOG
|
2
2
|
|
3
|
+
== Version 1.3.2 (February 24, 2008)
|
4
|
+
|
5
|
+
* Actually fix the bug by adding extdata element to Payflow Requests [cody]
|
6
|
+
* Fix bug with adding name to Payflow requests [cody]
|
7
|
+
* Gateways will now look for CreditCard#brand before looking for CreditCard#type [cody]
|
8
|
+
* Make before_validate in CreditCard more clear [keith_du...@mac.com, cody]
|
9
|
+
* Don't send full Australian state names to PayPal [cody]
|
10
|
+
* Return last_digits that are less than 4 characters long [cody]
|
11
|
+
* Fix Bug with Authorize.Net ARB Remote Test [patrick.t.joyce]
|
12
|
+
* Add support for forcing test mode on Secure Pay AU gateway [cody]
|
13
|
+
* Update Secure Pay Au to meet specs for MessageInfo elements [cody]
|
14
|
+
* Add support for the Australian Secure Pay payment gateway [cody]
|
15
|
+
* Allow LinkPoint cancellations for recurring billing. [yanagimoto.shin]
|
16
|
+
* Add support for Åland Islands to the country list [cody]
|
17
|
+
|
3
18
|
== Version 1.3.1 (January 28, 2008)
|
4
19
|
|
5
20
|
* Rename BrainTreeGateway to BraintreeGateway, but keep alias to old naming for backwards compatibility [cody]
|
data/Rakefile
CHANGED
@@ -112,7 +112,7 @@ module ActiveMerchant #:nodoc:
|
|
112
112
|
def before_validate #:nodoc:
|
113
113
|
self.month = month.to_i
|
114
114
|
self.year = year.to_i
|
115
|
-
self.number.to_s.gsub
|
115
|
+
self.number = number.to_s.gsub(/[^\d]/, "")
|
116
116
|
self.type.downcase! if type.respond_to?(:downcase)
|
117
117
|
self.type = self.class.type?(number) if type.blank?
|
118
118
|
end
|
@@ -84,12 +84,12 @@ module ActiveMerchant #:nodoc:
|
|
84
84
|
return nil
|
85
85
|
end
|
86
86
|
|
87
|
-
def last_digits(number)
|
88
|
-
number.to_s.slice(-4..-1)
|
87
|
+
def last_digits(number)
|
88
|
+
number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
89
89
|
end
|
90
90
|
|
91
91
|
def mask(number)
|
92
|
-
"XXXX-XXXX-XXXX-#{last_digits(number)}"
|
92
|
+
"XXXX-XXXX-XXXX-#{last_digits(number)}"
|
93
93
|
end
|
94
94
|
|
95
95
|
# Checks to see if the calculated type matches the specified type
|
@@ -101,7 +101,16 @@ module ActiveMerchant #:nodoc:
|
|
101
101
|
# Use this method to check if your gateway of interest supports a credit card of some type
|
102
102
|
def self.supports?(card_type)
|
103
103
|
supported_cardtypes.include?(card_type.to_sym)
|
104
|
-
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.card_brand(source)
|
107
|
+
result = source.respond_to?(:brand) ? source.brand : source.type
|
108
|
+
result.to_s.downcase
|
109
|
+
end
|
110
|
+
|
111
|
+
def card_brand(source)
|
112
|
+
self.class.card_brand(source)
|
113
|
+
end
|
105
114
|
|
106
115
|
# Initialize a new gateway.
|
107
116
|
#
|
@@ -145,8 +154,8 @@ module ActiveMerchant #:nodoc:
|
|
145
154
|
end
|
146
155
|
|
147
156
|
def requires_start_date_or_issue_number?(credit_card)
|
148
|
-
return false if credit_card.
|
149
|
-
DEBIT_CARDS.include?(credit_card.
|
157
|
+
return false if card_brand(credit_card).blank?
|
158
|
+
DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
|
150
159
|
end
|
151
160
|
end
|
152
161
|
end
|
@@ -192,8 +192,8 @@ module ActiveMerchant #:nodoc:
|
|
192
192
|
def determine_funding_source(source)
|
193
193
|
case
|
194
194
|
when source.is_a?(String) then :vault
|
195
|
-
when CreditCard.card_companies.keys.include?(source
|
196
|
-
when source
|
195
|
+
when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
|
196
|
+
when card_brand(source) == 'check' then :check
|
197
197
|
else raise ArgumentError, "Unsupported funding source provided"
|
198
198
|
end
|
199
199
|
end
|
@@ -134,7 +134,7 @@ module ActiveMerchant #:nodoc:
|
|
134
134
|
add_pair(post, :TransactionUnique, options[:order_id], :required => true)
|
135
135
|
add_pair(post, :OrderDesc, options[:description] || options[:order_id], :required => true)
|
136
136
|
|
137
|
-
if [ 'american_express', 'diners_club' ].include?(credit_card.
|
137
|
+
if [ 'american_express', 'diners_club' ].include?(card_brand(credit_card).to_s)
|
138
138
|
add_pair(post, :AEIT1Quantity, 1)
|
139
139
|
add_pair(post, :AEIT1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
140
140
|
add_pair(post, :AEIT1GrossValue, amount(money))
|
@@ -159,7 +159,7 @@ module ActiveMerchant #:nodoc:
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def format_issue_number(credit_card)
|
162
|
-
credit_card.
|
162
|
+
card_brand(credit_card).to_s == 'solo' ? format(credit_card.issue_number, :two_digits) : credit_card.issue_number
|
163
163
|
end
|
164
164
|
|
165
165
|
def commit(action, parameters)
|
@@ -270,7 +270,7 @@ module ActiveMerchant #:nodoc:
|
|
270
270
|
xml.tag! 'expirationMonth', format(creditcard.month, :two_digits)
|
271
271
|
xml.tag! 'expirationYear', format(creditcard.year, :four_digits)
|
272
272
|
xml.tag!('cvNumber', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? )
|
273
|
-
xml.tag! 'cardType', @@credit_card_codes[creditcard.
|
273
|
+
xml.tag! 'cardType', @@credit_card_codes[card_brand(creditcard).to_sym]
|
274
274
|
end
|
275
275
|
end
|
276
276
|
|
@@ -275,7 +275,7 @@ module ActiveMerchant
|
|
275
275
|
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
|
276
276
|
|
277
277
|
# optional values - for Solo etc
|
278
|
-
if [ 'switch', 'solo' ].include?(credit_card.
|
278
|
+
if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
|
279
279
|
|
280
280
|
xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?
|
281
281
|
|
@@ -144,7 +144,7 @@ module ActiveMerchant #:nodoc:
|
|
144
144
|
|
145
145
|
options.update(
|
146
146
|
:ordertype => "SALE",
|
147
|
-
:action => "SUBMIT",
|
147
|
+
:action => options[:action] || "SUBMIT",
|
148
148
|
:installments => options[:installments] || 12,
|
149
149
|
:startdate => options[:startdate] || "immediate",
|
150
150
|
:periodicity => options[:periodicity].to_s || "monthly",
|
@@ -126,20 +126,21 @@ module ActiveMerchant #:nodoc:
|
|
126
126
|
xml.tag! 'CardType', credit_card_type(credit_card)
|
127
127
|
xml.tag! 'CardNum', credit_card.number
|
128
128
|
xml.tag! 'ExpDate', expdate(credit_card)
|
129
|
-
xml.tag! 'NameOnCard', credit_card.
|
129
|
+
xml.tag! 'NameOnCard', credit_card.first_name
|
130
130
|
xml.tag! 'CVNum', credit_card.verification_value if credit_card.verification_value?
|
131
131
|
|
132
132
|
if requires_start_date_or_issue_number?(credit_card)
|
133
133
|
xml.tag!('ExtData', 'Name' => 'CardStart', 'Value' => startdate(credit_card)) unless credit_card.start_month.blank? || credit_card.start_year.blank?
|
134
134
|
xml.tag!('ExtData', 'Name' => 'CardIssue', 'Value' => format(credit_card.issue_number, :two_digits)) unless credit_card.issue_number.blank?
|
135
135
|
end
|
136
|
+
xml.tag! 'ExtData', 'Name' => 'LASTNAME', 'Value' => credit_card.last_name
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
139
140
|
def credit_card_type(credit_card)
|
140
|
-
return '' if credit_card.
|
141
|
+
return '' if card_brand(credit_card).blank?
|
141
142
|
|
142
|
-
CARD_MAPPING[credit_card.
|
143
|
+
CARD_MAPPING[card_brand(credit_card).to_sym]
|
143
144
|
end
|
144
145
|
|
145
146
|
def expdate(creditcard)
|
@@ -128,7 +128,7 @@ module ActiveMerchant #:nodoc:
|
|
128
128
|
def add_address(xml, tag, address, options)
|
129
129
|
return if address.nil?
|
130
130
|
xml.tag! tag do
|
131
|
-
xml.tag! 'Name', address[:name] unless
|
131
|
+
xml.tag! 'Name', address[:name] unless address[:name].blank?
|
132
132
|
xml.tag! 'EMail', options[:email] unless options[:email].blank?
|
133
133
|
xml.tag! 'Phone', address[:phone] unless address[:phone].blank?
|
134
134
|
xml.tag! 'CustCode', options[:customer] if !options[:customer].blank? && tag == 'BillTo'
|
@@ -200,7 +200,7 @@ module ActiveMerchant #:nodoc:
|
|
200
200
|
headers = build_headers(request.size)
|
201
201
|
|
202
202
|
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request, headers))
|
203
|
-
|
203
|
+
|
204
204
|
build_response(response[:result] == "0", response[:message], response,
|
205
205
|
:test => test?,
|
206
206
|
:authorization => response[:pn_ref] || response[:rp_ref],
|
@@ -65,13 +65,13 @@ module ActiveMerchant #:nodoc:
|
|
65
65
|
|
66
66
|
def add_credit_card(xml, credit_card, address, options)
|
67
67
|
xml.tag! 'n2:CreditCard' do
|
68
|
-
xml.tag! 'n2:CreditCardType', credit_card_type(credit_card
|
68
|
+
xml.tag! 'n2:CreditCardType', credit_card_type(card_brand(credit_card))
|
69
69
|
xml.tag! 'n2:CreditCardNumber', credit_card.number
|
70
70
|
xml.tag! 'n2:ExpMonth', format(credit_card.month, :two_digits)
|
71
71
|
xml.tag! 'n2:ExpYear', format(credit_card.year, :four_digits)
|
72
72
|
xml.tag! 'n2:CVV2', credit_card.verification_value
|
73
73
|
|
74
|
-
if [ 'switch', 'solo' ].include?(credit_card.
|
74
|
+
if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
|
75
75
|
xml.tag! 'n2:StartMonth', format(credit_card.start_month, :two_digits) unless credit_card.start_month.blank?
|
76
76
|
xml.tag! 'n2:StartYear', format(credit_card.start_year, :four_digits) unless credit_card.start_year.blank?
|
77
77
|
xml.tag! 'n2:IssueNumber', format(credit_card.issue_number, :two_digits) unless credit_card.issue_number.blank?
|
@@ -122,7 +122,7 @@ module ActiveMerchant #:nodoc:
|
|
122
122
|
xml.target!
|
123
123
|
end
|
124
124
|
|
125
|
-
def build_capture_request(money, authorization, options)
|
125
|
+
def build_capture_request(money, authorization, options)
|
126
126
|
xml = Builder::XmlMarkup.new :indent => 2
|
127
127
|
|
128
128
|
xml.tag! 'DoCaptureReq', 'xmlns' => PAYPAL_NAMESPACE do
|
@@ -168,7 +168,7 @@ module ActiveMerchant #:nodoc:
|
|
168
168
|
xml.target!
|
169
169
|
end
|
170
170
|
|
171
|
-
def build_mass_pay_request(*args)
|
171
|
+
def build_mass_pay_request(*args)
|
172
172
|
default_options = args.last.is_a?(Hash) ? args.pop : {}
|
173
173
|
recipients = args.first.is_a?(Array) ? args : [args]
|
174
174
|
|
@@ -269,25 +269,13 @@ module ActiveMerchant #:nodoc:
|
|
269
269
|
xml.tag! 'n2:Street1', address[:address1]
|
270
270
|
xml.tag! 'n2:Street2', address[:address2]
|
271
271
|
xml.tag! 'n2:CityName', address[:city]
|
272
|
-
xml.tag! 'n2:StateOrProvince',
|
272
|
+
xml.tag! 'n2:StateOrProvince', address[:state].blank? ? 'N/A' : address[:state]
|
273
273
|
xml.tag! 'n2:Country', address[:country]
|
274
274
|
xml.tag! 'n2:PostalCode', address[:zip]
|
275
275
|
xml.tag! 'n2:Phone', address[:phone]
|
276
276
|
end
|
277
277
|
end
|
278
278
|
|
279
|
-
def lookup_state(address)
|
280
|
-
country = Country.find(address[:country]) rescue nil
|
281
|
-
return '' if country.nil?
|
282
|
-
|
283
|
-
case country.code(:alpha2).to_s
|
284
|
-
when 'AU'
|
285
|
-
AUSTRALIAN_STATES[address[:state]] || address[:state]
|
286
|
-
else
|
287
|
-
address[:state].blank? ? 'N/A' : address[:state]
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
279
|
def endpoint_url
|
292
280
|
URLS[test? ? :test : :live][@options[:signature].blank? ? :certificate : :signature]
|
293
281
|
end
|
@@ -188,9 +188,9 @@ module ActiveMerchant #:nodoc:
|
|
188
188
|
end
|
189
189
|
|
190
190
|
def map_card_type(credit_card)
|
191
|
-
raise ArgumentError, "The credit card type must be provided" if credit_card.
|
191
|
+
raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
|
192
192
|
|
193
|
-
card_type = credit_card.
|
193
|
+
card_type = card_brand(credit_card).to_sym
|
194
194
|
|
195
195
|
# Check if it is an electron card
|
196
196
|
if card_type == :visa && credit_card.number =~ ELECTRON
|
@@ -209,7 +209,7 @@ module ActiveMerchant #:nodoc:
|
|
209
209
|
end
|
210
210
|
|
211
211
|
def format_issue_number(credit_card)
|
212
|
-
credit_card.
|
212
|
+
card_brand(credit_card).to_s == 'solo' ? format(credit_card.issue_number, :two_digits) : credit_card.issue_number
|
213
213
|
end
|
214
214
|
|
215
215
|
def commit(action, parameters)
|
@@ -107,7 +107,7 @@ module ActiveMerchant
|
|
107
107
|
xml.tag! 'card' do
|
108
108
|
xml.tag! 'number', credit_card.number
|
109
109
|
xml.tag! 'expdate', expiry_date(credit_card)
|
110
|
-
xml.tag! 'type', CARD_MAPPING[credit_card.
|
110
|
+
xml.tag! 'type', CARD_MAPPING[card_brand(credit_card).to_s]
|
111
111
|
xml.tag! 'chname', credit_card.name
|
112
112
|
xml.tag! 'issueno', credit_card.issue_number
|
113
113
|
|
@@ -0,0 +1,155 @@
|
|
1
|
+
require 'rexml/document'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
class SecurePayAuGateway < Gateway
|
6
|
+
API_VERSION = 'xml-4.2'
|
7
|
+
|
8
|
+
TEST_URL = 'https://www.securepay.com.au/test/payment'
|
9
|
+
LIVE_URL = 'https://www.securepay.com.au/xmlapi/payment'
|
10
|
+
|
11
|
+
self.supported_countries = ['AU']
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
13
|
+
|
14
|
+
# The homepage URL of the gateway
|
15
|
+
self.homepage_url = 'http://securepay.com.au'
|
16
|
+
|
17
|
+
# The name of the gateway
|
18
|
+
self.display_name = 'SecurePay'
|
19
|
+
|
20
|
+
class_inheritable_accessor :request_timeout
|
21
|
+
self.request_timeout = 60
|
22
|
+
|
23
|
+
self.money_format = :cents
|
24
|
+
self.default_currency = 'AUD'
|
25
|
+
|
26
|
+
# 0 Standard Payment
|
27
|
+
# 4 Refund
|
28
|
+
# 6 Client Reversal (Void)
|
29
|
+
# 10 Preauthorise
|
30
|
+
# 11 Preauth Complete (Advice)
|
31
|
+
TRANSACTIONS = {
|
32
|
+
:purchase => 0,
|
33
|
+
:authorization => 10,
|
34
|
+
:capture => 11,
|
35
|
+
:void => 6,
|
36
|
+
:credit => 4
|
37
|
+
}
|
38
|
+
|
39
|
+
def initialize(options = {})
|
40
|
+
requires!(options, :login, :password)
|
41
|
+
@options = options
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
def test?
|
46
|
+
@options[:test] || super
|
47
|
+
end
|
48
|
+
|
49
|
+
def purchase(money, credit_card, options = {})
|
50
|
+
commit :purchase, build_purchase_request(money, credit_card, options)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def build_purchase_request(money, credit_card, options)
|
56
|
+
xml = Builder::XmlMarkup.new
|
57
|
+
|
58
|
+
xml.tag! 'amount', amount(money)
|
59
|
+
xml.tag! 'currency', options[:currency] || currency(money)
|
60
|
+
xml.tag! 'purchaseOrderNo', options[:order_id].to_s.gsub(/[ ']/, '')
|
61
|
+
|
62
|
+
xml.tag! 'CreditCardInfo' do
|
63
|
+
xml.tag! 'cardNumber', credit_card.number
|
64
|
+
xml.tag! 'expiryDate', expdate(credit_card)
|
65
|
+
xml.tag! 'cvv', credit_card.verification_value if credit_card.verification_value?
|
66
|
+
end
|
67
|
+
|
68
|
+
xml.target!
|
69
|
+
end
|
70
|
+
|
71
|
+
def build_request(action, body)
|
72
|
+
xml = Builder::XmlMarkup.new
|
73
|
+
xml.instruct!
|
74
|
+
xml.tag! 'SecurePayMessage' do
|
75
|
+
xml.tag! 'MessageInfo' do
|
76
|
+
xml.tag! 'messageID', Utils.generate_unique_id.slice(0, 30)
|
77
|
+
xml.tag! 'messageTimestamp', generate_timestamp
|
78
|
+
xml.tag! 'timeoutValue', request_timeout
|
79
|
+
xml.tag! 'apiVersion', API_VERSION
|
80
|
+
end
|
81
|
+
|
82
|
+
xml.tag! 'MerchantInfo' do
|
83
|
+
xml.tag! 'merchantID', @options[:login]
|
84
|
+
xml.tag! 'password', @options[:password]
|
85
|
+
end
|
86
|
+
|
87
|
+
xml.tag! 'RequestType', 'Payment'
|
88
|
+
xml.tag! 'Payment' do
|
89
|
+
xml.tag! 'TxnList', "count" => 1 do
|
90
|
+
xml.tag! 'Txn', "ID" => 1 do
|
91
|
+
xml.tag! 'txnType', TRANSACTIONS[action]
|
92
|
+
xml.tag! 'txnSource', 23
|
93
|
+
xml << body
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
xml.target!
|
100
|
+
end
|
101
|
+
|
102
|
+
def commit(action, request)
|
103
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, build_request(action, request)))
|
104
|
+
|
105
|
+
Response.new(success?(response), message_from(response), response,
|
106
|
+
:test => test?,
|
107
|
+
:authorization => authorization_from(response)
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
def success?(response)
|
112
|
+
response[:response_code] == "00"
|
113
|
+
end
|
114
|
+
|
115
|
+
def authorization_from(response)
|
116
|
+
response[:txn_id]
|
117
|
+
end
|
118
|
+
|
119
|
+
def message_from(response)
|
120
|
+
response[:response_text] || response[:status_description]
|
121
|
+
end
|
122
|
+
|
123
|
+
def expdate(credit_card)
|
124
|
+
"#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
|
125
|
+
end
|
126
|
+
|
127
|
+
def parse(body)
|
128
|
+
xml = REXML::Document.new(body)
|
129
|
+
|
130
|
+
response = {}
|
131
|
+
|
132
|
+
xml.root.elements.to_a.each do |node|
|
133
|
+
parse_element(response, node)
|
134
|
+
end
|
135
|
+
|
136
|
+
response
|
137
|
+
end
|
138
|
+
|
139
|
+
def parse_element(response, node)
|
140
|
+
if node.has_elements?
|
141
|
+
node.elements.each{|element| parse_element(response, element) }
|
142
|
+
else
|
143
|
+
response[node.name.underscore.to_sym] = node.text
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# YYYYDDMMHHNNSSKKK000sOOO
|
148
|
+
def generate_timestamp
|
149
|
+
time = Time.now.utc
|
150
|
+
time.strftime("%Y%d%m%H%M%S#{time.usec}+000")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
@@ -63,7 +63,8 @@ module ActiveMerchant #:nodoc:
|
|
63
63
|
{ :alpha2 => 'AM', :name => 'Armenia', :alpha3 => 'ARM', :numeric => '051' },
|
64
64
|
{ :alpha2 => 'AW', :name => 'Aruba', :alpha3 => 'ABW', :numeric => '533' },
|
65
65
|
{ :alpha2 => 'AU', :name => 'Australia', :alpha3 => 'AUS', :numeric => '036' },
|
66
|
-
{ :alpha2 => 'AT', :name => 'Austria', :alpha3 => 'AUT', :numeric => '040' },
|
66
|
+
{ :alpha2 => 'AT', :name => 'Austria', :alpha3 => 'AUT', :numeric => '040' },
|
67
|
+
{ :alpha2 => 'AX', :name => 'Åland Islands', :alpha3 => 'ALA', :numeric => '248' },
|
67
68
|
{ :alpha2 => 'AZ', :name => 'Azerbaijan', :alpha3 => 'AZE', :numeric => '031' },
|
68
69
|
{ :alpha2 => 'BS', :name => 'Bahamas', :alpha3 => 'BHS', :numeric => '044' },
|
69
70
|
{ :alpha2 => 'BH', :name => 'Bahrain', :alpha3 => 'BHR', :numeric => '048' },
|
data/test/fixtures.yml
CHANGED
@@ -244,6 +244,10 @@ secure_pay_tech:
|
|
244
244
|
login: TESTDIGISPL1
|
245
245
|
password: d557591484cb2cd12bba445aba420d2c69cd6a88
|
246
246
|
|
247
|
+
secure_pay_au:
|
248
|
+
login:
|
249
|
+
password:
|
250
|
+
|
247
251
|
# Replace with your serial numbers for the skipjack test environment
|
248
252
|
skipjack:
|
249
253
|
login: X
|
@@ -129,7 +129,7 @@ class AuthorizeNetTest < Test::Unit::TestCase
|
|
129
129
|
subscription_id = response.authorization
|
130
130
|
|
131
131
|
assert response = @gateway.update_recurring(:subscription_id => subscription_id, :amount => @amount * 2)
|
132
|
-
assert_success response
|
132
|
+
assert_success response
|
133
133
|
|
134
134
|
assert response = @gateway.cancel_recurring(subscription_id)
|
135
135
|
assert_success response
|
@@ -7,11 +7,11 @@ class PaypalTest < Test::Unit::TestCase
|
|
7
7
|
@gateway = PaypalGateway.new(fixtures(:paypal_certificate))
|
8
8
|
|
9
9
|
@creditcard = CreditCard.new(
|
10
|
-
:type => "
|
10
|
+
:type => "visa",
|
11
11
|
:number => "4381258770269608", # Use a generated CC from the paypal Sandbox
|
12
12
|
:verification_value => "000",
|
13
13
|
:month => 1,
|
14
|
-
:year =>
|
14
|
+
:year => Time.now.year + 1,
|
15
15
|
:first_name => 'Fred',
|
16
16
|
:last_name => 'Brooks'
|
17
17
|
)
|
@@ -63,7 +63,7 @@ class PaypalTest < Test::Unit::TestCase
|
|
63
63
|
response = @gateway.authorize(@amount, @creditcard, @params)
|
64
64
|
assert_success response
|
65
65
|
assert response.params['transaction_id']
|
66
|
-
assert_equal '
|
66
|
+
assert_equal '1.00', response.params['amount']
|
67
67
|
assert_equal 'USD', response.params['amount_currency_id']
|
68
68
|
end
|
69
69
|
|
@@ -100,7 +100,7 @@ class PaypalTest < Test::Unit::TestCase
|
|
100
100
|
response = @gateway.capture(@amount, auth.authorization)
|
101
101
|
assert_success response
|
102
102
|
assert response.params['transaction_id']
|
103
|
-
assert_equal '
|
103
|
+
assert_equal '1.00', response.params['gross_amount']
|
104
104
|
assert_equal 'USD', response.params['gross_amount_currency_id']
|
105
105
|
end
|
106
106
|
|
@@ -119,11 +119,11 @@ class PaypalTest < Test::Unit::TestCase
|
|
119
119
|
assert_success credit
|
120
120
|
assert credit.test?
|
121
121
|
assert_equal 'USD', credit.params['net_refund_amount_currency_id']
|
122
|
-
assert_equal '
|
122
|
+
assert_equal '0.67', credit.params['net_refund_amount']
|
123
123
|
assert_equal 'USD', credit.params['gross_refund_amount_currency_id']
|
124
|
-
assert_equal '
|
124
|
+
assert_equal '1.00', credit.params['gross_refund_amount']
|
125
125
|
assert_equal 'USD', credit.params['fee_refund_amount_currency_id']
|
126
|
-
assert_equal '0.
|
126
|
+
assert_equal '0.33', credit.params['fee_refund_amount']
|
127
127
|
end
|
128
128
|
|
129
129
|
def test_failed_voiding
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class RemoteSecurePayAuTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@gateway = SecurePayAuGateway.new(fixtures(:secure_pay_au))
|
7
|
+
|
8
|
+
@amount = 100
|
9
|
+
@credit_card = credit_card('4444333322221111')
|
10
|
+
|
11
|
+
@options = {
|
12
|
+
:order_id => '1',
|
13
|
+
:billing_address => address,
|
14
|
+
:description => 'Store Purchase'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_successful_purchase
|
19
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
20
|
+
assert_success response
|
21
|
+
assert_equal 'Approved', response.message
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_unsuccessful_purchase
|
25
|
+
@credit_card.year = '2005'
|
26
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
27
|
+
assert_failure response
|
28
|
+
assert_equal 'CARD EXPIRED', response.message
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_invalid_login
|
32
|
+
gateway = SecurePayAuGateway.new(
|
33
|
+
:login => '',
|
34
|
+
:password => ''
|
35
|
+
)
|
36
|
+
assert response = gateway.purchase(@amount, @credit_card, @options)
|
37
|
+
assert_failure response
|
38
|
+
assert_equal "Invalid merchant ID", response.message
|
39
|
+
end
|
40
|
+
end
|
@@ -162,9 +162,9 @@ class CreditCardTest < Test::Unit::TestCase
|
|
162
162
|
assert_equal 'XXXX-XXXX-XXXX-1234', CreditCard.new(:number => '111222233331234').display_number
|
163
163
|
assert_equal 'XXXX-XXXX-XXXX-1234', CreditCard.new(:number => '1112223331234').display_number
|
164
164
|
|
165
|
-
|
166
|
-
|
167
|
-
|
165
|
+
assert_equal 'XXXX-XXXX-XXXX-', CreditCard.new(:number => nil).display_number
|
166
|
+
assert_equal 'XXXX-XXXX-XXXX-', CreditCard.new(:number => '').display_number
|
167
|
+
assert_equal 'XXXX-XXXX-XXXX-123', CreditCard.new(:number => '123').display_number
|
168
168
|
assert_equal 'XXXX-XXXX-XXXX-1234', CreditCard.new(:number => '1234').display_number
|
169
169
|
assert_equal 'XXXX-XXXX-XXXX-1234', CreditCard.new(:number => '01234').display_number
|
170
170
|
end
|
@@ -222,6 +222,11 @@ class CreditCardTest < Test::Unit::TestCase
|
|
222
222
|
assert_equal "8580", ccn.last_digits
|
223
223
|
end
|
224
224
|
|
225
|
+
def test_bogus_last_digits
|
226
|
+
ccn = CreditCard.new(:number => "1")
|
227
|
+
assert_equal "1", ccn.last_digits
|
228
|
+
end
|
229
|
+
|
225
230
|
def test_should_be_true_when_credit_card_has_a_first_name
|
226
231
|
c = CreditCard.new
|
227
232
|
assert_false c.first_name?
|
@@ -291,4 +296,16 @@ class CreditCardTest < Test::Unit::TestCase
|
|
291
296
|
def test_mask_number
|
292
297
|
assert_equal 'XXXX-XXXX-XXXX-5100', CreditCard.mask('5105105105105100')
|
293
298
|
end
|
299
|
+
|
300
|
+
def test_strip_non_digit_characters
|
301
|
+
card = credit_card('4242-4242 %%%%%%4242......4242')
|
302
|
+
assert card.valid?
|
303
|
+
assert_equal "4242424242424242", card.number
|
304
|
+
end
|
305
|
+
|
306
|
+
def test_before_validate_handles_blank_number
|
307
|
+
card = credit_card(nil)
|
308
|
+
assert !card.valid?
|
309
|
+
assert_equal "", card.number
|
310
|
+
end
|
294
311
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../test_helper'
|
2
2
|
|
3
3
|
class Gateway < Test::Unit::TestCase
|
4
|
-
|
4
|
+
def test_should_detect_if_a_card_is_supported
|
5
5
|
Gateway.supported_cardtypes = [:visa, :bogus]
|
6
6
|
assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }
|
7
7
|
|
@@ -28,4 +28,14 @@ class Gateway < Test::Unit::TestCase
|
|
28
28
|
Gateway.new.send(:amount, '10.34')
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
def test_invalid_type
|
33
|
+
credit_card = stub(:type => "visa")
|
34
|
+
assert_equal "visa", Gateway.card_brand(credit_card)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_invalid_type
|
38
|
+
credit_card = stub(:type => "String", :brand => "visa")
|
39
|
+
assert_equal "visa", Gateway.card_brand(credit_card)
|
40
|
+
end
|
31
41
|
end
|
@@ -94,26 +94,6 @@ class PaypalTest < Test::Unit::TestCase
|
|
94
94
|
assert_equal '123456', express.options[:pem]
|
95
95
|
end
|
96
96
|
|
97
|
-
def test_successful_state_lookup
|
98
|
-
assert_equal 'AB', @gateway.send(:lookup_state, { :country => 'CA', :state => 'AB'})
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_lookup_unknown_state
|
102
|
-
assert_equal '', @gateway.send(:lookup_state, { :country => 'XX', :state => 'NA'})
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_lookup_uk_with_state
|
106
|
-
assert_equal 'Avon', @gateway.send(:lookup_state, { :country => 'United Kingdom', :state => 'Avon'})
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_lookup_uk_with_no_state
|
110
|
-
assert_equal 'N/A', @gateway.send(:lookup_state, { :country => 'GB', :state => '' })
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_lookup_australian_state
|
114
|
-
assert_equal 'Australian Capital Territory', @gateway.send(:lookup_state, { :country => 'AU', :state => 'ACT'} )
|
115
|
-
end
|
116
|
-
|
117
97
|
def test_supported_countries
|
118
98
|
assert_equal ['US'], PaypalGateway.supported_countries
|
119
99
|
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
+
|
3
|
+
class SecurePayAuTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@gateway = SecurePayAuGateway.new(
|
6
|
+
:login => 'login',
|
7
|
+
:password => 'password'
|
8
|
+
)
|
9
|
+
|
10
|
+
@credit_card = credit_card
|
11
|
+
@amount = 100
|
12
|
+
|
13
|
+
@options = {
|
14
|
+
:order_id => '1',
|
15
|
+
:billing_address => address,
|
16
|
+
:description => 'Store Purchase'
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_successful_purchase
|
21
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
22
|
+
|
23
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
24
|
+
assert_instance_of Response, response
|
25
|
+
assert_success response
|
26
|
+
|
27
|
+
assert_equal '024259', response.authorization
|
28
|
+
assert response.test?
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_unsuccessful_purchase
|
32
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
33
|
+
|
34
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
35
|
+
assert_instance_of Response, response
|
36
|
+
assert_failure response
|
37
|
+
assert response.test?
|
38
|
+
assert_equal "CARD EXPIRED", response.message
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_failed_login
|
42
|
+
@gateway.expects(:ssl_post).returns(failed_login_response)
|
43
|
+
|
44
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
45
|
+
assert_instance_of Response, response
|
46
|
+
assert_failure response
|
47
|
+
assert_equal "Invalid merchant ID", response.message
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def failed_login_response
|
53
|
+
'<SecurePayMessage><Status><statusCode>504</statusCode><statusDescription>Invalid merchant ID</statusDescription></Status></SecurePayMessage>'
|
54
|
+
end
|
55
|
+
|
56
|
+
def successful_purchase_response
|
57
|
+
<<-XML
|
58
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
59
|
+
<SecurePayMessage>
|
60
|
+
<MessageInfo>
|
61
|
+
<messageID>8af793f9af34bea0cf40f5fb5c630c</messageID>
|
62
|
+
<messageTimestamp>20080802041625665000+660</messageTimestamp>
|
63
|
+
<apiVersion>xml-4.2</apiVersion>
|
64
|
+
</MessageInfo>
|
65
|
+
<RequestType>Payment</RequestType>
|
66
|
+
<MerchantInfo>
|
67
|
+
<merchantID>XYZ0001</merchantID>
|
68
|
+
</MerchantInfo>
|
69
|
+
<Status>
|
70
|
+
<statusCode>000</statusCode>
|
71
|
+
<statusDescription>Normal</statusDescription>
|
72
|
+
</Status>
|
73
|
+
<Payment>
|
74
|
+
<TxnList count="1">
|
75
|
+
<Txn ID="1">
|
76
|
+
<txnType>0</txnType>
|
77
|
+
<txnSource>0</txnSource>
|
78
|
+
<amount>1000</amount>
|
79
|
+
<currency>AUD</currency>
|
80
|
+
<purchaseOrderNo>test</purchaseOrderNo>
|
81
|
+
<approved>Yes</approved>
|
82
|
+
<responseCode>00</responseCode>
|
83
|
+
<responseText>Approved</responseText>
|
84
|
+
<thinlinkResponseCode>100</thinlinkResponseCode>
|
85
|
+
<thinlinkResponseText>000</thinlinkResponseText>
|
86
|
+
<thinlinkEventStatusCode>000</thinlinkEventStatusCode>
|
87
|
+
<thinlinkEventStatusText>Normal</thinlinkEventStatusText>
|
88
|
+
<settlementDate>20080208</settlementDate>
|
89
|
+
<txnID>024259</txnID>
|
90
|
+
<CreditCardInfo>
|
91
|
+
<pan>424242...242</pan>
|
92
|
+
<expiryDate>07/11</expiryDate>
|
93
|
+
<cardType>6</cardType>
|
94
|
+
<cardDescription>Visa</cardDescription>
|
95
|
+
</CreditCardInfo>
|
96
|
+
</Txn>
|
97
|
+
</TxnList>
|
98
|
+
</Payment>
|
99
|
+
</SecurePayMessage>
|
100
|
+
|
101
|
+
XML
|
102
|
+
end
|
103
|
+
|
104
|
+
def failed_purchase_response
|
105
|
+
<<-XML
|
106
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
107
|
+
<SecurePayMessage>
|
108
|
+
<MessageInfo>
|
109
|
+
<messageID>8af793f9af34bea0cf40f5fb5c630c</messageID>
|
110
|
+
<messageTimestamp>20080802040346380000+660</messageTimestamp>
|
111
|
+
<apiVersion>xml-4.2</apiVersion>
|
112
|
+
</MessageInfo>
|
113
|
+
<RequestType>Payment</RequestType>
|
114
|
+
<MerchantInfo>
|
115
|
+
<merchantID>XYZ0001</merchantID>
|
116
|
+
</MerchantInfo>
|
117
|
+
<Status>
|
118
|
+
<statusCode>000</statusCode>
|
119
|
+
<statusDescription>Normal</statusDescription>
|
120
|
+
</Status>
|
121
|
+
<Payment>
|
122
|
+
<TxnList count="1">
|
123
|
+
<Txn ID="1">
|
124
|
+
<txnType>0</txnType>
|
125
|
+
<txnSource>0</txnSource>
|
126
|
+
<amount>1000</amount>
|
127
|
+
<currency>AUD</currency>
|
128
|
+
<purchaseOrderNo>test</purchaseOrderNo>
|
129
|
+
<approved>No</approved>
|
130
|
+
<responseCode>907</responseCode>
|
131
|
+
<responseText>CARD EXPIRED</responseText>
|
132
|
+
<thinlinkResponseCode>300</thinlinkResponseCode>
|
133
|
+
<thinlinkResponseText>000</thinlinkResponseText>
|
134
|
+
<thinlinkEventStatusCode>981</thinlinkEventStatusCode>
|
135
|
+
<thinlinkEventStatusText>Error - Expired Card</thinlinkEventStatusText>
|
136
|
+
<settlementDate> </settlementDate>
|
137
|
+
<txnID>000000</txnID>
|
138
|
+
<CreditCardInfo>
|
139
|
+
<pan>424242...242</pan>
|
140
|
+
<expiryDate>07/06</expiryDate>
|
141
|
+
<cardType>6</cardType>
|
142
|
+
<cardDescription>Visa</cardDescription>
|
143
|
+
</CreditCardInfo>
|
144
|
+
</Txn>
|
145
|
+
</TxnList>
|
146
|
+
</Payment>
|
147
|
+
</SecurePayMessage>
|
148
|
+
XML
|
149
|
+
end
|
150
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tobias Luetke
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
hPaSTyVU0yCSnw==
|
31
31
|
-----END CERTIFICATE-----
|
32
32
|
|
33
|
-
date: 2008-
|
33
|
+
date: 2008-02-24 00:00:00 -05:00
|
34
34
|
default_executable:
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/active_merchant/billing/gateways/quickpay.rb
|
109
109
|
- lib/active_merchant/billing/gateways/realex.rb
|
110
110
|
- lib/active_merchant/billing/gateways/secure_pay.rb
|
111
|
+
- lib/active_merchant/billing/gateways/secure_pay_au.rb
|
111
112
|
- lib/active_merchant/billing/gateways/secure_pay_tech.rb
|
112
113
|
- lib/active_merchant/billing/gateways/skip_jack.rb
|
113
114
|
- lib/active_merchant/billing/gateways/trans_first.rb
|
@@ -206,6 +207,7 @@ files:
|
|
206
207
|
- test/remote/gateways/remote_psl_card_test.rb
|
207
208
|
- test/remote/gateways/remote_quickpay_test.rb
|
208
209
|
- test/remote/gateways/remote_realex_test.rb
|
210
|
+
- test/remote/gateways/remote_secure_pay_au_test.rb
|
209
211
|
- test/remote/gateways/remote_secure_pay_tech_test.rb
|
210
212
|
- test/remote/gateways/remote_secure_pay_test.rb
|
211
213
|
- test/remote/gateways/remote_skipjack_test.rb
|
@@ -259,6 +261,7 @@ files:
|
|
259
261
|
- test/unit/gateways/psl_card_test.rb
|
260
262
|
- test/unit/gateways/quickpay_test.rb
|
261
263
|
- test/unit/gateways/realex_test.rb
|
264
|
+
- test/unit/gateways/secure_pay_au_test.rb
|
262
265
|
- test/unit/gateways/secure_pay_tech_test.rb
|
263
266
|
- test/unit/gateways/secure_pay_test.rb
|
264
267
|
- test/unit/gateways/skip_jack_test.rb
|
metadata.gz.sig
CHANGED
Binary file
|