tomriley-active_merchant 1.4.2.6 → 1.4.2.7
Sign up to get free protection for your applications and to get access to all the features.
data/active_merchant.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "active_merchant"
|
3
|
-
s.version = "1.4.2.
|
3
|
+
s.version = "1.4.2.7"
|
4
4
|
s.date = "2009-01-12"
|
5
5
|
s.summary = "Active Merchant is a simple payment abstraction library used in and sponsored by Shopify."
|
6
6
|
s.homepage = "http://www.activemerchant.org/"
|
@@ -112,8 +112,17 @@ module ActiveMerchant #:nodoc:
|
|
112
112
|
def before_validate #:nodoc:
|
113
113
|
self.month = month.to_i
|
114
114
|
self.year = year.to_i
|
115
|
-
|
116
|
-
|
115
|
+
# Set start date to nil unless user provided one
|
116
|
+
if !start_month.nil? && !start_month.blank?
|
117
|
+
self.start_month = start_month.to_i
|
118
|
+
else
|
119
|
+
self.start_month = nil
|
120
|
+
end
|
121
|
+
if !start_year.nil? && !start_year.blank?
|
122
|
+
self.start_year = start_year.to_i
|
123
|
+
else
|
124
|
+
self.start_year = nil
|
125
|
+
end
|
117
126
|
self.number = number.to_s.gsub(/[^\d]/, "")
|
118
127
|
self.type.downcase! if type.respond_to?(:downcase)
|
119
128
|
self.type = self.class.type?(number) if type.blank?
|
@@ -140,12 +149,9 @@ module ActiveMerchant #:nodoc:
|
|
140
149
|
end
|
141
150
|
|
142
151
|
def validate_switch_or_solo_attributes #:nodoc:
|
143
|
-
if
|
144
|
-
unless valid_month?(@start_month)
|
145
|
-
|
146
|
-
errors.add :start_year, "is invalid" unless valid_start_year?(@start_year)
|
147
|
-
errors.add :issue_number, "cannot be empty" unless valid_issue_number?(@issue_number)
|
148
|
-
end
|
152
|
+
if @start_month && @start_year
|
153
|
+
errors.add :start_month, "is invalid" unless valid_month?(@start_month)
|
154
|
+
errors.add :start_year, "is invalid" unless valid_start_year?(@start_year)
|
149
155
|
end
|
150
156
|
end
|
151
157
|
|
@@ -245,19 +245,17 @@ module ActiveMerchant #:nodoc:
|
|
245
245
|
add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
|
246
246
|
|
247
247
|
start_date = format_date(credit_card.start_month, credit_card.start_year)
|
248
|
-
|
248
|
+
if start_date
|
249
|
+
print "Adding StartDate #{start_date}\n"
|
250
|
+
add_pair(post, :StartDate, start_date)
|
251
|
+
end
|
249
252
|
|
250
253
|
unless credit_card.issue_number.blank?
|
251
254
|
issue_number = sprintf("%02d", credit_card.issue_number.to_i)
|
255
|
+
print "Adding IssueNumber #{issue_number}\n"
|
252
256
|
add_pair(post, :IssueNumber, issue_number)
|
253
257
|
end
|
254
258
|
|
255
|
-
#if requires_start_date_or_issue_number?(credit_card)
|
256
|
-
if credit_card.start_month && credit_card.start_year
|
257
|
-
add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
|
258
|
-
end
|
259
|
-
add_pair(post, :IssueNumber, credit_card.issue_number) if credit_card.issue_number
|
260
|
-
#end
|
261
259
|
add_pair(post, :CardType, map_card_type(credit_card))
|
262
260
|
|
263
261
|
add_pair(post, :CV2, credit_card.verification_value)
|
@@ -282,7 +280,7 @@ module ActiveMerchant #:nodoc:
|
|
282
280
|
|
283
281
|
# MMYY format
|
284
282
|
def format_date(month, year)
|
285
|
-
return nil if year.blank? || month.blank?
|
283
|
+
return nil if year.nil? || month.nil? || year.blank? || month.blank?
|
286
284
|
|
287
285
|
year = sprintf("%.4i", year)
|
288
286
|
month = sprintf("%.2i", month)
|