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
@@ -65,22 +65,18 @@ module ActiveMerchant #:nodoc:
|
|
65
65
|
requires!(options, :login, :password)
|
66
66
|
|
67
67
|
headers = {'X-PP-AUTHORIZATION' => options.delete(:auth_signature), 'X-PAYPAL-MESSAGE-PROTOCOL' => 'SOAP11'} if options[:auth_signature]
|
68
|
-
|
68
|
+
options = {
|
69
69
|
:pem => pem_file,
|
70
70
|
:signature => signature,
|
71
71
|
:headers => headers || {}
|
72
72
|
}.update(options)
|
73
73
|
|
74
74
|
|
75
|
-
if
|
75
|
+
if options[:pem].blank? && options[:signature].blank?
|
76
76
|
raise ArgumentError, "An API Certificate or API Signature is required to make requests to PayPal"
|
77
77
|
end
|
78
78
|
|
79
|
-
super
|
80
|
-
end
|
81
|
-
|
82
|
-
def test?
|
83
|
-
@options[:test] || Base.gateway_mode == :test
|
79
|
+
super(options)
|
84
80
|
end
|
85
81
|
|
86
82
|
def reauthorize(money, authorization, options = {})
|
@@ -509,10 +505,10 @@ module ActiveMerchant #:nodoc:
|
|
509
505
|
def add_credentials(xml)
|
510
506
|
xml.tag! 'RequesterCredentials', CREDENTIALS_NAMESPACES do
|
511
507
|
xml.tag! 'n1:Credentials' do
|
512
|
-
xml.tag! 'Username', @options[:login]
|
513
|
-
xml.tag! 'Password', @options[:password]
|
514
|
-
xml.tag! 'Subject', @options[:subject]
|
515
|
-
xml.tag! 'Signature', @options[:signature] unless @options[:signature].blank?
|
508
|
+
xml.tag! 'n1:Username', @options[:login]
|
509
|
+
xml.tag! 'n1:Password', @options[:password]
|
510
|
+
xml.tag! 'n1:Subject', @options[:subject]
|
511
|
+
xml.tag! 'n1:Signature', @options[:signature] unless @options[:signature].blank?
|
516
512
|
end
|
517
513
|
end
|
518
514
|
end
|
@@ -44,6 +44,13 @@ module ActiveMerchant #:nodoc:
|
|
44
44
|
'phone' => (contact_phone || address['Phone'])
|
45
45
|
}
|
46
46
|
end
|
47
|
+
|
48
|
+
def shipping
|
49
|
+
shipping = (@params['UserSelectedOptions']||{})
|
50
|
+
{ 'amount' => shipping['ShippingOptionAmount'],
|
51
|
+
'name' => shipping['ShippingOptionName']
|
52
|
+
}
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
49
56
|
end
|
@@ -202,6 +202,9 @@ commit 'ManageRecurringPaymentsProfileStatus', build_manage_profile_request(prof
|
|
202
202
|
if options.has_key?(:start_date)
|
203
203
|
xml.tag! 'n2:BillingStartDate', (options[:start_date].is_a?(Date) ? options[:start_date].to_time : options[:start_date]).utc.iso8601
|
204
204
|
end
|
205
|
+
if options.has_key?(:outstanding_balance)
|
206
|
+
xml.tag! 'n2:OutstandingBalance', amount(options[:outstanding_balance]), 'currencyID' => options[:currency] || 'USD'
|
207
|
+
end
|
205
208
|
end
|
206
209
|
end
|
207
210
|
end
|
@@ -1,97 +1,95 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
3
|
class PaystationGateway < Gateway
|
4
|
-
|
4
|
+
|
5
5
|
self.live_url = self.test_url = "https://www.paystation.co.nz/direct/paystation.dll"
|
6
|
-
|
6
|
+
|
7
7
|
# an "error code" of "0" means "No error - transaction successful"
|
8
8
|
SUCCESSFUL_RESPONSE_CODE = '0'
|
9
|
-
|
9
|
+
|
10
10
|
# an "error code" of "34" means "Future Payment Stored OK"
|
11
11
|
SUCCESSFUL_FUTURE_PAYMENT = '34'
|
12
|
-
|
12
|
+
|
13
13
|
# TODO: check this with paystation
|
14
14
|
self.supported_countries = ['NZ']
|
15
|
-
|
15
|
+
|
16
16
|
# TODO: check this with paystation (amex and diners need to be enabled)
|
17
17
|
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club ]
|
18
|
-
|
18
|
+
|
19
19
|
self.homepage_url = 'http://paystation.co.nz'
|
20
20
|
self.display_name = 'Paystation'
|
21
|
-
|
21
|
+
|
22
22
|
self.default_currency = 'NZD'
|
23
23
|
self.money_format = :cents
|
24
|
-
|
24
|
+
|
25
25
|
def initialize(options = {})
|
26
|
-
# You need to pass your Paystation ID and Gateway ID
|
27
26
|
requires!(options, :paystation_id, :gateway_id)
|
28
|
-
@options = options
|
29
27
|
super
|
30
|
-
end
|
31
|
-
|
28
|
+
end
|
29
|
+
|
32
30
|
def authorize(money, credit_card, options = {})
|
33
31
|
post = new_request
|
34
|
-
|
32
|
+
|
35
33
|
add_invoice(post, options)
|
36
34
|
add_amount(post, money, options)
|
37
|
-
|
35
|
+
|
38
36
|
add_credit_card(post, credit_card)
|
39
|
-
|
37
|
+
|
40
38
|
add_authorize_flag(post, options)
|
41
|
-
|
39
|
+
|
42
40
|
commit(post)
|
43
41
|
end
|
44
|
-
|
42
|
+
|
45
43
|
def capture(money, authorization_token, options = {})
|
46
44
|
post = new_request
|
47
|
-
|
45
|
+
|
48
46
|
add_invoice(post, options)
|
49
47
|
add_amount(post, money, options)
|
50
|
-
|
48
|
+
|
51
49
|
add_authorization_token(post, authorization_token, options[:credit_card_verification])
|
52
|
-
|
50
|
+
|
53
51
|
commit(post)
|
54
52
|
end
|
55
|
-
|
53
|
+
|
56
54
|
def purchase(money, payment_source, options = {})
|
57
55
|
post = new_request
|
58
|
-
|
56
|
+
|
59
57
|
add_invoice(post, options)
|
60
58
|
add_amount(post, money, options)
|
61
|
-
|
59
|
+
|
62
60
|
if payment_source.is_a?(String)
|
63
|
-
add_token(post, payment_source)
|
61
|
+
add_token(post, payment_source)
|
64
62
|
else
|
65
63
|
add_credit_card(post, payment_source)
|
66
64
|
end
|
67
|
-
|
65
|
+
|
68
66
|
add_customer_data(post, options) if options.has_key?(:customer)
|
69
|
-
|
67
|
+
|
70
68
|
commit(post)
|
71
|
-
end
|
72
|
-
|
69
|
+
end
|
70
|
+
|
73
71
|
def store(credit_card, options = {})
|
74
72
|
post = new_request
|
75
|
-
|
73
|
+
|
76
74
|
add_invoice(post, options)
|
77
75
|
add_credit_card(post, credit_card)
|
78
76
|
store_credit_card(post, options)
|
79
|
-
|
77
|
+
|
80
78
|
commit(post)
|
81
79
|
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
80
|
+
|
81
|
+
private
|
82
|
+
|
85
83
|
def new_request
|
86
|
-
{
|
84
|
+
{
|
87
85
|
:pi => @options[:paystation_id], # paystation account id
|
88
86
|
:gi => @options[:gateway_id], # paystation gateway id
|
89
87
|
"2p" => "t", # two-party transaction type
|
90
88
|
:nr => "t", # -- redirect??
|
91
89
|
:df => "yymm" # date format: optional sometimes, required others
|
92
|
-
}
|
90
|
+
}
|
93
91
|
end
|
94
|
-
|
92
|
+
|
95
93
|
def add_customer_data(post, options)
|
96
94
|
post[:mc] = options[:customer]
|
97
95
|
end
|
@@ -103,78 +101,78 @@ module ActiveMerchant #:nodoc:
|
|
103
101
|
post[:mo] = options[:invoice] # "Order Details", displayed in Paystation Admin
|
104
102
|
post[:mr] = options[:description] # "Merchant Reference Code", seen from Paystation Admin
|
105
103
|
end
|
106
|
-
|
107
|
-
def add_credit_card(post, credit_card)
|
108
|
-
|
104
|
+
|
105
|
+
def add_credit_card(post, credit_card)
|
106
|
+
|
109
107
|
post[:cn] = credit_card.number
|
110
108
|
post[:ct] = credit_card.brand
|
111
109
|
post[:ex] = format_date(credit_card.month, credit_card.year)
|
112
110
|
post[:cc] = credit_card.verification_value if credit_card.verification_value?
|
113
|
-
|
111
|
+
|
114
112
|
end
|
115
|
-
|
113
|
+
|
116
114
|
# bill a token (stored via "store") rather than a Credit Card
|
117
115
|
def add_token(post, token)
|
118
116
|
post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
|
119
117
|
post[:ft] = token
|
120
118
|
end
|
121
|
-
|
119
|
+
|
122
120
|
def store_credit_card(post, options)
|
123
|
-
|
121
|
+
|
124
122
|
post[:fp] = "t" # turn on "future payments" - what paystation calls Token Billing
|
125
123
|
post[:fs] = "t" # tells paystation to store right now, not bill
|
126
124
|
post[:ft] = options[:token] if options[:token] # specify a token to use that, or let Paystation generate one
|
127
|
-
|
125
|
+
|
128
126
|
end
|
129
|
-
|
127
|
+
|
130
128
|
def add_authorize_flag(post, options)
|
131
129
|
post[:pa] = "t" # tells Paystation that this is a pre-auth authorisation payment (account must be in pre-auth mode)
|
132
130
|
end
|
133
|
-
|
131
|
+
|
134
132
|
def add_authorization_token(post, auth_token, verification_value = nil)
|
135
133
|
post[:cp] = "t" # Capture Payment flag – tells Paystation this transaction should be treated as a capture payment
|
136
134
|
post[:cx] = auth_token
|
137
135
|
post[:cc] = verification_value
|
138
136
|
end
|
139
|
-
|
137
|
+
|
140
138
|
def add_amount(post, money, options)
|
141
|
-
|
139
|
+
|
142
140
|
post[:am] = amount(money)
|
143
141
|
post[:cu] = options[:currency] || currency(money)
|
144
|
-
|
142
|
+
|
145
143
|
end
|
146
|
-
|
144
|
+
|
147
145
|
def parse(xml_response)
|
148
146
|
response = {}
|
149
|
-
|
147
|
+
|
150
148
|
xml = REXML::Document.new(xml_response)
|
151
|
-
|
149
|
+
|
152
150
|
# for normal payments, the root node is <Response>
|
153
151
|
# for "future payments", it's <PaystationFuturePaymentResponse>
|
154
152
|
xml.elements.each("#{xml.root.name}/*") do |element|
|
155
153
|
response[element.name.underscore.to_sym] = element.text
|
156
154
|
end
|
157
|
-
|
155
|
+
|
158
156
|
response
|
159
|
-
end
|
160
|
-
|
157
|
+
end
|
158
|
+
|
161
159
|
def commit(post)
|
162
|
-
|
160
|
+
|
163
161
|
post[:tm] = "T" if test? # test mode
|
164
|
-
|
162
|
+
|
165
163
|
pstn_prefix_params = post.collect { |key, value| "pstn_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
166
|
-
|
164
|
+
|
167
165
|
# need include paystation param as "initiator flag for payment engine"
|
168
166
|
data = ssl_post(self.live_url, "#{pstn_prefix_params}&paystation=_empty")
|
169
167
|
response = parse(data)
|
170
168
|
message = message_from(response)
|
171
|
-
|
172
|
-
PaystationResponse.new(success?(response), message, response,
|
169
|
+
|
170
|
+
PaystationResponse.new(success?(response), message, response,
|
173
171
|
:test => (response[:tm] && response[:tm].downcase == "t"),
|
174
172
|
:authorization => response[:paystation_transaction_id]
|
175
173
|
)
|
176
174
|
end
|
177
|
-
|
175
|
+
|
178
176
|
def success?(response)
|
179
177
|
(response[:ec] == SUCCESSFUL_RESPONSE_CODE) || (response[:ec] == SUCCESSFUL_FUTURE_PAYMENT)
|
180
178
|
end
|
@@ -182,13 +180,13 @@ module ActiveMerchant #:nodoc:
|
|
182
180
|
def message_from(response)
|
183
181
|
response[:em]
|
184
182
|
end
|
185
|
-
|
183
|
+
|
186
184
|
def format_date(month, year)
|
187
185
|
"#{format(year, :two_digits)}#{format(month, :two_digits)}"
|
188
186
|
end
|
189
|
-
|
187
|
+
|
190
188
|
end
|
191
|
-
|
189
|
+
|
192
190
|
class PaystationResponse < Response
|
193
191
|
# add a method to response so we can easily get the token
|
194
192
|
# for Validate transactions
|
@@ -86,13 +86,10 @@ module ActiveMerchant
|
|
86
86
|
def initialize(options={})
|
87
87
|
@options = options
|
88
88
|
|
89
|
-
options[:merchant] ||= 'TEST' if test?
|
90
|
-
|
89
|
+
@options[:merchant] ||= 'TEST' if test?
|
91
90
|
requires!(options, :username, :password, :merchant, :pem)
|
92
91
|
|
93
|
-
@options[:eci]
|
94
|
-
|
95
|
-
super
|
92
|
+
@options[:eci] ||= 'SSL'
|
96
93
|
end
|
97
94
|
|
98
95
|
def authorize(amount, payment_method, options={})
|
@@ -205,10 +202,6 @@ module ActiveMerchant
|
|
205
202
|
rescue ActiveMerchant::ClientCertificateError
|
206
203
|
return Response.new(false, "Invalid certificate", {}, :test => test?)
|
207
204
|
end
|
208
|
-
|
209
|
-
def test?
|
210
|
-
(@options[:test] || super)
|
211
|
-
end
|
212
205
|
end
|
213
206
|
end
|
214
207
|
end
|
@@ -1,140 +1,138 @@
|
|
1
|
-
# This class implements the Psigate gateway for the ActiveMerchant module.
|
2
|
-
# Psigate = http://www.psigate.com/ The class is currently set up to use
|
3
|
-
# the psigate test server while rails is in testing or developement mode.
|
4
|
-
# The real server will be used while in production mode.
|
5
|
-
#
|
6
|
-
# Modifications by Sean O'Hara ( sohara at sohara dot com )
|
7
|
-
#
|
8
|
-
# Usage for a PreAuth (authorize) is as follows:
|
9
|
-
#
|
10
|
-
# twenty = 2000
|
11
|
-
# gateway = PsigateGateway.new(
|
12
|
-
# :login => 'teststore',
|
13
|
-
# :password => 'psigate1234'
|
14
|
-
# )
|
15
|
-
#
|
16
|
-
# creditcard = CreditCard.new(
|
17
|
-
# :number => '4242424242424242',
|
18
|
-
# :month => 8,
|
19
|
-
# :year => 2006,
|
20
|
-
# :first_name => 'Longbob',
|
21
|
-
# :last_name => 'Longsen'
|
22
|
-
# )
|
23
|
-
# response = @gateway.authorize(twenty, creditcard,
|
24
|
-
# :order_id => 1234,
|
25
|
-
# :billing_address => {
|
26
|
-
# :address1 => '123 fairweather Lane',
|
27
|
-
# :address2 => 'Apt B',
|
28
|
-
# :city => 'New York',
|
29
|
-
# :state => 'NY',
|
30
|
-
# :country => 'U.S.A.',
|
31
|
-
# :zip => '10010'
|
32
|
-
# },
|
33
|
-
# :email => 'jack@yahoo.com'
|
34
|
-
# )
|
35
|
-
|
36
1
|
require 'rexml/document'
|
37
2
|
|
38
3
|
module ActiveMerchant #:nodoc:
|
39
4
|
module Billing #:nodoc:
|
40
|
-
|
5
|
+
# This class implements the Psigate gateway for the ActiveMerchant module.
|
6
|
+
#
|
7
|
+
# Modifications by Sean O'Hara ( sohara at sohara dot com )
|
8
|
+
#
|
9
|
+
# Usage for a PreAuth (authorize) is as follows:
|
10
|
+
#
|
11
|
+
# gateway = PsigateGateway.new(
|
12
|
+
# :login => 'teststore',
|
13
|
+
# :password => 'psigate1234'
|
14
|
+
# )
|
15
|
+
#
|
16
|
+
# creditcard = CreditCard.new(
|
17
|
+
# :number => '4242424242424242',
|
18
|
+
# :month => 8,
|
19
|
+
# :year => 2006,
|
20
|
+
# :first_name => 'Longbob',
|
21
|
+
# :last_name => 'Longsen'
|
22
|
+
# )
|
23
|
+
#
|
24
|
+
# twenty = 2000
|
25
|
+
# response = @gateway.authorize(twenty, creditcard,
|
26
|
+
# :order_id => 1234,
|
27
|
+
# :billing_address => {
|
28
|
+
# :address1 => '123 fairweather Lane',
|
29
|
+
# :address2 => 'Apt B',
|
30
|
+
# :city => 'New York',
|
31
|
+
# :state => 'NY',
|
32
|
+
# :country => 'U.S.A.',
|
33
|
+
# :zip => '10010'
|
34
|
+
# },
|
35
|
+
# :email => 'jack@yahoo.com'
|
36
|
+
# )
|
41
37
|
class PsigateGateway < Gateway
|
42
38
|
self.test_url = 'https://dev.psigate.com:7989/Messenger/XMLMessenger'
|
43
39
|
self.live_url = 'https://secure.psigate.com:7934/Messenger/XMLMessenger'
|
44
|
-
|
40
|
+
|
45
41
|
self.supported_cardtypes = [:visa, :master, :american_express]
|
46
42
|
self.supported_countries = ['CA']
|
47
43
|
self.homepage_url = 'http://www.psigate.com/'
|
48
44
|
self.display_name = 'Psigate'
|
49
|
-
|
45
|
+
|
50
46
|
SUCCESS_MESSAGE = 'Success'
|
51
47
|
FAILURE_MESSAGE = 'The transaction was declined'
|
52
|
-
|
48
|
+
|
53
49
|
def initialize(options = {})
|
54
50
|
requires!(options, :login, :password)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
# Psigate PreAuth
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
60
54
|
def authorize(money, creditcard, options = {})
|
61
|
-
requires!(options, :order_id)
|
62
|
-
options
|
63
|
-
commit(money, creditcard, options)
|
55
|
+
requires!(options, :order_id)
|
56
|
+
options[:CardAction] = "1"
|
57
|
+
commit(money, creditcard, options)
|
64
58
|
end
|
65
|
-
|
66
|
-
# Psigate Sale
|
59
|
+
|
67
60
|
def purchase(money, creditcard, options = {})
|
68
|
-
requires!(options, :order_id)
|
69
|
-
options
|
70
|
-
commit(money, creditcard, options)
|
61
|
+
requires!(options, :order_id)
|
62
|
+
options[:CardAction] = "0"
|
63
|
+
commit(money, creditcard, options)
|
71
64
|
end
|
72
|
-
|
73
|
-
# Psigate PostAuth
|
65
|
+
|
74
66
|
def capture(money, authorization, options = {})
|
75
|
-
options
|
67
|
+
options[:CardAction] = "2"
|
68
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
76
69
|
commit(money, nil, options)
|
77
70
|
end
|
78
|
-
|
79
71
|
|
80
|
-
# Psigate Credit
|
81
72
|
def credit(money, authorization, options = {})
|
82
73
|
deprecated CREDIT_DEPRECATION_MESSAGE
|
83
74
|
refund(money, authorization, options)
|
84
75
|
end
|
85
76
|
|
86
77
|
def refund(money, authorization, options = {})
|
87
|
-
options
|
78
|
+
options[:CardAction] = "3"
|
79
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
88
80
|
commit(money, nil, options)
|
89
81
|
end
|
90
82
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
83
|
+
def void(authorization, options = {})
|
84
|
+
options[:CardAction] = "9"
|
85
|
+
options[:order_id], options[:trans_ref_number] = split_authorization(authorization)
|
86
|
+
commit(nil, nil, options)
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def commit(money, creditcard, options = {})
|
92
|
+
response = parse(ssl_post(url, post_data(money, creditcard, options)))
|
95
93
|
|
96
|
-
Response.new(successful?(response), message_from(response), response,
|
97
|
-
:test => test?,
|
98
|
-
:authorization => response
|
94
|
+
Response.new(successful?(response), message_from(response), response,
|
95
|
+
:test => test?,
|
96
|
+
:authorization => build_authorization(response) ,
|
99
97
|
:avs_result => { :code => response[:avsresult] },
|
100
98
|
:cvv_result => response[:cardidresult]
|
101
99
|
)
|
102
100
|
end
|
103
|
-
|
101
|
+
|
102
|
+
def url
|
103
|
+
(test? ? self.test_url : self.live_url)
|
104
|
+
end
|
105
|
+
|
104
106
|
def successful?(response)
|
105
107
|
response[:approved] == "APPROVED"
|
106
108
|
end
|
107
|
-
|
109
|
+
|
108
110
|
def parse(xml)
|
109
111
|
response = {:message => "Global Error Receipt", :complete => false}
|
110
112
|
|
111
|
-
xml = REXML::Document.new(xml)
|
113
|
+
xml = REXML::Document.new(xml)
|
112
114
|
xml.elements.each('//Result/*') do |node|
|
113
|
-
|
114
115
|
response[node.name.downcase.to_sym] = normalize(node.text)
|
115
|
-
|
116
116
|
end unless xml.root.nil?
|
117
117
|
|
118
118
|
response
|
119
|
-
end
|
119
|
+
end
|
120
120
|
|
121
121
|
def post_data(money, creditcard, options)
|
122
122
|
xml = REXML::Document.new
|
123
123
|
xml << REXML::XMLDecl.new
|
124
|
-
root
|
125
|
-
|
126
|
-
|
124
|
+
root = xml.add_element("Order")
|
125
|
+
|
126
|
+
parameters(money, creditcard, options).each do |key, value|
|
127
127
|
root.add_element(key.to_s).text = value if value
|
128
|
-
end
|
128
|
+
end
|
129
129
|
|
130
130
|
xml.to_s
|
131
131
|
end
|
132
|
-
|
133
|
-
|
134
|
-
# for every action.
|
135
|
-
def parameters(money, creditcard, options = {})
|
132
|
+
|
133
|
+
def parameters(money, creditcard, options = {})
|
136
134
|
params = {
|
137
|
-
# General order
|
135
|
+
# General order parameters
|
138
136
|
:StoreID => @options[:login],
|
139
137
|
:Passphrase => @options[:password],
|
140
138
|
:TestResult => options[:test_result],
|
@@ -143,12 +141,13 @@ module ActiveMerchant #:nodoc:
|
|
143
141
|
:Phone => options[:phone],
|
144
142
|
:Fax => options[:fax],
|
145
143
|
:Email => options[:email],
|
146
|
-
|
147
|
-
|
144
|
+
:TransRefNumber => options[:trans_ref_number],
|
145
|
+
|
146
|
+
# Credit Card parameters
|
148
147
|
:PaymentType => "CC",
|
149
148
|
:CardAction => options[:CardAction],
|
150
|
-
|
151
|
-
# Financial
|
149
|
+
|
150
|
+
# Financial parameters
|
152
151
|
:CustomerIP => options[:ip],
|
153
152
|
:SubTotal => amount(money),
|
154
153
|
:Tax1 => options[:tax1],
|
@@ -159,9 +158,9 @@ module ActiveMerchant #:nodoc:
|
|
159
158
|
if creditcard
|
160
159
|
exp_month = sprintf("%.2i", creditcard.month) unless creditcard.month.blank?
|
161
160
|
exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
|
162
|
-
card_id_code = creditcard.verification_value.blank? ? nil : "1"
|
161
|
+
card_id_code = (creditcard.verification_value.blank? ? nil : "1")
|
163
162
|
|
164
|
-
params.update(
|
163
|
+
params.update(
|
165
164
|
:CardNumber => creditcard.number,
|
166
165
|
:CardExpMonth => exp_month,
|
167
166
|
:CardExpYear => exp_year,
|
@@ -169,9 +168,9 @@ module ActiveMerchant #:nodoc:
|
|
169
168
|
:CardIDNumber => creditcard.verification_value
|
170
169
|
)
|
171
170
|
end
|
172
|
-
|
173
|
-
if
|
174
|
-
params[:Bname] = address[:name] || creditcard.name
|
171
|
+
|
172
|
+
if(address = (options[:billing_address] || options[:address]))
|
173
|
+
params[:Bname] = address[:name] || creditcard.name
|
175
174
|
params[:Baddress1] = address[:address1] unless address[:address1].blank?
|
176
175
|
params[:Baddress2] = address[:address2] unless address[:address2].blank?
|
177
176
|
params[:Bcity] = address[:city] unless address[:city].blank?
|
@@ -180,9 +179,9 @@ module ActiveMerchant #:nodoc:
|
|
180
179
|
params[:Bcountry] = address[:country] unless address[:country].blank?
|
181
180
|
params[:Bcompany] = address[:company] unless address[:company].blank?
|
182
181
|
end
|
183
|
-
|
182
|
+
|
184
183
|
if address = options[:shipping_address]
|
185
|
-
params[:Sname] = address[:name] || creditcard.name
|
184
|
+
params[:Sname] = address[:name] || creditcard.name
|
186
185
|
params[:Saddress1] = address[:address1] unless address[:address1].blank?
|
187
186
|
params[:Saddress2] = address[:address2] unless address[:address2].blank?
|
188
187
|
params[:Scity] = address[:city] unless address[:city].blank?
|
@@ -191,10 +190,10 @@ module ActiveMerchant #:nodoc:
|
|
191
190
|
params[:Scountry] = address[:country] unless address[:country].blank?
|
192
191
|
params[:Scompany] = address[:company] unless address[:company].blank?
|
193
192
|
end
|
194
|
-
|
195
|
-
|
193
|
+
|
194
|
+
params
|
196
195
|
end
|
197
|
-
|
196
|
+
|
198
197
|
def message_from(response)
|
199
198
|
if response[:approved] == "APPROVED"
|
200
199
|
return SUCCESS_MESSAGE
|
@@ -214,6 +213,15 @@ module ActiveMerchant #:nodoc:
|
|
214
213
|
else field
|
215
214
|
end
|
216
215
|
end
|
216
|
+
|
217
|
+
def split_authorization(authorization)
|
218
|
+
order_id, trans_ref_number = authorization.split(';')
|
219
|
+
[order_id, trans_ref_number]
|
220
|
+
end
|
221
|
+
|
222
|
+
def build_authorization(response)
|
223
|
+
[response[:orderid], response[:transrefnumber]].join(";")
|
224
|
+
end
|
217
225
|
end
|
218
226
|
end
|
219
227
|
end
|