activemerchant 1.3.2 → 1.4.0
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 +58 -0
- data/CONTRIBUTERS +25 -0
- data/MIT-LICENSE +3 -3
- data/README +16 -10
- data/Rakefile +4 -3
- data/lib/active_merchant.rb +7 -1
- data/lib/active_merchant/billing/check.rb +16 -9
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +702 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +10 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +26 -2
- data/lib/active_merchant/billing/gateways/data_cash.rb +255 -59
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +1 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -2
- data/lib/active_merchant/billing/gateways/payflow_express.rb +3 -11
- data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +39 -21
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +3 -12
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/protx.rb +25 -25
- data/lib/active_merchant/billing/gateways/sage.rb +145 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -1
- data/lib/active_merchant/billing/gateways/wirecard.rb +304 -0
- data/lib/active_merchant/billing/integrations.rb +8 -2
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +18 -4
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +4 -2
- data/lib/active_merchant/billing/integrations/notification.rb +10 -1
- data/lib/active_merchant/lib/posts_data.rb +12 -3
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/test/extra/binding_of_caller.rb +0 -0
- data/test/extra/breakpoint.rb +0 -0
- data/test/fixtures.yml +24 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +22 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +28 -3
- data/test/remote/gateways/remote_data_cash_test.rb +250 -48
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_wirecard_test.rb +76 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +15 -3
- data/test/test_helper.rb +31 -13
- data/test/unit/check_test.rb +14 -2
- data/test/unit/credit_card_methods_test.rb +18 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +641 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +108 -0
- data/test/unit/gateways/braintree_test.rb +2 -5
- data/test/unit/gateways/cyber_source_test.rb +18 -0
- data/test/unit/gateways/data_cash_test.rb +32 -4
- data/test/unit/gateways/gateway_test.rb +8 -1
- data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
- data/test/unit/gateways/net_registry_test.rb +6 -0
- data/test/unit/gateways/payflow_express_test.rb +18 -2
- data/test/unit/gateways/paypal_express_test.rb +154 -0
- data/test/unit/gateways/paypal_test.rb +140 -0
- data/test/unit/gateways/sage_bankcard_test.rb +162 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/secure_pay_au_test.rb +58 -1
- data/test/unit/gateways/skip_jack_test.rb +8 -0
- data/test/unit/gateways/verifi_test.rb +0 -1
- data/test/unit/gateways/wirecard_test.rb +232 -0
- data/test/unit/integrations/action_view_helper_test.rb +3 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +23 -2
- data/test/unit/integrations/notifications/notification_test.rb +13 -0
- data/test/unit/posts_data_test.rb +20 -6
- metadata +40 -5
- metadata.gz.sig +0 -0
@@ -1,40 +1,43 @@
|
|
1
|
-
#
|
1
|
+
# Authors:: MoneySpyder, http://moneyspyder.co.uk and E-consultancy, http://www.e-consultancy.com
|
2
2
|
|
3
3
|
module ActiveMerchant
|
4
4
|
module Billing
|
5
5
|
class DataCashGateway < Gateway
|
6
6
|
self.default_currency = 'GBP'
|
7
7
|
self.supported_countries = ['GB']
|
8
|
-
|
8
|
+
|
9
9
|
# From the DataCash docs; Page 13, the following cards are
|
10
10
|
# usable:
|
11
11
|
# American Express, ATM, Carte Blanche, Diners Club, Discover,
|
12
12
|
# EnRoute, GE Capital, JCB, Laser, Maestro, Mastercard, Solo,
|
13
|
-
# Switch, Visa, Visa Delta, VISA Electron, Visa Purchasing
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
# Switch, Visa, Visa Delta, VISA Electron, Visa Purchasing
|
14
|
+
#
|
15
|
+
# Note continuous authority is only supported for :visa, :master and :american_express card types
|
16
|
+
self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ]
|
17
|
+
|
17
18
|
self.homepage_url = 'http://www.datacash.com/'
|
18
19
|
self.display_name = 'DataCash'
|
19
|
-
|
20
|
+
|
20
21
|
# Datacash server URLs
|
21
22
|
TEST_URL = 'https://testserver.datacash.com/Transaction'
|
22
23
|
LIVE_URL = 'https://mars.transaction.datacash.com/Transaction'
|
23
|
-
|
24
|
+
|
24
25
|
# Different Card Transaction Types
|
25
26
|
AUTH_TYPE = 'auth'
|
26
27
|
CANCEL_TYPE = 'cancel'
|
27
28
|
FULFILL_TYPE = 'fulfill'
|
28
29
|
PRE_TYPE = 'pre'
|
29
|
-
|
30
|
+
REFUND_TYPE = 'refund'
|
31
|
+
TRANSACTION_REFUND_TYPE = 'txn_refund'
|
32
|
+
|
30
33
|
# Constant strings for use in the ExtendedPolicy complex element for
|
31
34
|
# CV2 checks
|
32
35
|
POLICY_ACCEPT = 'accept'
|
33
36
|
POLICY_REJECT = 'reject'
|
34
|
-
|
37
|
+
|
35
38
|
# Datacash success code
|
36
39
|
DATACASH_SUCCESS = '1'
|
37
|
-
|
40
|
+
|
38
41
|
# Creates a new DataCashGateway
|
39
42
|
#
|
40
43
|
# The gateway requires that a valid login and password be passed
|
@@ -51,30 +54,61 @@ module ActiveMerchant
|
|
51
54
|
@options = options
|
52
55
|
super
|
53
56
|
end
|
54
|
-
|
57
|
+
|
55
58
|
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
56
59
|
#
|
57
60
|
# ==== Parameters
|
61
|
+
# * <tt>money</tt> The amount to be authorized. Either an Integer value in cents or a Money object.
|
62
|
+
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
63
|
+
# * <tt>options</tt> A hash of optional parameters.
|
64
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
65
|
+
# * <tt>:set_up_continuous_authority</tt>
|
66
|
+
# Set to true to set up a recurring historic transaction account be set up.
|
67
|
+
# Only supported for :visa, :master and :american_express card types
|
68
|
+
# See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
|
69
|
+
# * <tt>:address</tt>:: billing address for card
|
58
70
|
#
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
71
|
+
# The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
|
72
|
+
def purchase(money, authorization_or_credit_card, options = {})
|
73
|
+
requires!(options, :order_id)
|
74
|
+
|
75
|
+
if authorization_or_credit_card.is_a?(String)
|
76
|
+
request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
77
|
+
else
|
78
|
+
request = build_purchase_or_authorization_request_with_credit_card_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
79
|
+
end
|
80
|
+
|
81
|
+
commit(request)
|
64
82
|
end
|
65
|
-
|
83
|
+
|
66
84
|
# Performs an authorization, which reserves the funds on the customer's credit card, but does not
|
67
85
|
# charge the card.
|
68
|
-
#
|
86
|
+
#
|
69
87
|
# ==== Parameters
|
70
88
|
#
|
71
|
-
# * <tt>money</tt>
|
72
|
-
# * <tt>
|
73
|
-
# * <tt>options</tt>
|
74
|
-
|
75
|
-
|
89
|
+
# * <tt>money</tt> The amount to be authorized. Either an Integer value in cents or a Money object.
|
90
|
+
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
91
|
+
# * <tt>options</tt> A hash of optional parameters.
|
92
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
93
|
+
# * <tt>:set_up_continuous_authority</tt>::
|
94
|
+
# Set to true to set up a recurring historic transaction account be set up.
|
95
|
+
# Only supported for :visa, :master and :american_express card types
|
96
|
+
# See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
|
97
|
+
# * <tt>:address</tt>:: billing address for card
|
98
|
+
#
|
99
|
+
# The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
|
100
|
+
def authorize(money, authorization_or_credit_card, options = {})
|
101
|
+
requires!(options, :order_id)
|
102
|
+
|
103
|
+
if authorization_or_credit_card.is_a?(String)
|
104
|
+
request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
105
|
+
else
|
106
|
+
request = build_purchase_or_authorization_request_with_credit_card_request(PRE_TYPE, money, authorization_or_credit_card, options)
|
107
|
+
end
|
108
|
+
|
109
|
+
commit(request)
|
76
110
|
end
|
77
|
-
|
111
|
+
|
78
112
|
# Captures the funds from an authorized transaction.
|
79
113
|
#
|
80
114
|
# ==== Parameters
|
@@ -84,7 +118,7 @@ module ActiveMerchant
|
|
84
118
|
def capture(money, authorization, options = {})
|
85
119
|
commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
|
86
120
|
end
|
87
|
-
|
121
|
+
|
88
122
|
# Void a previous transaction
|
89
123
|
#
|
90
124
|
# ==== Parameters
|
@@ -92,15 +126,34 @@ module ActiveMerchant
|
|
92
126
|
# * <tt>authorization</tt> - The authorization returned from the previous authorize request.
|
93
127
|
def void(authorization, options = {})
|
94
128
|
request = build_void_or_capture_request(CANCEL_TYPE, nil, authorization, options)
|
95
|
-
|
129
|
+
|
96
130
|
commit(request)
|
97
131
|
end
|
98
|
-
|
132
|
+
|
133
|
+
# Refund to a card
|
134
|
+
#
|
135
|
+
# ==== Parameters
|
136
|
+
#
|
137
|
+
# * <tt>money</tt> The amount to be refunded. Either an Integer value in cents or a Money object. Set to nil for a full refund on existing transaction.
|
138
|
+
# * <tt>reference_or_credit_card</tt> The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding
|
139
|
+
# * <tt>options</tt> Are ignored when refunding via reference to an existing transaction, otherwise
|
140
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
141
|
+
# * <tt>:address</tt>:: billing address for card
|
142
|
+
def credit(money, reference_or_credit_card, options = {})
|
143
|
+
if reference_or_credit_card.is_a?(String)
|
144
|
+
request = build_transaction_refund_request(money, reference_or_credit_card)
|
145
|
+
else
|
146
|
+
request = build_refund_request(money, reference_or_credit_card, options)
|
147
|
+
end
|
148
|
+
|
149
|
+
commit(request)
|
150
|
+
end
|
151
|
+
|
99
152
|
# Is the gateway running in test mode?
|
100
153
|
def test?
|
101
154
|
@options[:test] || super
|
102
155
|
end
|
103
|
-
|
156
|
+
|
104
157
|
private
|
105
158
|
# Create the xml document for a 'cancel' or 'fulfill' transaction.
|
106
159
|
#
|
@@ -123,19 +176,18 @@ module ActiveMerchant
|
|
123
176
|
# </Request>
|
124
177
|
#
|
125
178
|
# Parameters:
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
# -order_id - The merchants reference
|
179
|
+
# * <tt>type</tt> must be FULFILL_TYPE or CANCEL_TYPE
|
180
|
+
# * <tt>money</tt> - optional - Money object or value in cents
|
181
|
+
# * <tt>authorization</tt> - the Datacash authorization from a previous succesful authorize transaction
|
182
|
+
# * <tt>options</tt>
|
183
|
+
# * <tt>order_id</tt> - A unique reference for the transaction
|
132
184
|
#
|
133
185
|
# Returns:
|
134
186
|
# -Builder xml document
|
135
187
|
#
|
136
188
|
def build_void_or_capture_request(type, money, authorization, options)
|
137
|
-
reference, auth_code = authorization.to_s.split(';')
|
138
|
-
|
189
|
+
reference, auth_code, ca_reference = authorization.to_s.split(';')
|
190
|
+
|
139
191
|
xml = Builder::XmlMarkup.new :indent => 2
|
140
192
|
xml.instruct!
|
141
193
|
xml.tag! :Request do
|
@@ -158,8 +210,8 @@ module ActiveMerchant
|
|
158
210
|
end
|
159
211
|
xml.target!
|
160
212
|
end
|
161
|
-
|
162
|
-
# Create the xml document for an 'auth' or 'pre' transaction
|
213
|
+
|
214
|
+
# Create the xml document for an 'auth' or 'pre' transaction with a credit card
|
163
215
|
#
|
164
216
|
# Final XML should look like:
|
165
217
|
#
|
@@ -203,7 +255,7 @@ module ActiveMerchant
|
|
203
255
|
# </ExtendedPolicy>
|
204
256
|
# </Cv2Avs>
|
205
257
|
# </Card>
|
206
|
-
# <method>auth
|
258
|
+
# <method>auth</method>
|
207
259
|
# </CardTxn>
|
208
260
|
# </Transaction>
|
209
261
|
# </Request>
|
@@ -220,27 +272,171 @@ module ActiveMerchant
|
|
220
272
|
# Returns:
|
221
273
|
# -xml: Builder document containing the markup
|
222
274
|
#
|
223
|
-
def
|
275
|
+
def build_purchase_or_authorization_request_with_credit_card_request(type, money, credit_card, options)
|
224
276
|
xml = Builder::XmlMarkup.new :indent => 2
|
225
277
|
xml.instruct!
|
226
278
|
xml.tag! :Request do
|
227
279
|
add_authentication(xml)
|
228
280
|
|
229
281
|
xml.tag! :Transaction do
|
282
|
+
if options[:set_up_continuous_authority]
|
283
|
+
xml.tag! :ContAuthTxn, :type => 'setup'
|
284
|
+
end
|
230
285
|
xml.tag! :CardTxn do
|
231
286
|
xml.tag! :method, type
|
232
|
-
|
233
|
-
|
287
|
+
add_credit_card(xml, credit_card, options[:billing_address])
|
288
|
+
end
|
289
|
+
xml.tag! :TxnDetails do
|
290
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
291
|
+
xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|
295
|
+
xml.target!
|
296
|
+
end
|
297
|
+
|
298
|
+
# Create the xml document for an 'auth' or 'pre' transaction with
|
299
|
+
# continuous authorization
|
300
|
+
#
|
301
|
+
# Final XML should look like:
|
302
|
+
#
|
303
|
+
# <Request>
|
304
|
+
# <Transaction>
|
305
|
+
# <ContAuthTxn type="historic" />
|
306
|
+
# <TxnDetails>
|
307
|
+
# <merchantreference>3851231</merchantreference>
|
308
|
+
# <capturemethod>cont_auth</capturemethod>
|
309
|
+
# <amount currency="GBP">18.50</amount>
|
310
|
+
# </TxnDetails>
|
311
|
+
# <HistoricTxn>
|
312
|
+
# <reference>4500200040925092</reference>
|
313
|
+
# <method>auth</method>
|
314
|
+
# </HistoricTxn>
|
315
|
+
# </Transaction>
|
316
|
+
# <Authentication>
|
317
|
+
# <client>99000001</client>
|
318
|
+
# <password>mypasswd</password>
|
319
|
+
# </Authentication>
|
320
|
+
# </Request>
|
321
|
+
#
|
322
|
+
# Parameters:
|
323
|
+
# -type must be 'auth' or 'pre'
|
324
|
+
# -money - A money object with the price and currency
|
325
|
+
# -authorization - The authorization containing a continuous authority reference previously set up on a credit card
|
326
|
+
# -options:
|
327
|
+
# :order_id is the merchant reference number
|
328
|
+
#
|
329
|
+
# Returns:
|
330
|
+
# -xml: Builder document containing the markup
|
331
|
+
#
|
332
|
+
def build_purchase_or_authorization_request_with_continuous_authority_reference_request(type, money, authorization, options)
|
333
|
+
reference, auth_code, ca_reference = authorization.to_s.split(';')
|
334
|
+
raise ArgumentError, "The continuous authority reference is required for continuous authority transactions" if ca_reference.blank?
|
335
|
+
|
336
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
337
|
+
xml.instruct!
|
338
|
+
xml.tag! :Request do
|
339
|
+
add_authentication(xml)
|
340
|
+
xml.tag! :Transaction do
|
341
|
+
xml.tag! :ContAuthTxn, :type => 'historic'
|
342
|
+
xml.tag! :HistoricTxn do
|
343
|
+
xml.tag! :reference, ca_reference
|
344
|
+
xml.tag! :method, type
|
234
345
|
end
|
235
346
|
xml.tag! :TxnDetails do
|
236
347
|
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
237
348
|
xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)
|
349
|
+
xml.tag! :capturemethod, 'cont_auth'
|
238
350
|
end
|
239
351
|
end
|
240
352
|
end
|
241
353
|
xml.target!
|
242
354
|
end
|
243
|
-
|
355
|
+
|
356
|
+
# Create the xml document for a full or partial refund transaction with
|
357
|
+
#
|
358
|
+
# Final XML should look like:
|
359
|
+
#
|
360
|
+
# <Request>
|
361
|
+
# <Authentication>
|
362
|
+
# <client>99000001</client>
|
363
|
+
# <password>*******</password>
|
364
|
+
# </Authentication>
|
365
|
+
# <Transaction>
|
366
|
+
# <HistoricTxn>
|
367
|
+
# <method>txn_refund</method>
|
368
|
+
# <reference>12345678</reference>
|
369
|
+
# </HistoricTxn>
|
370
|
+
# <TxnDetails>
|
371
|
+
# <amount>10.00</amount>
|
372
|
+
# </TxnDetails>
|
373
|
+
# </Transaction>
|
374
|
+
# </Request>
|
375
|
+
#
|
376
|
+
def build_transaction_refund_request(money, reference)
|
377
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
378
|
+
xml.instruct!
|
379
|
+
xml.tag! :Request do
|
380
|
+
add_authentication(xml)
|
381
|
+
xml.tag! :Transaction do
|
382
|
+
xml.tag! :HistoricTxn do
|
383
|
+
xml.tag! :reference, reference
|
384
|
+
xml.tag! :method, TRANSACTION_REFUND_TYPE
|
385
|
+
end
|
386
|
+
unless money.nil?
|
387
|
+
xml.tag! :TxnDetails do
|
388
|
+
xml.tag! :amount, amount(money)
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
xml.target!
|
394
|
+
end
|
395
|
+
|
396
|
+
# Create the xml document for a full or partial refund with
|
397
|
+
#
|
398
|
+
# Final XML should look like:
|
399
|
+
#
|
400
|
+
# <Request>
|
401
|
+
# <Authentication>
|
402
|
+
# <client>99000001</client>
|
403
|
+
# <password>*****</password>
|
404
|
+
# </Authentication>
|
405
|
+
# <Transaction>
|
406
|
+
# <CardTxn>
|
407
|
+
# <Card>
|
408
|
+
# <pan>633300*********1</pan>
|
409
|
+
# <expirydate>04/06</expirydate>
|
410
|
+
# <startdate>01/04</startdate>
|
411
|
+
# </Card>
|
412
|
+
# <method>refund</method>
|
413
|
+
# </CardTxn>
|
414
|
+
# <TxnDetails>
|
415
|
+
# <merchantreference>1000001</merchantreference>
|
416
|
+
# <amount currency="GBP">95.99</amount>
|
417
|
+
# </TxnDetails>
|
418
|
+
# </Transaction>
|
419
|
+
# </Request>
|
420
|
+
def build_refund_request(money, credit_card, options)
|
421
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
422
|
+
xml.instruct!
|
423
|
+
xml.tag! :Request do
|
424
|
+
add_authentication(xml)
|
425
|
+
xml.tag! :Transaction do
|
426
|
+
xml.tag! :CardTxn do
|
427
|
+
xml.tag! :method, REFUND_TYPE
|
428
|
+
add_credit_card(xml, credit_card, options[:billing_address])
|
429
|
+
end
|
430
|
+
xml.tag! :TxnDetails do
|
431
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
432
|
+
xml.tag! :amount, amount(money)
|
433
|
+
end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
xml.target!
|
437
|
+
end
|
438
|
+
|
439
|
+
|
244
440
|
# Adds the authentication element to the passed builder xml doc
|
245
441
|
#
|
246
442
|
# Parameters:
|
@@ -255,7 +451,7 @@ module ActiveMerchant
|
|
255
451
|
xml.tag! :password, @options[:password]
|
256
452
|
end
|
257
453
|
end
|
258
|
-
|
454
|
+
|
259
455
|
# Add credit_card detals to the passed XML Builder doc
|
260
456
|
#
|
261
457
|
# Parameters:
|
@@ -269,21 +465,21 @@ module ActiveMerchant
|
|
269
465
|
def add_credit_card(xml, credit_card, address)
|
270
466
|
|
271
467
|
xml.tag! :Card do
|
272
|
-
|
468
|
+
|
273
469
|
# DataCash calls the CC number 'pan'
|
274
470
|
xml.tag! :pan, credit_card.number
|
275
471
|
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
|
276
|
-
|
472
|
+
|
277
473
|
# optional values - for Solo etc
|
278
474
|
if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
|
279
475
|
|
280
476
|
xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?
|
281
|
-
|
477
|
+
|
282
478
|
if !credit_card.start_month.blank? && !credit_card.start_year.blank?
|
283
479
|
xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)
|
284
480
|
end
|
285
481
|
end
|
286
|
-
|
482
|
+
|
287
483
|
xml.tag! :Cv2Avs do
|
288
484
|
xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?
|
289
485
|
if address
|
@@ -293,7 +489,7 @@ module ActiveMerchant
|
|
293
489
|
xml.tag! :street_address4, address[:address4] unless address[:address4].blank?
|
294
490
|
xml.tag! :postcode, address[:zip] unless address[:zip].blank?
|
295
491
|
end
|
296
|
-
|
492
|
+
|
297
493
|
# The ExtendedPolicy defines what to do when the passed data
|
298
494
|
# matches, or not...
|
299
495
|
#
|
@@ -323,7 +519,7 @@ module ActiveMerchant
|
|
323
519
|
end
|
324
520
|
end
|
325
521
|
end
|
326
|
-
|
522
|
+
|
327
523
|
# Send the passed data to DataCash for processing
|
328
524
|
#
|
329
525
|
# Parameters:
|
@@ -337,10 +533,10 @@ module ActiveMerchant
|
|
337
533
|
|
338
534
|
Response.new(response[:status] == DATACASH_SUCCESS, response[:reason], response,
|
339
535
|
:test => test?,
|
340
|
-
:authorization => "#{response[:datacash_reference]};#{response[:authcode]}"
|
536
|
+
:authorization => "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}"
|
341
537
|
)
|
342
538
|
end
|
343
|
-
|
539
|
+
|
344
540
|
# Returns a date string in the format Datacash expects
|
345
541
|
#
|
346
542
|
# Parameters:
|
@@ -353,7 +549,7 @@ module ActiveMerchant
|
|
353
549
|
def format_date(month, year)
|
354
550
|
"#{format(month,:two_digits)}/#{format(year, :two_digits)}"
|
355
551
|
end
|
356
|
-
|
552
|
+
|
357
553
|
# Parse the datacash response and create a Response object
|
358
554
|
#
|
359
555
|
# Parameters:
|
@@ -363,18 +559,18 @@ module ActiveMerchant
|
|
363
559
|
# -a hash with all of the values returned in the Datacash XML response
|
364
560
|
#
|
365
561
|
def parse(body)
|
366
|
-
|
562
|
+
|
367
563
|
response = {}
|
368
564
|
xml = REXML::Document.new(body)
|
369
565
|
root = REXML::XPath.first(xml, "//Response")
|
370
|
-
|
566
|
+
|
371
567
|
root.elements.to_a.each do |node|
|
372
568
|
parse_element(response, node)
|
373
569
|
end
|
374
|
-
|
570
|
+
|
375
571
|
response
|
376
572
|
end
|
377
|
-
|
573
|
+
|
378
574
|
# Parse an xml element
|
379
575
|
#
|
380
576
|
# Parameters:
|
@@ -390,7 +586,7 @@ module ActiveMerchant
|
|
390
586
|
response[node.name.underscore.to_sym] = node.text
|
391
587
|
end
|
392
588
|
end
|
393
|
-
|
589
|
+
|
394
590
|
def format_reference_number(number)
|
395
591
|
number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, "0").first(30)
|
396
592
|
end
|