activemerchant 1.10.0 → 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +13 -0
- data/CONTRIBUTORS +12 -1
- data/README.rdoc +2 -0
- data/lib/active_merchant.rb +1 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +304 -0
- data/lib/active_merchant/billing/gateways/epay.rb +1 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +20 -11
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +1 -1
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +82 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +91 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/version.rb +1 -1
- metadata +13 -7
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
= ActiveMerchant CHANGELOG
|
2
2
|
|
3
|
+
== Version 1.11.0 (Feb 11, 2011)
|
4
|
+
|
5
|
+
* Bump dependency for activesupport from 2.3.2 to 2.3.8 [Soleone]
|
6
|
+
* Garanti: Normalize text in xml fields for non-standard characters [Selem Delul]
|
7
|
+
* Garanti: Make sure order number does not contain illegal characters [Soleone]
|
8
|
+
* Fix ActionView tests for ActiveSupport 3.0.4 [Soleone]
|
9
|
+
* DirecPay: Make address information editable by default [Soleone]
|
10
|
+
* Fix ePDQ credit to expect and handle full authorization [Nathaniel Talbott]
|
11
|
+
* Add Barclays ePDQ Gateway [Nathaniel Talbott]
|
12
|
+
* Add default fixture for Garanti and don't use fixture for Garanti [cody]
|
13
|
+
* Add cms param for ePay [ePay]
|
14
|
+
* Add Valitor Integration [Nathaniel Talbott]
|
15
|
+
|
3
16
|
== Version 1.10.0 (Jan 20, 2011)
|
4
17
|
|
5
18
|
* PayPal Express: Support returning payer phone number [Soleone]
|
data/CONTRIBUTORS
CHANGED
@@ -187,4 +187,15 @@ Quantum Gateway
|
|
187
187
|
|
188
188
|
BluePay Gateway
|
189
189
|
|
190
|
-
*
|
190
|
+
* Mel Sleight
|
191
|
+
* Refactored by Nathaniel Talbott
|
192
|
+
|
193
|
+
Valitor Integration (January 2011)
|
194
|
+
|
195
|
+
* Nathaniel Talbott
|
196
|
+
* Sponsored by Sævar Öfjörð Magnússon
|
197
|
+
|
198
|
+
Barclays ePDQ
|
199
|
+
|
200
|
+
* Original code by Rob W (rfwatson)
|
201
|
+
* Refactored by Nathaniel Talbott
|
data/README.rdoc
CHANGED
@@ -13,6 +13,7 @@ The {ActiveMerchant Wiki}[http://github.com/Shopify/active_merchant/wikis] conta
|
|
13
13
|
|
14
14
|
* {Authorize.Net CIM}[http://www.authorize.net/] - US
|
15
15
|
* {Authorize.Net}[http://www.authorize.net/] - US
|
16
|
+
* {Barclays ePDQ}[http://www.barclaycard.co.uk/business/accepting-payments/epdq-mpi/] - UK
|
16
17
|
* {Beanstream.com}[http://www.beanstream.com/] - CA
|
17
18
|
* {BluePay}[http://www.bluepay.com/] - US
|
18
19
|
* {Braintree}[http://www.braintreepaymentsolutions.com] - US
|
@@ -82,6 +83,7 @@ The {ActiveMerchant Wiki}[http://github.com/Shopify/active_merchant/wikis] conta
|
|
82
83
|
* {Nochex}[http://www.nochex.com]
|
83
84
|
* {PayPal Website Payments Standard}[https://www.paypal.com/cgi-bin/webscr?cmd=_wp-standard-overview-outside]
|
84
85
|
* {SagePay Form}[http://www.sagepay.com/products_services/sage_pay_go/integration/form]
|
86
|
+
* {Valitor}[http://www.valitor.is/] - IS
|
85
87
|
|
86
88
|
== Download
|
87
89
|
|
data/lib/active_merchant.rb
CHANGED
@@ -32,6 +32,7 @@ require 'active_support/core_ext/class/attribute_accessors'
|
|
32
32
|
require 'active_support/core_ext/class/delegating_attributes'
|
33
33
|
require 'active_support/core_ext/module/attribute_accessors'
|
34
34
|
require 'active_support/core_ext/kernel/requires'
|
35
|
+
require 'active_support/core_ext/module/deprecation'
|
35
36
|
require 'active_support/base64'
|
36
37
|
require 'active_support/secure_random'
|
37
38
|
|
@@ -0,0 +1,304 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class BarclaysEpdqGateway < Gateway
|
4
|
+
TEST_URL = 'https://secure2.mde.epdq.co.uk:11500'
|
5
|
+
LIVE_URL = 'https://secure2.epdq.co.uk:11500'
|
6
|
+
|
7
|
+
self.supported_countries = ['UK']
|
8
|
+
self.default_currency = 'GBP'
|
9
|
+
self.supported_cardtypes = [:visa, :master, :maestro, :switch ]
|
10
|
+
self.money_format = :cents
|
11
|
+
self.homepage_url = 'http://www.barclaycard.co.uk/business/accepting-payments/epdq-mpi/'
|
12
|
+
self.display_name = 'Barclays ePDQ'
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :login, :password, :client_id)
|
16
|
+
@options = options
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize(money, creditcard, options = {})
|
21
|
+
document = Document.new(self, @options) do
|
22
|
+
add_order_form(options[:order_id]) do
|
23
|
+
add_consumer(options) do
|
24
|
+
add_creditcard(creditcard)
|
25
|
+
end
|
26
|
+
add_transaction(:PreAuth, money)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
commit(document)
|
31
|
+
end
|
32
|
+
|
33
|
+
def purchase(money, creditcard, options = {})
|
34
|
+
# disable fraud checks if this is a repeat order:
|
35
|
+
if options[:payment_number] && (options[:payment_number] > 1)
|
36
|
+
no_fraud = true
|
37
|
+
else
|
38
|
+
no_fraud = options[:no_fraud]
|
39
|
+
end
|
40
|
+
document = Document.new(self, @options, :no_fraud => no_fraud) do
|
41
|
+
add_order_form(options[:order_id], options[:group_id]) do
|
42
|
+
add_consumer(options) do
|
43
|
+
add_creditcard(creditcard)
|
44
|
+
end
|
45
|
+
add_transaction(:Auth, money, options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
commit(document)
|
49
|
+
end
|
50
|
+
|
51
|
+
# authorization is your unique order ID, not the authorization
|
52
|
+
# code returned by ePDQ
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
document = Document.new(self, @options) do
|
55
|
+
add_order_form(authorization) do
|
56
|
+
add_transaction(:PostAuth, money)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
commit(document)
|
61
|
+
end
|
62
|
+
|
63
|
+
# authorization is your unique order ID, not the authorization
|
64
|
+
# code returned by ePDQ
|
65
|
+
def credit(money, creditcard_or_authorization, options = {})
|
66
|
+
if creditcard_or_authorization.is_a?(String)
|
67
|
+
credit_existing_order(money, creditcard_or_authorization, options)
|
68
|
+
else
|
69
|
+
credit_new_order(money, creditcard_or_authorization, options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def void(authorization, options = {})
|
74
|
+
document = Document.new(self, @options) do
|
75
|
+
add_order_form(authorization) do
|
76
|
+
add_transaction(:Void)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
commit(document)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
def credit_new_order(money, creditcard, options)
|
85
|
+
document = Document.new(self, @options) do
|
86
|
+
add_order_form do
|
87
|
+
add_consumer(options) do
|
88
|
+
add_creditcard(creditcard)
|
89
|
+
end
|
90
|
+
add_transaction(:Credit, money)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
commit(document)
|
95
|
+
end
|
96
|
+
|
97
|
+
def credit_existing_order(money, authorization, options)
|
98
|
+
order_id, _ = authorization.split(":")
|
99
|
+
document = Document.new(self, @options) do
|
100
|
+
add_order_form(order_id) do
|
101
|
+
add_transaction(:Credit, money)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
commit(document)
|
106
|
+
end
|
107
|
+
|
108
|
+
def parse(body)
|
109
|
+
parser = Parser.new(body)
|
110
|
+
response = parser.parse
|
111
|
+
Response.new(response[:success], response[:message], response,
|
112
|
+
:test => test?,
|
113
|
+
:authorization => response[:authorization],
|
114
|
+
:avs_result => response[:avsresponse],
|
115
|
+
:cvv_result => response[:cvv_result],
|
116
|
+
:order_id => response[:order_id],
|
117
|
+
:raw_response => response[:raw_response]
|
118
|
+
)
|
119
|
+
end
|
120
|
+
|
121
|
+
def commit(document)
|
122
|
+
url = (test? ? TEST_URL : LIVE_URL)
|
123
|
+
data = ssl_post(url, document.to_xml)
|
124
|
+
parse(data)
|
125
|
+
end
|
126
|
+
|
127
|
+
class Parser
|
128
|
+
def initialize(response)
|
129
|
+
@response = response
|
130
|
+
end
|
131
|
+
|
132
|
+
def parse
|
133
|
+
doc = REXML::Document.new(@response)
|
134
|
+
auth_type = find(doc, "//Transaction/Type").to_sym
|
135
|
+
|
136
|
+
message = find(doc, "//Message/Text")
|
137
|
+
if message.blank?
|
138
|
+
message = find(doc, "//Transaction/CardProcResp/CcReturnMsg")
|
139
|
+
end
|
140
|
+
|
141
|
+
case auth_type.to_sym
|
142
|
+
when :Credit, :Void
|
143
|
+
success = find(doc, "//CcReturnMsg") == "Approved."
|
144
|
+
else
|
145
|
+
success = find(doc, "//Transaction/AuthCode").present?
|
146
|
+
end
|
147
|
+
|
148
|
+
{
|
149
|
+
:success => success,
|
150
|
+
:message => message,
|
151
|
+
:authorization =>
|
152
|
+
[find(doc, "//OrderFormDoc/Id"), find(doc, "//Transaction/Id")].join(":"),
|
153
|
+
:avs_result => find(doc, "//Transaction/AvsRespCode"),
|
154
|
+
:cvv_result => find(doc, "//Transaction/Cvv2Resp"),
|
155
|
+
:order_id => find(doc, "//OrderFormDoc/Transaction/Id"),
|
156
|
+
:raw_response => @response
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
def find(doc, xpath)
|
161
|
+
REXML::XPath.first(doc, xpath).try(:text)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
class Document
|
166
|
+
attr_reader :type, :xml
|
167
|
+
|
168
|
+
PAYMENT_INTERVALS = {
|
169
|
+
:days => 'D',
|
170
|
+
:months => 'M'
|
171
|
+
}
|
172
|
+
|
173
|
+
EPDQ_CARD_TYPES = {
|
174
|
+
:visa => 1,
|
175
|
+
:master => 2,
|
176
|
+
:switch => 9,
|
177
|
+
:maestro => 10,
|
178
|
+
}
|
179
|
+
|
180
|
+
def initialize(gateway, options = {}, document_options = {}, &block)
|
181
|
+
@gateway = gateway
|
182
|
+
@options = options
|
183
|
+
@document_options = document_options
|
184
|
+
@xml = Builder::XmlMarkup.new(:indent => 2)
|
185
|
+
build(&block)
|
186
|
+
end
|
187
|
+
|
188
|
+
def to_xml
|
189
|
+
@xml.target!
|
190
|
+
end
|
191
|
+
|
192
|
+
def build(&block)
|
193
|
+
xml.instruct!(:xml, :version => '1.0')
|
194
|
+
xml.EngineDocList do
|
195
|
+
xml.DocVersion "1.0"
|
196
|
+
xml.EngineDoc do
|
197
|
+
xml.ContentType "OrderFormDoc"
|
198
|
+
xml.User do
|
199
|
+
xml.Name(@options[:login])
|
200
|
+
xml.Password(@options[:password])
|
201
|
+
xml.ClientId({ :DataType => "S32" }, @options[:client_id])
|
202
|
+
end
|
203
|
+
xml.Instructions do
|
204
|
+
if @document_options[:no_fraud]
|
205
|
+
xml.Pipeline "PaymentNoFraud"
|
206
|
+
else
|
207
|
+
xml.Pipeline "Payment"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
instance_eval(&block)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def add_order_form(order_id=nil, group_id=nil, &block)
|
216
|
+
xml.OrderFormDoc do
|
217
|
+
xml.Mode 'P'
|
218
|
+
xml.Id(order_id) if order_id
|
219
|
+
xml.GroupId(group_id) if group_id
|
220
|
+
instance_eval(&block)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def add_consumer(options=nil, &block)
|
225
|
+
xml.Consumer do
|
226
|
+
if options
|
227
|
+
xml.Email(options[:email]) if options[:email]
|
228
|
+
billing_address = options[:billing_address] || options[:address]
|
229
|
+
if billing_address
|
230
|
+
xml.BillTo do
|
231
|
+
xml.Location do
|
232
|
+
xml.Address do
|
233
|
+
xml.Street1 billing_address[:address1]
|
234
|
+
xml.Street2 billing_address[:address2]
|
235
|
+
xml.City billing_address[:city]
|
236
|
+
xml.StateProv billing_address[:state]
|
237
|
+
xml.PostalCode billing_address[:zip]
|
238
|
+
xml.Country billing_address[:country_code]
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
instance_eval(&block)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def add_creditcard(creditcard)
|
249
|
+
xml.PaymentMech do
|
250
|
+
xml.CreditCard do
|
251
|
+
xml.Type({ :DataType => 'S32' }, EPDQ_CARD_TYPES[creditcard.brand.to_sym])
|
252
|
+
xml.Number creditcard.number
|
253
|
+
xml.Expires({ :DataType => 'ExpirationDate', :Locale => 826 }, format_expiry_date(creditcard))
|
254
|
+
if creditcard.verification_value.present?
|
255
|
+
xml.Cvv2Indicator 1
|
256
|
+
xml.Cvv2Val creditcard.verification_value
|
257
|
+
else
|
258
|
+
xml.Cvv2Indicator 5
|
259
|
+
end
|
260
|
+
xml.IssueNum(creditcard.issue_number) if creditcard.issue_number.present?
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def add_transaction(auth_type, amount = nil, options = {})
|
266
|
+
@auth_type = auth_type
|
267
|
+
xml.Transaction do
|
268
|
+
xml.Type @auth_type.to_s
|
269
|
+
if options[:payment_number] && options[:payment_number] > 1
|
270
|
+
xml.CardholderPresentCode({ :DataType => 'S32' }, 8)
|
271
|
+
else
|
272
|
+
xml.CardholderPresentCode({ :DataType => 'S32' }, 7)
|
273
|
+
end
|
274
|
+
if options[:payment_number]
|
275
|
+
xml.PaymentNumber({ :DataType => 'S32' }, options[:payment_number])
|
276
|
+
end
|
277
|
+
if options[:total_payments]
|
278
|
+
xml.TotalNumberPayments({ :DataType => 'S32' }, options[:total_payments])
|
279
|
+
end
|
280
|
+
if amount
|
281
|
+
xml.CurrentTotals do
|
282
|
+
xml.Totals do
|
283
|
+
xml.Total({ :DataType => 'Money', :Currency => 826 }, amount)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
# date must be formatted MM/YY
|
291
|
+
def format_expiry_date(creditcard)
|
292
|
+
month_str = "%02d" % creditcard.month
|
293
|
+
if match = creditcard.year.to_s.match(/^\d{2}(\d{2})$/)
|
294
|
+
year_str = "%02d" % match[1].to_i
|
295
|
+
else
|
296
|
+
year_str = "%02d" % creditcard.year
|
297
|
+
end
|
298
|
+
"#{month_str}/#{year_str}"
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
@@ -247,6 +247,7 @@ module ActiveMerchant #:nodoc:
|
|
247
247
|
|
248
248
|
def authorize_post_data(params = {})
|
249
249
|
params[:language] = '2'
|
250
|
+
params[:cms] = 'activemerchant'
|
250
251
|
params[:accepturl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?accept=1'
|
251
252
|
params[:declineurl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?decline=1'
|
252
253
|
params[:merchantnumber] = @options[:login]
|
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
|
|
65
65
|
|
66
66
|
def build_xml_request(money, credit_card, options, &block)
|
67
67
|
card_number = credit_card.respond_to?(:number) ? credit_card.number : ''
|
68
|
-
hash_data = generate_hash_data(options[:order_id], @options[:terminal_id], card_number, amount(money), security_data)
|
68
|
+
hash_data = generate_hash_data(format_order_id(options[:order_id]), @options[:terminal_id], card_number, amount(money), security_data)
|
69
69
|
|
70
70
|
xml = Builder::XmlMarkup.new(:indent => 2)
|
71
71
|
xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
|
@@ -135,7 +135,7 @@ module ActiveMerchant #:nodoc:
|
|
135
135
|
|
136
136
|
def add_order_data(xml, options, &block)
|
137
137
|
xml.tag! 'Order' do
|
138
|
-
xml.tag! 'OrderID', options[:order_id]
|
138
|
+
xml.tag! 'OrderID', format_order_id(options[:order_id])
|
139
139
|
xml.tag! 'GroupID'
|
140
140
|
|
141
141
|
if block_given?
|
@@ -156,6 +156,11 @@ module ActiveMerchant #:nodoc:
|
|
156
156
|
format(value, :two_digits)
|
157
157
|
end
|
158
158
|
|
159
|
+
# OrderId field must be A-Za-z0-9_ format and max 36 char
|
160
|
+
def format_order_id(order_id)
|
161
|
+
order_id.to_s.gsub(/[^A-Za-z0-9_]/, '')[0...36]
|
162
|
+
end
|
163
|
+
|
159
164
|
def add_addresses(xml, options)
|
160
165
|
xml.tag! 'AddressList' do
|
161
166
|
if billing_address = options[:billing_address] || options[:address]
|
@@ -175,18 +180,22 @@ module ActiveMerchant #:nodoc:
|
|
175
180
|
end
|
176
181
|
|
177
182
|
def add_address(xml, address)
|
178
|
-
xml.tag! 'Name', address[:name]
|
183
|
+
xml.tag! 'Name', normalize(address[:name])
|
179
184
|
address_text = address[:address1]
|
180
|
-
address_text << " #{address[:address2]}" if address[:address2]
|
181
|
-
xml.tag! 'Text', address_text
|
182
|
-
xml.tag! 'City', address[:city]
|
183
|
-
xml.tag! 'District', address[:state]
|
185
|
+
address_text << " #{ address[:address2]}" if address[:address2]
|
186
|
+
xml.tag! 'Text', normalize(address_text)
|
187
|
+
xml.tag! 'City', normalize(address[:city])
|
188
|
+
xml.tag! 'District', normalize(address[:state])
|
184
189
|
xml.tag! 'PostalCode', address[:zip]
|
185
|
-
xml.tag! 'Country', address[:country]
|
186
|
-
xml.tag! 'Company', address[:company]
|
190
|
+
xml.tag! 'Country', normalize(address[:country])
|
191
|
+
xml.tag! 'Company', normalize(address[:company])
|
187
192
|
xml.tag! 'PhoneNumber', address[:phone].to_s.gsub(/[^0-9]/, '') if address[:phone]
|
188
193
|
end
|
189
|
-
|
194
|
+
|
195
|
+
def normalize(text)
|
196
|
+
ActiveSupport::Inflector.transliterate(text,'')
|
197
|
+
end
|
198
|
+
|
190
199
|
def add_transaction_data(xml, money, options)
|
191
200
|
xml.tag! 'Transaction' do
|
192
201
|
xml.tag! 'Type', options[:gvp_order_type]
|
@@ -207,7 +216,7 @@ module ActiveMerchant #:nodoc:
|
|
207
216
|
success = success?(response)
|
208
217
|
|
209
218
|
Response.new(success,
|
210
|
-
success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]})",
|
219
|
+
success ? 'Approved' : "Declined (Reason: #{response[:reason_code]} - #{response[:error_msg]} - #{response[:sys_err_msg]})",
|
211
220
|
response,
|
212
221
|
:test => test?,
|
213
222
|
:authorization => response[:order_id])
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
module Integrations #:nodoc:
|
4
|
+
module Valitor
|
5
|
+
autoload :Return, 'active_merchant/billing/integrations/valitor/return.rb'
|
6
|
+
autoload :Helper, 'active_merchant/billing/integrations/valitor/helper.rb'
|
7
|
+
autoload :Notification, 'active_merchant/billing/integrations/valitor/notification.rb'
|
8
|
+
|
9
|
+
mattr_accessor :test_url
|
10
|
+
self.test_url = 'https://testvefverslun.valitor.is/1_1/'
|
11
|
+
|
12
|
+
mattr_accessor :production_url
|
13
|
+
self.production_url = 'https://vefverslun.valitor.is/1_1/'
|
14
|
+
|
15
|
+
def self.test?
|
16
|
+
(ActiveMerchant::Billing::Base.integration_mode == :test)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.service_url
|
20
|
+
(test? ? test_url : production_url)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.notification(params, options={})
|
24
|
+
Notification.new(params, options.merge(:test => test?))
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.return(query_string, options={})
|
28
|
+
Return.new(query_string, options.merge(:test => test?))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Valitor
|
7
|
+
class Helper < ActiveMerchant::Billing::Integrations::Helper
|
8
|
+
include RequiresParameters
|
9
|
+
|
10
|
+
DEFAULT_SUCCESS_TEXT = "The transaction has been completed."
|
11
|
+
|
12
|
+
def initialize(order, account, options={})
|
13
|
+
options[:currency] ||= 'ISK'
|
14
|
+
super
|
15
|
+
add_field 'Adeinsheimild', '0'
|
16
|
+
add_field 'KaupandaUpplysingar', '0'
|
17
|
+
add_field 'SlokkvaHaus', '0'
|
18
|
+
@security_number = options[:credential2]
|
19
|
+
@amount = options[:amount]
|
20
|
+
@order = order
|
21
|
+
end
|
22
|
+
|
23
|
+
mapping :account, 'VefverslunID'
|
24
|
+
mapping :currency, 'Gjaldmidill'
|
25
|
+
|
26
|
+
mapping :order, 'Tilvisunarnumer'
|
27
|
+
|
28
|
+
mapping :notify_url, 'SlodTokstAdGjaldfaeraServerSide'
|
29
|
+
mapping :return_url, 'SlodTokstAdGjaldfaera'
|
30
|
+
mapping :cancel_return_url, 'SlodNotandiHaettirVid'
|
31
|
+
|
32
|
+
mapping :success_text, 'SlodTokstAdGjaldfaeraTexti'
|
33
|
+
|
34
|
+
mapping :language, 'Lang'
|
35
|
+
|
36
|
+
def authorize_only
|
37
|
+
add_field 'Adeinsheimild', '1'
|
38
|
+
end
|
39
|
+
|
40
|
+
def collect_customer_info
|
41
|
+
add_field 'KaupandaUpplysingar', '1'
|
42
|
+
end
|
43
|
+
|
44
|
+
def hide_header
|
45
|
+
add_field 'SlokkvaHaus', '1'
|
46
|
+
end
|
47
|
+
|
48
|
+
def product(id, options={})
|
49
|
+
raise ArgumentError, "Product id #{id} is not an integer between 1 and 500" unless id.to_i > 0 && id.to_i <= 500
|
50
|
+
requires!(options, :amount, :description)
|
51
|
+
options.assert_valid_keys([:description, :quantity, :amount, :discount])
|
52
|
+
|
53
|
+
add_field("Vara_#{id}_Verd", options[:amount])
|
54
|
+
add_field("Vara_#{id}_Fjoldi", options[:quantity] || "1")
|
55
|
+
|
56
|
+
add_field("Vara_#{id}_Lysing", options[:description]) if options[:description]
|
57
|
+
add_field("Vara_#{id}_Afslattur", options[:discount] || '0')
|
58
|
+
|
59
|
+
@products ||= []
|
60
|
+
@products << id.to_i
|
61
|
+
end
|
62
|
+
|
63
|
+
def signature
|
64
|
+
raise ArgumentError, "Security number not set" unless @security_number
|
65
|
+
parts = [@security_number, @fields['Adeinsheimild']]
|
66
|
+
@products.sort.uniq.each do |id|
|
67
|
+
parts.concat(["Vara_#{id}_Fjoldi", "Vara_#{id}_Verd", "Vara_#{id}_Afslattur"].collect{|e| @fields[e]})
|
68
|
+
end if @products
|
69
|
+
parts.concat(%w(VefverslunID Tilvisunarnumer SlodTokstAdGjaldfaera SlodTokstAdGjaldfaeraServerSide Gjaldmidill).collect{|e| @fields[e]})
|
70
|
+
Digest::MD5.hexdigest(parts.compact.join(''))
|
71
|
+
end
|
72
|
+
|
73
|
+
def form_fields
|
74
|
+
product(1, :amount => @amount, :description => @order) if Array(@products).empty?
|
75
|
+
@fields[mappings[:success_text]] ||= DEFAULT_SUCCESS_TEXT
|
76
|
+
@fields.merge('RafraenUndirskrift' => signature)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_merchant/billing/integrations/valitor/response_fields'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Valitor
|
7
|
+
class Notification < ActiveMerchant::Billing::Integrations::Notification
|
8
|
+
include ResponseFields
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Valitor
|
7
|
+
module ResponseFields
|
8
|
+
def success?
|
9
|
+
valid?
|
10
|
+
end
|
11
|
+
alias :complete? :success?
|
12
|
+
|
13
|
+
def test?
|
14
|
+
@options[:test]
|
15
|
+
end
|
16
|
+
|
17
|
+
def order
|
18
|
+
params['Tilvisunarnumer']
|
19
|
+
end
|
20
|
+
|
21
|
+
def received_at
|
22
|
+
params['Dagsetning']
|
23
|
+
end
|
24
|
+
|
25
|
+
def transaction_id
|
26
|
+
params['VefverslunSalaID']
|
27
|
+
end
|
28
|
+
|
29
|
+
def status
|
30
|
+
"OK"
|
31
|
+
end
|
32
|
+
|
33
|
+
def card_type
|
34
|
+
params['Kortategund']
|
35
|
+
end
|
36
|
+
|
37
|
+
def card_last_four
|
38
|
+
params['KortnumerSidustu']
|
39
|
+
end
|
40
|
+
|
41
|
+
def authorization_number
|
42
|
+
params['Heimildarnumer']
|
43
|
+
end
|
44
|
+
|
45
|
+
def transaction_number
|
46
|
+
params['Faerslunumer']
|
47
|
+
end
|
48
|
+
|
49
|
+
def customer_name
|
50
|
+
params['Nafn']
|
51
|
+
end
|
52
|
+
|
53
|
+
def customer_address
|
54
|
+
params['Heimilisfang']
|
55
|
+
end
|
56
|
+
|
57
|
+
def customer_zip
|
58
|
+
params['Postnumer']
|
59
|
+
end
|
60
|
+
|
61
|
+
def customer_city
|
62
|
+
params['Stadur']
|
63
|
+
end
|
64
|
+
|
65
|
+
def customer_country
|
66
|
+
params['Land']
|
67
|
+
end
|
68
|
+
|
69
|
+
def customer_email
|
70
|
+
params['Tolvupostfang']
|
71
|
+
end
|
72
|
+
|
73
|
+
def customer_comment
|
74
|
+
params['Athugasemdir']
|
75
|
+
end
|
76
|
+
|
77
|
+
def valid?
|
78
|
+
unless @valid
|
79
|
+
@valid = if(security_number = @options[:password])
|
80
|
+
(params['RafraenUndirskriftSvar'] == Digest::MD5.hexdigest("#{security_number}#{order}"))
|
81
|
+
else
|
82
|
+
true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
@valid
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'active_merchant/billing/integrations/valitor/response_fields'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
module Integrations #:nodoc:
|
6
|
+
module Valitor
|
7
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
8
|
+
include ResponseFields
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activemerchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
8
|
+
- 11
|
9
9
|
- 0
|
10
|
-
version: 1.
|
10
|
+
version: 1.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tobias Luetke
|
@@ -36,7 +36,7 @@ cert_chain:
|
|
36
36
|
hPaSTyVU0yCSnw==
|
37
37
|
-----END CERTIFICATE-----
|
38
38
|
|
39
|
-
date: 2011-
|
39
|
+
date: 2011-02-14 00:00:00 +01:00
|
40
40
|
default_executable:
|
41
41
|
dependencies:
|
42
42
|
- !ruby/object:Gem::Dependency
|
@@ -47,12 +47,12 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
hash:
|
50
|
+
hash: 19
|
51
51
|
segments:
|
52
52
|
- 2
|
53
53
|
- 3
|
54
|
-
-
|
55
|
-
version: 2.3.
|
54
|
+
- 8
|
55
|
+
version: 2.3.8
|
56
56
|
type: :runtime
|
57
57
|
version_requirements: *id001
|
58
58
|
- !ruby/object:Gem::Dependency
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/active_merchant/billing/gateway.rb
|
113
113
|
- lib/active_merchant/billing/gateways/authorize_net.rb
|
114
114
|
- lib/active_merchant/billing/gateways/authorize_net_cim.rb
|
115
|
+
- lib/active_merchant/billing/gateways/barclays_epdq.rb
|
115
116
|
- lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb
|
116
117
|
- lib/active_merchant/billing/gateways/beanstream.rb
|
117
118
|
- lib/active_merchant/billing/gateways/beanstream_interac.rb
|
@@ -238,6 +239,11 @@ files:
|
|
238
239
|
- lib/active_merchant/billing/integrations/two_checkout/notification.rb
|
239
240
|
- lib/active_merchant/billing/integrations/two_checkout/return.rb
|
240
241
|
- lib/active_merchant/billing/integrations/two_checkout.rb
|
242
|
+
- lib/active_merchant/billing/integrations/valitor/helper.rb
|
243
|
+
- lib/active_merchant/billing/integrations/valitor/notification.rb
|
244
|
+
- lib/active_merchant/billing/integrations/valitor/response_fields.rb
|
245
|
+
- lib/active_merchant/billing/integrations/valitor/return.rb
|
246
|
+
- lib/active_merchant/billing/integrations/valitor.rb
|
241
247
|
- lib/active_merchant/billing/integrations.rb
|
242
248
|
- lib/active_merchant/billing/response.rb
|
243
249
|
- lib/active_merchant/billing.rb
|
metadata.gz.sig
CHANGED
Binary file
|