activemerchant 1.28.0 → 1.29.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -3
- data/CHANGELOG +36 -0
- data/CONTRIBUTORS +8 -0
- data/README.md +5 -0
- data/lib/active_merchant/billing/gateway.rb +2 -1
- data/lib/active_merchant/billing/gateways.rb +6 -7
- data/lib/active_merchant/billing/gateways/authorize_net.rb +3 -2
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +77 -78
- data/lib/active_merchant/billing/gateways/balanced.rb +0 -1
- data/lib/active_merchant/billing/gateways/banwire.rb +1 -2
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +19 -20
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +35 -36
- data/lib/active_merchant/billing/gateways/blue_pay.rb +135 -140
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +54 -59
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -14
- data/lib/active_merchant/billing/gateways/data_cash.rb +106 -112
- data/lib/active_merchant/billing/gateways/efsnet.rb +29 -34
- data/lib/active_merchant/billing/gateways/elavon.rb +7 -1
- data/lib/active_merchant/billing/gateways/epay.rb +0 -1
- data/lib/active_merchant/billing/gateways/eway.rb +88 -93
- data/lib/active_merchant/billing/gateways/eway_managed.rb +47 -51
- data/lib/active_merchant/billing/gateways/exact.rb +45 -54
- data/lib/active_merchant/billing/gateways/federated_canada.rb +3 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +37 -38
- data/lib/active_merchant/billing/gateways/garanti.rb +1 -2
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +5 -8
- data/lib/active_merchant/billing/gateways/inspire.rb +52 -52
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -11
- data/lib/active_merchant/billing/gateways/iridium.rb +38 -39
- data/lib/active_merchant/billing/gateways/itransact.rb +7 -9
- data/lib/active_merchant/billing/gateways/jetpay.rb +45 -46
- data/lib/active_merchant/billing/gateways/linkpoint.rb +104 -108
- data/lib/active_merchant/billing/gateways/litle.rb +1 -5
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +153 -155
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +49 -50
- data/lib/active_merchant/billing/gateways/mercury.rb +272 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +9 -10
- data/lib/active_merchant/billing/gateways/migs.rb +5 -3
- data/lib/active_merchant/billing/gateways/modern_payments.rb +6 -7
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +40 -41
- data/lib/active_merchant/billing/gateways/moneris.rb +46 -50
- data/lib/active_merchant/billing/gateways/moneris_us.rb +52 -55
- data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -5
- data/lib/active_merchant/billing/gateways/net_registry.rb +20 -21
- data/lib/active_merchant/billing/gateways/netaxept.rb +30 -36
- data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
- data/lib/active_merchant/billing/gateways/ogone.rb +0 -5
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -6
- data/lib/active_merchant/billing/gateways/orbital.rb +25 -21
- data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +93 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +1 -6
- data/lib/active_merchant/billing/gateways/pay_junction.rb +62 -63
- data/lib/active_merchant/billing/gateways/pay_secure.rb +29 -30
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -5
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +33 -38
- data/lib/active_merchant/billing/gateways/payment_express.rb +48 -51
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +7 -11
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +7 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +3 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +62 -64
- data/lib/active_merchant/billing/gateways/payway.rb +2 -9
- data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/psigate.rb +102 -94
- data/lib/active_merchant/billing/gateways/psl_card.rb +66 -67
- data/lib/active_merchant/billing/gateways/qbms.rb +0 -6
- data/lib/active_merchant/billing/gateways/quantum.rb +2 -8
- data/lib/active_merchant/billing/gateways/quickpay.rb +2 -3
- data/lib/active_merchant/billing/gateways/realex.rb +6 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +394 -0
- data/lib/active_merchant/billing/gateways/sage.rb +15 -16
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +25 -26
- data/lib/active_merchant/billing/gateways/sage_pay.rb +51 -56
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
- data/lib/active_merchant/billing/gateways/samurai.rb +1 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
- data/lib/active_merchant/billing/gateways/secure_pay.rb +5 -8
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -5
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +17 -18
- data/lib/active_merchant/billing/gateways/skip_jack.rb +29 -34
- data/lib/active_merchant/billing/gateways/smart_ps.rb +55 -56
- data/lib/active_merchant/billing/gateways/stripe.rb +8 -3
- data/lib/active_merchant/billing/gateways/trans_first.rb +28 -29
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +85 -87
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +27 -28
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +86 -87
- data/lib/active_merchant/billing/gateways/viaklix.rb +42 -47
- data/lib/active_merchant/billing/gateways/vindicia.rb +30 -28
- data/lib/active_merchant/billing/gateways/webpay.rb +45 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +0 -6
- data/lib/active_merchant/billing/gateways/worldpay.rb +4 -9
- data/lib/active_merchant/billing/integrations/a1agregator.rb +26 -0
- data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +31 -0
- data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +186 -0
- data/lib/active_merchant/billing/integrations/a1agregator/status.rb +38 -0
- data/lib/active_merchant/billing/integrations/liqpay.rb +30 -0
- data/lib/active_merchant/billing/integrations/liqpay/helper.rb +43 -0
- data/lib/active_merchant/billing/integrations/liqpay/notification.rb +89 -0
- data/lib/active_merchant/billing/integrations/liqpay/return.rb +83 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +17 -1
- data/lib/active_merchant/billing/integrations/notification.rb +4 -0
- data/lib/active_merchant/billing/integrations/pay_fast.rb +70 -0
- data/lib/active_merchant/billing/integrations/pay_fast/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +50 -0
- data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +134 -0
- data/lib/active_merchant/billing/integrations/pay_fast/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +64 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +10 -7
- data/lib/active_merchant/billing/integrations/webmoney/notification.rb +12 -0
- data/lib/active_merchant/billing/response.rb +19 -4
- data/lib/active_merchant/version.rb +1 -1
- metadata +45 -27
- metadata.gz.sig +0 -0
@@ -7,13 +7,13 @@ module ActiveMerchant #:nodoc:
|
|
7
7
|
base.homepage_url = 'http://www.sagepayments.com'
|
8
8
|
base.display_name = 'Sage Payment Solutions'
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
# Transactions types:
|
12
12
|
# <tt>01</tt> - Sale
|
13
|
-
# <tt>02</tt> - AuthOnly
|
14
|
-
# <tt>03</tt> - Force/PriorAuthSale
|
15
|
-
# <tt>04</tt> - Void
|
16
|
-
# <tt>06</tt> - Credit
|
13
|
+
# <tt>02</tt> - AuthOnly
|
14
|
+
# <tt>03</tt> - Force/PriorAuthSale
|
15
|
+
# <tt>04</tt> - Void
|
16
|
+
# <tt>06</tt> - Credit
|
17
17
|
# <tt>11</tt> - PriorAuthSale by Reference*
|
18
18
|
TRANSACTIONS = {
|
19
19
|
:purchase => '01',
|
@@ -22,83 +22,82 @@ module ActiveMerchant #:nodoc:
|
|
22
22
|
:void => '04',
|
23
23
|
:credit => '06'
|
24
24
|
}
|
25
|
-
|
25
|
+
|
26
26
|
def initialize(options = {})
|
27
27
|
requires!(options, :login, :password)
|
28
|
-
@options = options
|
29
28
|
super
|
30
29
|
end
|
31
|
-
|
30
|
+
|
32
31
|
private
|
33
32
|
def add_invoice(post, options)
|
34
33
|
post[:T_ordernum] = options[:order_id].slice(0, 20)
|
35
34
|
post[:T_tax] = amount(options[:tax]) unless options[:tax].blank?
|
36
35
|
post[:T_shipping] = amount(options[:shipping]) unless options[:shipping].blank?
|
37
36
|
end
|
38
|
-
|
37
|
+
|
39
38
|
def add_reference(post, reference)
|
40
39
|
ref, source = reference.to_s.split(";")
|
41
40
|
post[:T_reference] = ref
|
42
41
|
end
|
43
|
-
|
42
|
+
|
44
43
|
def add_amount(post, money)
|
45
44
|
post[:T_amt] = amount(money)
|
46
45
|
end
|
47
|
-
|
46
|
+
|
48
47
|
def add_customer_data(post, options)
|
49
48
|
post[:T_customer_number] = options[:customer]
|
50
49
|
end
|
51
50
|
|
52
51
|
def add_addresses(post, options)
|
53
52
|
billing_address = options[:billing_address] || options[:address] || {}
|
54
|
-
|
53
|
+
|
55
54
|
post[:C_address] = billing_address[:address1]
|
56
55
|
post[:C_city] = billing_address[:city]
|
57
|
-
|
56
|
+
|
58
57
|
if ['US', 'CA'].include?(billing_address[:country])
|
59
58
|
post[:C_state] = billing_address[:state]
|
60
59
|
else
|
61
60
|
post[:C_state] = "Outside of United States"
|
62
61
|
end
|
63
|
-
|
62
|
+
|
64
63
|
post[:C_zip] = billing_address[:zip]
|
65
|
-
post[:C_country] = billing_address[:country]
|
64
|
+
post[:C_country] = billing_address[:country]
|
66
65
|
post[:C_telephone] = billing_address[:phone]
|
67
66
|
post[:C_fax] = billing_address[:fax]
|
68
67
|
post[:C_email] = options[:email]
|
69
|
-
|
68
|
+
|
70
69
|
if shipping_address = options[:shipping_address]
|
71
70
|
post[:C_ship_name] = shipping_address[:name]
|
72
71
|
post[:C_ship_address] = shipping_address[:address1]
|
73
72
|
post[:C_ship_city] = shipping_address[:city]
|
74
73
|
post[:C_ship_state] = shipping_address[:state]
|
75
|
-
post[:C_ship_zip] = shipping_address[:zip]
|
74
|
+
post[:C_ship_zip] = shipping_address[:zip]
|
76
75
|
post[:C_ship_country] = shipping_address[:country]
|
77
76
|
end
|
78
77
|
end
|
79
|
-
|
78
|
+
|
80
79
|
def add_transaction_data(post, money, options)
|
81
80
|
add_amount(post, money)
|
82
81
|
add_invoice(post, options)
|
83
|
-
add_addresses(post, options)
|
82
|
+
add_addresses(post, options)
|
84
83
|
add_customer_data(post, options)
|
85
84
|
end
|
86
|
-
|
85
|
+
|
87
86
|
def commit(action, params)
|
88
87
|
response = parse(ssl_post(self.live_url, post_data(action, params)))
|
89
|
-
|
90
|
-
Response.new(success?(response), response[:message], response,
|
91
|
-
:test => test?,
|
88
|
+
|
89
|
+
Response.new(success?(response), response[:message], response,
|
90
|
+
:test => test?,
|
92
91
|
:authorization => authorization_from(response),
|
93
92
|
:avs_result => { :code => response[:avs_result] },
|
94
93
|
:cvv_result => response[:cvv_result]
|
95
94
|
)
|
96
95
|
end
|
97
|
-
|
96
|
+
|
98
97
|
def authorization_from(response)
|
99
98
|
"#{response[:reference]};#{source}"
|
100
99
|
end
|
101
|
-
|
100
|
+
|
102
101
|
def success?(response)
|
103
102
|
response[:success] == 'A'
|
104
103
|
end
|
@@ -107,7 +106,7 @@ module ActiveMerchant #:nodoc:
|
|
107
106
|
params[:M_id] = @options[:login]
|
108
107
|
params[:M_key] = @options[:password]
|
109
108
|
params[:T_code] = TRANSACTIONS[action]
|
110
|
-
|
109
|
+
|
111
110
|
params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
112
111
|
end
|
113
112
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
|
-
class SagePayGateway < Gateway
|
3
|
+
class SagePayGateway < Gateway
|
4
4
|
cattr_accessor :simulate
|
5
5
|
self.simulate = false
|
6
6
|
|
@@ -9,9 +9,9 @@ module ActiveMerchant #:nodoc:
|
|
9
9
|
self.test_url = 'https://test.sagepay.com/gateway/service'
|
10
10
|
self.live_url = 'https://live.sagepay.com/gateway/service'
|
11
11
|
self.simulator_url = 'https://test.sagepay.com/Simulator'
|
12
|
-
|
12
|
+
|
13
13
|
APPROVED = 'OK'
|
14
|
-
|
14
|
+
|
15
15
|
TRANSACTIONS = {
|
16
16
|
:purchase => 'PAYMENT',
|
17
17
|
:credit => 'REFUND',
|
@@ -20,7 +20,7 @@ module ActiveMerchant #:nodoc:
|
|
20
20
|
:void => 'VOID',
|
21
21
|
:abort => 'ABORT'
|
22
22
|
}
|
23
|
-
|
23
|
+
|
24
24
|
CREDIT_CARDS = {
|
25
25
|
:visa => "VISA",
|
26
26
|
:master => "MC",
|
@@ -35,36 +35,31 @@ module ActiveMerchant #:nodoc:
|
|
35
35
|
}
|
36
36
|
|
37
37
|
ELECTRON = /^(424519|42496[23]|450875|48440[6-8]|4844[1-5][1-5]|4917[3-5][0-9]|491880)\d{10}(\d{3})?$/
|
38
|
-
|
38
|
+
|
39
39
|
AVS_CVV_CODE = {
|
40
|
-
"NOTPROVIDED" => nil,
|
40
|
+
"NOTPROVIDED" => nil,
|
41
41
|
"NOTCHECKED" => 'X',
|
42
42
|
"MATCHED" => 'Y',
|
43
43
|
"NOTMATCHED" => 'N'
|
44
44
|
}
|
45
|
-
|
45
|
+
|
46
46
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :switch, :solo, :maestro, :diners_club]
|
47
47
|
self.supported_countries = ['GB']
|
48
48
|
self.default_currency = 'GBP'
|
49
|
-
|
49
|
+
|
50
50
|
self.homepage_url = 'http://www.sagepay.com'
|
51
51
|
self.display_name = 'SagePay'
|
52
52
|
|
53
53
|
def initialize(options = {})
|
54
54
|
requires!(options, :login)
|
55
|
-
@options = options
|
56
55
|
super
|
57
56
|
end
|
58
|
-
|
59
|
-
def test?
|
60
|
-
@options[:test] || super
|
61
|
-
end
|
62
|
-
|
57
|
+
|
63
58
|
def purchase(money, credit_card, options = {})
|
64
59
|
requires!(options, :order_id)
|
65
|
-
|
60
|
+
|
66
61
|
post = {}
|
67
|
-
|
62
|
+
|
68
63
|
add_amount(post, money, options)
|
69
64
|
add_invoice(post, options)
|
70
65
|
add_credit_card(post, credit_card)
|
@@ -73,12 +68,12 @@ module ActiveMerchant #:nodoc:
|
|
73
68
|
|
74
69
|
commit(:purchase, post)
|
75
70
|
end
|
76
|
-
|
71
|
+
|
77
72
|
def authorize(money, credit_card, options = {})
|
78
73
|
requires!(options, :order_id)
|
79
|
-
|
74
|
+
|
80
75
|
post = {}
|
81
|
-
|
76
|
+
|
82
77
|
add_amount(post, money, options)
|
83
78
|
add_invoice(post, options)
|
84
79
|
add_credit_card(post, credit_card)
|
@@ -87,20 +82,20 @@ module ActiveMerchant #:nodoc:
|
|
87
82
|
|
88
83
|
commit(:authorization, post)
|
89
84
|
end
|
90
|
-
|
85
|
+
|
91
86
|
# You can only capture a transaction once, even if you didn't capture the full amount the first time.
|
92
87
|
def capture(money, identification, options = {})
|
93
88
|
post = {}
|
94
|
-
|
89
|
+
|
95
90
|
add_reference(post, identification)
|
96
91
|
add_release_amount(post, money, options)
|
97
|
-
|
92
|
+
|
98
93
|
commit(:capture, post)
|
99
94
|
end
|
100
|
-
|
95
|
+
|
101
96
|
def void(identification, options = {})
|
102
97
|
post = {}
|
103
|
-
|
98
|
+
|
104
99
|
add_reference(post, identification)
|
105
100
|
action = abort_or_void_from(identification)
|
106
101
|
|
@@ -110,13 +105,13 @@ module ActiveMerchant #:nodoc:
|
|
110
105
|
# Refunding requires a new order_id to passed in, as well as a description
|
111
106
|
def refund(money, identification, options = {})
|
112
107
|
requires!(options, :order_id, :description)
|
113
|
-
|
108
|
+
|
114
109
|
post = {}
|
115
|
-
|
110
|
+
|
116
111
|
add_credit_reference(post, identification)
|
117
112
|
add_amount(post, money, options)
|
118
113
|
add_invoice(post, options)
|
119
|
-
|
114
|
+
|
120
115
|
commit(:credit, post)
|
121
116
|
end
|
122
117
|
|
@@ -124,26 +119,26 @@ module ActiveMerchant #:nodoc:
|
|
124
119
|
deprecated CREDIT_DEPRECATION_MESSAGE
|
125
120
|
refund(money, identification, options)
|
126
121
|
end
|
127
|
-
|
122
|
+
|
128
123
|
private
|
129
124
|
def add_reference(post, identification)
|
130
|
-
order_id, transaction_id, authorization, security_key = identification.split(';')
|
131
|
-
|
125
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
126
|
+
|
132
127
|
add_pair(post, :VendorTxCode, order_id)
|
133
128
|
add_pair(post, :VPSTxId, transaction_id)
|
134
129
|
add_pair(post, :TxAuthNo, authorization)
|
135
130
|
add_pair(post, :SecurityKey, security_key)
|
136
131
|
end
|
137
|
-
|
132
|
+
|
138
133
|
def add_credit_reference(post, identification)
|
139
|
-
order_id, transaction_id, authorization, security_key = identification.split(';')
|
140
|
-
|
134
|
+
order_id, transaction_id, authorization, security_key = identification.split(';')
|
135
|
+
|
141
136
|
add_pair(post, :RelatedVendorTxCode, order_id)
|
142
137
|
add_pair(post, :RelatedVPSTxId, transaction_id)
|
143
138
|
add_pair(post, :RelatedTxAuthNo, authorization)
|
144
139
|
add_pair(post, :RelatedSecurityKey, security_key)
|
145
140
|
end
|
146
|
-
|
141
|
+
|
147
142
|
def add_amount(post, money, options)
|
148
143
|
currency = options[:currency] || currency(money)
|
149
144
|
add_pair(post, :Amount, localized_amount(money, currency), :required => true)
|
@@ -173,7 +168,7 @@ module ActiveMerchant #:nodoc:
|
|
173
168
|
add_pair(post, :BillingCountry, billing_address[:country])
|
174
169
|
add_pair(post, :BillingPostCode, billing_address[:zip])
|
175
170
|
end
|
176
|
-
|
171
|
+
|
177
172
|
if shipping_address = options[:shipping_address] || billing_address
|
178
173
|
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
179
174
|
add_pair(post, :DeliverySurname, last_name)
|
@@ -195,59 +190,59 @@ module ActiveMerchant #:nodoc:
|
|
195
190
|
def add_credit_card(post, credit_card)
|
196
191
|
add_pair(post, :CardHolder, credit_card.name, :required => true)
|
197
192
|
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
198
|
-
|
193
|
+
|
199
194
|
add_pair(post, :ExpiryDate, format_date(credit_card.month, credit_card.year), :required => true)
|
200
|
-
|
195
|
+
|
201
196
|
if requires_start_date_or_issue_number?(credit_card)
|
202
197
|
add_pair(post, :StartDate, format_date(credit_card.start_month, credit_card.start_year))
|
203
198
|
add_pair(post, :IssueNumber, credit_card.issue_number)
|
204
199
|
end
|
205
200
|
add_pair(post, :CardType, map_card_type(credit_card))
|
206
|
-
|
201
|
+
|
207
202
|
add_pair(post, :CV2, credit_card.verification_value)
|
208
203
|
end
|
209
|
-
|
204
|
+
|
210
205
|
def sanitize_order_id(order_id)
|
211
206
|
order_id.to_s.gsub(/[^-a-zA-Z0-9._]/, '')
|
212
207
|
end
|
213
|
-
|
208
|
+
|
214
209
|
def map_card_type(credit_card)
|
215
210
|
raise ArgumentError, "The credit card type must be provided" if card_brand(credit_card).blank?
|
216
|
-
|
211
|
+
|
217
212
|
card_type = card_brand(credit_card).to_sym
|
218
|
-
|
213
|
+
|
219
214
|
# Check if it is an electron card
|
220
|
-
if card_type == :visa && credit_card.number =~ ELECTRON
|
215
|
+
if card_type == :visa && credit_card.number =~ ELECTRON
|
221
216
|
CREDIT_CARDS[:electron]
|
222
|
-
else
|
217
|
+
else
|
223
218
|
CREDIT_CARDS[card_type]
|
224
219
|
end
|
225
220
|
end
|
226
|
-
|
221
|
+
|
227
222
|
# MMYY format
|
228
223
|
def format_date(month, year)
|
229
224
|
return nil if year.blank? || month.blank?
|
230
|
-
|
225
|
+
|
231
226
|
year = sprintf("%.4i", year)
|
232
227
|
month = sprintf("%.2i", month)
|
233
228
|
|
234
229
|
"#{month}#{year[-2..-1]}"
|
235
230
|
end
|
236
|
-
|
231
|
+
|
237
232
|
def commit(action, parameters)
|
238
233
|
response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
|
239
|
-
|
234
|
+
|
240
235
|
Response.new(response["Status"] == APPROVED, message_from(response), response,
|
241
236
|
:test => test?,
|
242
237
|
:authorization => authorization_from(response, parameters, action),
|
243
|
-
:avs_result => {
|
238
|
+
:avs_result => {
|
244
239
|
:street_match => AVS_CVV_CODE[ response["AddressResult"] ],
|
245
240
|
:postal_match => AVS_CVV_CODE[ response["PostCodeResult"] ],
|
246
241
|
},
|
247
242
|
:cvv_result => AVS_CVV_CODE[ response["CV2Result"] ]
|
248
243
|
)
|
249
244
|
end
|
250
|
-
|
245
|
+
|
251
246
|
def authorization_from(response, params, action)
|
252
247
|
[ params[:VendorTxCode],
|
253
248
|
response["VPSTxId"],
|
@@ -264,12 +259,12 @@ module ActiveMerchant #:nodoc:
|
|
264
259
|
def url_for(action)
|
265
260
|
simulate ? build_simulator_url(action) : build_url(action)
|
266
261
|
end
|
267
|
-
|
262
|
+
|
268
263
|
def build_url(action)
|
269
264
|
endpoint = [ :purchase, :authorization ].include?(action) ? "vspdirect-register" : TRANSACTIONS[action].downcase
|
270
265
|
"#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
|
271
266
|
end
|
272
|
-
|
267
|
+
|
273
268
|
def build_simulator_url(action)
|
274
269
|
endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
|
275
270
|
"#{self.simulator_url}/#{endpoint}"
|
@@ -285,10 +280,10 @@ module ActiveMerchant #:nodoc:
|
|
285
280
|
:TxType => TRANSACTIONS[action],
|
286
281
|
:VPSProtocol => "2.23"
|
287
282
|
)
|
288
|
-
|
283
|
+
|
289
284
|
parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
290
285
|
end
|
291
|
-
|
286
|
+
|
292
287
|
# SagePay returns data in the following format
|
293
288
|
# Key1=value1
|
294
289
|
# Key2=value2
|
@@ -306,12 +301,12 @@ module ActiveMerchant #:nodoc:
|
|
306
301
|
|
307
302
|
def parse_first_and_last_name(value)
|
308
303
|
name = value.to_s.split(' ')
|
309
|
-
|
304
|
+
|
310
305
|
last_name = name.pop || ''
|
311
306
|
first_name = name.join(' ')
|
312
307
|
[ first_name[0,20], last_name[0,20] ]
|
313
308
|
end
|
314
|
-
|
309
|
+
|
315
310
|
def localized_amount(money, currency)
|
316
311
|
amount = amount(money)
|
317
312
|
CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount
|
@@ -17,16 +17,13 @@ module ActiveMerchant #:nodoc:
|
|
17
17
|
end
|
18
18
|
|
19
19
|
requires!(options, :login, :password, :processor_token)
|
20
|
-
@options = options
|
21
20
|
Samurai.options = {
|
22
21
|
:merchant_key => options[:login],
|
23
22
|
:merchant_password => options[:password],
|
24
23
|
:processor_token => options[:processor_token]
|
25
24
|
}
|
26
|
-
end
|
27
25
|
|
28
|
-
|
29
|
-
@options[:test] || super
|
26
|
+
super
|
30
27
|
end
|
31
28
|
|
32
29
|
def authorize(money, credit_card_or_vault_id, options = {})
|