fishman-activemerchant 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +733 -0
- data/CONTRIBUTORS +257 -0
- data/MIT-LICENSE +20 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +47 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +260 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +170 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +693 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +858 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +139 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +282 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +142 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +303 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +430 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +597 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +235 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/epay.rb +274 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +264 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +168 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +177 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +262 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +250 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +13 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +29 -0
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +55 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +221 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +258 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +276 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +454 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +156 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +289 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +209 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +239 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +13 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +292 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +274 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +321 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +253 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +222 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +235 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +354 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +49 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +184 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +25 -0
- data/lib/active_merchant/billing/gateways/paypal_express_de.rb +14 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +201 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +298 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +219 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +297 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +282 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +297 -0
- data/lib/active_merchant/billing/gateways/realex.rb +311 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +320 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +330 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +193 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +271 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +212 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +423 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +233 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +280 -0
- data/lib/active_merchant/billing/integrations.rb +17 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/direc_pay.rb +41 -0
- data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +200 -0
- data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +76 -0
- data/lib/active_merchant/billing/integrations/direc_pay/return.rb +32 -0
- data/lib/active_merchant/billing/integrations/direc_pay/status.rb +37 -0
- data/lib/active_merchant/billing/integrations/directebanking.rb +47 -0
- data/lib/active_merchant/billing/integrations/directebanking/helper.rb +90 -0
- data/lib/active_merchant/billing/integrations/directebanking/notification.rb +120 -0
- data/lib/active_merchant/billing/integrations/directebanking/return.rb +11 -0
- data/lib/active_merchant/billing/integrations/dwolla.rb +30 -0
- data/lib/active_merchant/billing/integrations/dwolla/helper.rb +28 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +50 -0
- data/lib/active_merchant/billing/integrations/dwolla/return.rb +38 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans.rb +48 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +34 -0
- data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +84 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +96 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/moneybookers.rb +26 -0
- data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +129 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/payflow_link.rb +21 -0
- data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +78 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +21 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +42 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form.rb +37 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +33 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +111 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +210 -0
- data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +31 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/valitor.rb +33 -0
- data/lib/active_merchant/billing/integrations/valitor/helper.rb +86 -0
- data/lib/active_merchant/billing/integrations/valitor/notification.rb +13 -0
- data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +97 -0
- data/lib/active_merchant/billing/integrations/valitor/return.rb +13 -0
- data/lib/active_merchant/billing/integrations/world_pay.rb +27 -0
- data/lib/active_merchant/billing/integrations/world_pay/helper.rb +100 -0
- data/lib/active_merchant/billing/integrations/world_pay/notification.rb +160 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +58 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +335 -0
@@ -0,0 +1,597 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
class DataCashGateway < Gateway
|
4
|
+
self.default_currency = 'GBP'
|
5
|
+
self.supported_countries = ['GB']
|
6
|
+
|
7
|
+
# From the DataCash docs; Page 13, the following cards are
|
8
|
+
# usable:
|
9
|
+
# American Express, ATM, Carte Blanche, Diners Club, Discover,
|
10
|
+
# EnRoute, GE Capital, JCB, Laser, Maestro, Mastercard, Solo,
|
11
|
+
# Switch, Visa, Visa Delta, VISA Electron, Visa Purchasing
|
12
|
+
#
|
13
|
+
# Note continuous authority is only supported for :visa, :master and :american_express card types
|
14
|
+
self.supported_cardtypes = [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ]
|
15
|
+
|
16
|
+
self.homepage_url = 'http://www.datacash.com/'
|
17
|
+
self.display_name = 'DataCash'
|
18
|
+
|
19
|
+
# Datacash server URLs
|
20
|
+
TEST_URL = 'https://testserver.datacash.com/Transaction'
|
21
|
+
LIVE_URL = 'https://mars.transaction.datacash.com/Transaction'
|
22
|
+
|
23
|
+
# Different Card Transaction Types
|
24
|
+
AUTH_TYPE = 'auth'
|
25
|
+
CANCEL_TYPE = 'cancel'
|
26
|
+
FULFILL_TYPE = 'fulfill'
|
27
|
+
PRE_TYPE = 'pre'
|
28
|
+
REFUND_TYPE = 'refund'
|
29
|
+
TRANSACTION_REFUND_TYPE = 'txn_refund'
|
30
|
+
|
31
|
+
# Constant strings for use in the ExtendedPolicy complex element for
|
32
|
+
# CV2 checks
|
33
|
+
POLICY_ACCEPT = 'accept'
|
34
|
+
POLICY_REJECT = 'reject'
|
35
|
+
|
36
|
+
# Datacash success code
|
37
|
+
DATACASH_SUCCESS = '1'
|
38
|
+
|
39
|
+
# Creates a new DataCashGateway
|
40
|
+
#
|
41
|
+
# The gateway requires that a valid login and password be passed
|
42
|
+
# in the +options+ hash.
|
43
|
+
#
|
44
|
+
# ==== Options
|
45
|
+
#
|
46
|
+
# * <tt>:login</tt> -- The Datacash account login.
|
47
|
+
# * <tt>:password</tt> -- The Datacash account password.
|
48
|
+
# * <tt>:test => +true+ or +false+</tt> -- Use the test or live Datacash url.
|
49
|
+
#
|
50
|
+
def initialize(options = {})
|
51
|
+
requires!(options, :login, :password)
|
52
|
+
@options = options
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
57
|
+
#
|
58
|
+
# ==== Parameters
|
59
|
+
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
|
60
|
+
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
61
|
+
# * <tt>options</tt> A hash of optional parameters.
|
62
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
63
|
+
# * <tt>:set_up_continuous_authority</tt>
|
64
|
+
# Set to true to set up a recurring historic transaction account be set up.
|
65
|
+
# Only supported for :visa, :master and :american_express card types
|
66
|
+
# See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
|
67
|
+
# * <tt>:address</tt>:: billing address for card
|
68
|
+
#
|
69
|
+
# The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
|
70
|
+
def purchase(money, authorization_or_credit_card, options = {})
|
71
|
+
requires!(options, :order_id)
|
72
|
+
|
73
|
+
if authorization_or_credit_card.is_a?(String)
|
74
|
+
request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
75
|
+
else
|
76
|
+
request = build_purchase_or_authorization_request_with_credit_card_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
77
|
+
end
|
78
|
+
|
79
|
+
commit(request)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Performs an authorization, which reserves the funds on the customer's credit card, but does not
|
83
|
+
# charge the card.
|
84
|
+
#
|
85
|
+
# ==== Parameters
|
86
|
+
#
|
87
|
+
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
|
88
|
+
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
89
|
+
# * <tt>options</tt> A hash of optional parameters.
|
90
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
91
|
+
# * <tt>:set_up_continuous_authority</tt>::
|
92
|
+
# Set to true to set up a recurring historic transaction account be set up.
|
93
|
+
# Only supported for :visa, :master and :american_express card types
|
94
|
+
# See http://www.datacash.com/services/recurring/historic.php for more details of historic transactions.
|
95
|
+
# * <tt>:address</tt>:: billing address for card
|
96
|
+
#
|
97
|
+
# The continuous authority reference will be available in response#params['ca_referece'] if you have requested one
|
98
|
+
def authorize(money, authorization_or_credit_card, options = {})
|
99
|
+
requires!(options, :order_id)
|
100
|
+
|
101
|
+
if authorization_or_credit_card.is_a?(String)
|
102
|
+
request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
|
103
|
+
else
|
104
|
+
request = build_purchase_or_authorization_request_with_credit_card_request(PRE_TYPE, money, authorization_or_credit_card, options)
|
105
|
+
end
|
106
|
+
|
107
|
+
commit(request)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Captures the funds from an authorized transaction.
|
111
|
+
#
|
112
|
+
# ==== Parameters
|
113
|
+
#
|
114
|
+
# * <tt>money</tt> -- The amount to be captured as anInteger value in cents.
|
115
|
+
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
|
116
|
+
def capture(money, authorization, options = {})
|
117
|
+
commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
|
118
|
+
end
|
119
|
+
|
120
|
+
# Void a previous transaction
|
121
|
+
#
|
122
|
+
# ==== Parameters
|
123
|
+
#
|
124
|
+
# * <tt>authorization</tt> - The authorization returned from the previous authorize request.
|
125
|
+
def void(authorization, options = {})
|
126
|
+
request = build_void_or_capture_request(CANCEL_TYPE, nil, authorization, options)
|
127
|
+
|
128
|
+
commit(request)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Refund to a card
|
132
|
+
#
|
133
|
+
# ==== Parameters
|
134
|
+
#
|
135
|
+
# * <tt>money</tt> The amount to be refunded as an Integer value in cents. Set to nil for a full refund on existing transaction.
|
136
|
+
# * <tt>reference_or_credit_card</tt> The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding
|
137
|
+
# * <tt>options</tt> Are ignored when refunding via reference to an existing transaction, otherwise
|
138
|
+
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
139
|
+
# * <tt>:address</tt>:: billing address for card
|
140
|
+
def credit(money, reference_or_credit_card, options = {})
|
141
|
+
if reference_or_credit_card.is_a?(String)
|
142
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
143
|
+
refund(money, reference_or_credit_card)
|
144
|
+
else
|
145
|
+
request = build_refund_request(money, reference_or_credit_card, options)
|
146
|
+
commit(request)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
def refund(money, reference, options = {})
|
151
|
+
commit(build_transaction_refund_request(money, reference))
|
152
|
+
end
|
153
|
+
|
154
|
+
# Is the gateway running in test mode?
|
155
|
+
def test?
|
156
|
+
@options[:test] || super
|
157
|
+
end
|
158
|
+
|
159
|
+
private
|
160
|
+
# Create the xml document for a 'cancel' or 'fulfill' transaction.
|
161
|
+
#
|
162
|
+
# Final XML should look like:
|
163
|
+
# <Request>
|
164
|
+
# <Authentication>
|
165
|
+
# <client>99000001</client>
|
166
|
+
# <password>******</password>
|
167
|
+
# </Authentication>
|
168
|
+
# <Transaction>
|
169
|
+
# <TxnDetails>
|
170
|
+
# <amount>25.00</amount>
|
171
|
+
# </TxnDetails>
|
172
|
+
# <HistoricTxn>
|
173
|
+
# <reference>4900200000000001</reference>
|
174
|
+
# <authcode>A6</authcode>
|
175
|
+
# <method>fulfill</method>
|
176
|
+
# </HistoricTxn>
|
177
|
+
# </Transaction>
|
178
|
+
# </Request>
|
179
|
+
#
|
180
|
+
# Parameters:
|
181
|
+
# * <tt>type</tt> must be FULFILL_TYPE or CANCEL_TYPE
|
182
|
+
# * <tt>money</tt> - optional - Integer value in cents
|
183
|
+
# * <tt>authorization</tt> - the Datacash authorization from a previous succesful authorize transaction
|
184
|
+
# * <tt>options</tt>
|
185
|
+
# * <tt>order_id</tt> - A unique reference for the transaction
|
186
|
+
#
|
187
|
+
# Returns:
|
188
|
+
# -Builder xml document
|
189
|
+
#
|
190
|
+
def build_void_or_capture_request(type, money, authorization, options)
|
191
|
+
reference, auth_code, ca_reference = authorization.to_s.split(';')
|
192
|
+
|
193
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
194
|
+
xml.instruct!
|
195
|
+
xml.tag! :Request do
|
196
|
+
add_authentication(xml)
|
197
|
+
|
198
|
+
xml.tag! :Transaction do
|
199
|
+
xml.tag! :HistoricTxn do
|
200
|
+
xml.tag! :reference, reference
|
201
|
+
xml.tag! :authcode, auth_code
|
202
|
+
xml.tag! :method, type
|
203
|
+
end
|
204
|
+
|
205
|
+
if money
|
206
|
+
xml.tag! :TxnDetails do
|
207
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
208
|
+
xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
xml.target!
|
214
|
+
end
|
215
|
+
|
216
|
+
# Create the xml document for an 'auth' or 'pre' transaction with a credit card
|
217
|
+
#
|
218
|
+
# Final XML should look like:
|
219
|
+
#
|
220
|
+
# <Request>
|
221
|
+
# <Authentication>
|
222
|
+
# <client>99000000</client>
|
223
|
+
# <password>*******</password>
|
224
|
+
# </Authentication>
|
225
|
+
# <Transaction>
|
226
|
+
# <TxnDetails>
|
227
|
+
# <merchantreference>123456</merchantreference>
|
228
|
+
# <amount currency="EUR">10.00</amount>
|
229
|
+
# </TxnDetails>
|
230
|
+
# <CardTxn>
|
231
|
+
# <Card>
|
232
|
+
# <pan>4444********1111</pan>
|
233
|
+
# <expirydate>03/04</expirydate>
|
234
|
+
# <Cv2Avs>
|
235
|
+
# <street_address1>Flat 7</street_address1>
|
236
|
+
# <street_address2>89 Jumble
|
237
|
+
# Street</street_address2>
|
238
|
+
# <street_address3>Mytown</street_address3>
|
239
|
+
# <postcode>AV12FR</postcode>
|
240
|
+
# <cv2>123</cv2>
|
241
|
+
# <ExtendedPolicy>
|
242
|
+
# <cv2_policy notprovided="reject"
|
243
|
+
# notchecked="accept"
|
244
|
+
# matched="accept"
|
245
|
+
# notmatched="reject"
|
246
|
+
# partialmatch="reject"/>
|
247
|
+
# <postcode_policy notprovided="reject"
|
248
|
+
# notchecked="accept"
|
249
|
+
# matched="accept"
|
250
|
+
# notmatched="reject"
|
251
|
+
# partialmatch="accept"/>
|
252
|
+
# <address_policy notprovided="reject"
|
253
|
+
# notchecked="accept"
|
254
|
+
# matched="accept"
|
255
|
+
# notmatched="reject"
|
256
|
+
# partialmatch="accept"/>
|
257
|
+
# </ExtendedPolicy>
|
258
|
+
# </Cv2Avs>
|
259
|
+
# </Card>
|
260
|
+
# <method>auth</method>
|
261
|
+
# </CardTxn>
|
262
|
+
# </Transaction>
|
263
|
+
# </Request>
|
264
|
+
#
|
265
|
+
# Parameters:
|
266
|
+
# -type must be 'auth' or 'pre'
|
267
|
+
# -money - A money object with the price and currency
|
268
|
+
# -credit_card - The credit_card details to use
|
269
|
+
# -options:
|
270
|
+
# :order_id is the merchant reference number
|
271
|
+
# :billing_address is the billing address for the cc
|
272
|
+
# :address is the delivery address
|
273
|
+
#
|
274
|
+
# Returns:
|
275
|
+
# -xml: Builder document containing the markup
|
276
|
+
#
|
277
|
+
def build_purchase_or_authorization_request_with_credit_card_request(type, money, credit_card, options)
|
278
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
279
|
+
xml.instruct!
|
280
|
+
xml.tag! :Request do
|
281
|
+
add_authentication(xml)
|
282
|
+
|
283
|
+
xml.tag! :Transaction do
|
284
|
+
if options[:set_up_continuous_authority]
|
285
|
+
xml.tag! :ContAuthTxn, :type => 'setup'
|
286
|
+
end
|
287
|
+
xml.tag! :CardTxn do
|
288
|
+
xml.tag! :method, type
|
289
|
+
add_credit_card(xml, credit_card, options[:billing_address])
|
290
|
+
end
|
291
|
+
xml.tag! :TxnDetails do
|
292
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
293
|
+
xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
xml.target!
|
298
|
+
end
|
299
|
+
|
300
|
+
# Create the xml document for an 'auth' or 'pre' transaction with
|
301
|
+
# continuous authorization
|
302
|
+
#
|
303
|
+
# Final XML should look like:
|
304
|
+
#
|
305
|
+
# <Request>
|
306
|
+
# <Transaction>
|
307
|
+
# <ContAuthTxn type="historic" />
|
308
|
+
# <TxnDetails>
|
309
|
+
# <merchantreference>3851231</merchantreference>
|
310
|
+
# <capturemethod>cont_auth</capturemethod>
|
311
|
+
# <amount currency="GBP">18.50</amount>
|
312
|
+
# </TxnDetails>
|
313
|
+
# <HistoricTxn>
|
314
|
+
# <reference>4500200040925092</reference>
|
315
|
+
# <method>auth</method>
|
316
|
+
# </HistoricTxn>
|
317
|
+
# </Transaction>
|
318
|
+
# <Authentication>
|
319
|
+
# <client>99000001</client>
|
320
|
+
# <password>mypasswd</password>
|
321
|
+
# </Authentication>
|
322
|
+
# </Request>
|
323
|
+
#
|
324
|
+
# Parameters:
|
325
|
+
# -type must be 'auth' or 'pre'
|
326
|
+
# -money - A money object with the price and currency
|
327
|
+
# -authorization - The authorization containing a continuous authority reference previously set up on a credit card
|
328
|
+
# -options:
|
329
|
+
# :order_id is the merchant reference number
|
330
|
+
#
|
331
|
+
# Returns:
|
332
|
+
# -xml: Builder document containing the markup
|
333
|
+
#
|
334
|
+
def build_purchase_or_authorization_request_with_continuous_authority_reference_request(type, money, authorization, options)
|
335
|
+
reference, auth_code, ca_reference = authorization.to_s.split(';')
|
336
|
+
raise ArgumentError, "The continuous authority reference is required for continuous authority transactions" if ca_reference.blank?
|
337
|
+
|
338
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
339
|
+
xml.instruct!
|
340
|
+
xml.tag! :Request do
|
341
|
+
add_authentication(xml)
|
342
|
+
xml.tag! :Transaction do
|
343
|
+
xml.tag! :ContAuthTxn, :type => 'historic'
|
344
|
+
xml.tag! :HistoricTxn do
|
345
|
+
xml.tag! :reference, ca_reference
|
346
|
+
xml.tag! :method, type
|
347
|
+
end
|
348
|
+
xml.tag! :TxnDetails do
|
349
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
350
|
+
xml.tag! :amount, amount(money), :currency => options[:currency] || currency(money)
|
351
|
+
xml.tag! :capturemethod, 'cont_auth'
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
xml.target!
|
356
|
+
end
|
357
|
+
|
358
|
+
# Create the xml document for a full or partial refund transaction with
|
359
|
+
#
|
360
|
+
# Final XML should look like:
|
361
|
+
#
|
362
|
+
# <Request>
|
363
|
+
# <Authentication>
|
364
|
+
# <client>99000001</client>
|
365
|
+
# <password>*******</password>
|
366
|
+
# </Authentication>
|
367
|
+
# <Transaction>
|
368
|
+
# <HistoricTxn>
|
369
|
+
# <method>txn_refund</method>
|
370
|
+
# <reference>12345678</reference>
|
371
|
+
# </HistoricTxn>
|
372
|
+
# <TxnDetails>
|
373
|
+
# <amount>10.00</amount>
|
374
|
+
# </TxnDetails>
|
375
|
+
# </Transaction>
|
376
|
+
# </Request>
|
377
|
+
#
|
378
|
+
def build_transaction_refund_request(money, reference)
|
379
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
380
|
+
xml.instruct!
|
381
|
+
xml.tag! :Request do
|
382
|
+
add_authentication(xml)
|
383
|
+
xml.tag! :Transaction do
|
384
|
+
xml.tag! :HistoricTxn do
|
385
|
+
xml.tag! :reference, reference
|
386
|
+
xml.tag! :method, TRANSACTION_REFUND_TYPE
|
387
|
+
end
|
388
|
+
unless money.nil?
|
389
|
+
xml.tag! :TxnDetails do
|
390
|
+
xml.tag! :amount, amount(money)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
xml.target!
|
396
|
+
end
|
397
|
+
|
398
|
+
# Create the xml document for a full or partial refund with
|
399
|
+
#
|
400
|
+
# Final XML should look like:
|
401
|
+
#
|
402
|
+
# <Request>
|
403
|
+
# <Authentication>
|
404
|
+
# <client>99000001</client>
|
405
|
+
# <password>*****</password>
|
406
|
+
# </Authentication>
|
407
|
+
# <Transaction>
|
408
|
+
# <CardTxn>
|
409
|
+
# <Card>
|
410
|
+
# <pan>633300*********1</pan>
|
411
|
+
# <expirydate>04/06</expirydate>
|
412
|
+
# <startdate>01/04</startdate>
|
413
|
+
# </Card>
|
414
|
+
# <method>refund</method>
|
415
|
+
# </CardTxn>
|
416
|
+
# <TxnDetails>
|
417
|
+
# <merchantreference>1000001</merchantreference>
|
418
|
+
# <amount currency="GBP">95.99</amount>
|
419
|
+
# </TxnDetails>
|
420
|
+
# </Transaction>
|
421
|
+
# </Request>
|
422
|
+
def build_refund_request(money, credit_card, options)
|
423
|
+
xml = Builder::XmlMarkup.new :indent => 2
|
424
|
+
xml.instruct!
|
425
|
+
xml.tag! :Request do
|
426
|
+
add_authentication(xml)
|
427
|
+
xml.tag! :Transaction do
|
428
|
+
xml.tag! :CardTxn do
|
429
|
+
xml.tag! :method, REFUND_TYPE
|
430
|
+
add_credit_card(xml, credit_card, options[:billing_address])
|
431
|
+
end
|
432
|
+
xml.tag! :TxnDetails do
|
433
|
+
xml.tag! :merchantreference, format_reference_number(options[:order_id])
|
434
|
+
xml.tag! :amount, amount(money)
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
438
|
+
xml.target!
|
439
|
+
end
|
440
|
+
|
441
|
+
|
442
|
+
# Adds the authentication element to the passed builder xml doc
|
443
|
+
#
|
444
|
+
# Parameters:
|
445
|
+
# -xml: Builder document that is being built up
|
446
|
+
#
|
447
|
+
# Returns:
|
448
|
+
# -none: The results is stored in the passed xml document
|
449
|
+
#
|
450
|
+
def add_authentication(xml)
|
451
|
+
xml.tag! :Authentication do
|
452
|
+
xml.tag! :client, @options[:login]
|
453
|
+
xml.tag! :password, @options[:password]
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
# Add credit_card detals to the passed XML Builder doc
|
458
|
+
#
|
459
|
+
# Parameters:
|
460
|
+
# -xml: Builder document that is being built up
|
461
|
+
# -credit_card: ActiveMerchant::Billing::CreditCard object
|
462
|
+
# -billing_address: Hash containing all of the billing address details
|
463
|
+
#
|
464
|
+
# Returns:
|
465
|
+
# -none: The results is stored in the passed xml document
|
466
|
+
#
|
467
|
+
def add_credit_card(xml, credit_card, address)
|
468
|
+
|
469
|
+
xml.tag! :Card do
|
470
|
+
|
471
|
+
# DataCash calls the CC number 'pan'
|
472
|
+
xml.tag! :pan, credit_card.number
|
473
|
+
xml.tag! :expirydate, format_date(credit_card.month, credit_card.year)
|
474
|
+
|
475
|
+
# optional values - for Solo etc
|
476
|
+
if [ 'switch', 'solo' ].include?(card_brand(credit_card).to_s)
|
477
|
+
|
478
|
+
xml.tag! :issuenumber, credit_card.issue_number unless credit_card.issue_number.blank?
|
479
|
+
|
480
|
+
if !credit_card.start_month.blank? && !credit_card.start_year.blank?
|
481
|
+
xml.tag! :startdate, format_date(credit_card.start_month, credit_card.start_year)
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
485
|
+
xml.tag! :Cv2Avs do
|
486
|
+
xml.tag! :cv2, credit_card.verification_value if credit_card.verification_value?
|
487
|
+
if address
|
488
|
+
xml.tag! :street_address1, address[:address1] unless address[:address1].blank?
|
489
|
+
xml.tag! :street_address2, address[:address2] unless address[:address2].blank?
|
490
|
+
xml.tag! :street_address3, address[:address3] unless address[:address3].blank?
|
491
|
+
xml.tag! :street_address4, address[:address4] unless address[:address4].blank?
|
492
|
+
xml.tag! :postcode, address[:zip] unless address[:zip].blank?
|
493
|
+
end
|
494
|
+
|
495
|
+
# The ExtendedPolicy defines what to do when the passed data
|
496
|
+
# matches, or not...
|
497
|
+
#
|
498
|
+
# All of the following elements MUST be present for the
|
499
|
+
# xml to be valid (or can drop the ExtendedPolicy and use
|
500
|
+
# a predefined one
|
501
|
+
xml.tag! :ExtendedPolicy do
|
502
|
+
xml.tag! :cv2_policy,
|
503
|
+
:notprovided => POLICY_REJECT,
|
504
|
+
:notchecked => POLICY_REJECT,
|
505
|
+
:matched => POLICY_ACCEPT,
|
506
|
+
:notmatched => POLICY_REJECT,
|
507
|
+
:partialmatch => POLICY_REJECT
|
508
|
+
xml.tag! :postcode_policy,
|
509
|
+
:notprovided => POLICY_ACCEPT,
|
510
|
+
:notchecked => POLICY_ACCEPT,
|
511
|
+
:matched => POLICY_ACCEPT,
|
512
|
+
:notmatched => POLICY_REJECT,
|
513
|
+
:partialmatch => POLICY_ACCEPT
|
514
|
+
xml.tag! :address_policy,
|
515
|
+
:notprovided => POLICY_ACCEPT,
|
516
|
+
:notchecked => POLICY_ACCEPT,
|
517
|
+
:matched => POLICY_ACCEPT,
|
518
|
+
:notmatched => POLICY_REJECT,
|
519
|
+
:partialmatch => POLICY_ACCEPT
|
520
|
+
end
|
521
|
+
end
|
522
|
+
end
|
523
|
+
end
|
524
|
+
|
525
|
+
# Send the passed data to DataCash for processing
|
526
|
+
#
|
527
|
+
# Parameters:
|
528
|
+
# -request: The XML data that is to be sent to Datacash
|
529
|
+
#
|
530
|
+
# Returns:
|
531
|
+
# - ActiveMerchant::Billing::Response object
|
532
|
+
#
|
533
|
+
def commit(request)
|
534
|
+
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, request))
|
535
|
+
|
536
|
+
Response.new(response[:status] == DATACASH_SUCCESS, response[:reason], response,
|
537
|
+
:test => test?,
|
538
|
+
:authorization => "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}"
|
539
|
+
)
|
540
|
+
end
|
541
|
+
|
542
|
+
# Returns a date string in the format Datacash expects
|
543
|
+
#
|
544
|
+
# Parameters:
|
545
|
+
# -month: integer, the month
|
546
|
+
# -year: integer, the year
|
547
|
+
#
|
548
|
+
# Returns:
|
549
|
+
# -String: date in MM/YY format
|
550
|
+
#
|
551
|
+
def format_date(month, year)
|
552
|
+
"#{format(month,:two_digits)}/#{format(year, :two_digits)}"
|
553
|
+
end
|
554
|
+
|
555
|
+
# Parse the datacash response and create a Response object
|
556
|
+
#
|
557
|
+
# Parameters:
|
558
|
+
# -body: The XML returned from Datacash
|
559
|
+
#
|
560
|
+
# Returns:
|
561
|
+
# -a hash with all of the values returned in the Datacash XML response
|
562
|
+
#
|
563
|
+
def parse(body)
|
564
|
+
|
565
|
+
response = {}
|
566
|
+
xml = REXML::Document.new(body)
|
567
|
+
root = REXML::XPath.first(xml, "//Response")
|
568
|
+
|
569
|
+
root.elements.to_a.each do |node|
|
570
|
+
parse_element(response, node)
|
571
|
+
end
|
572
|
+
|
573
|
+
response
|
574
|
+
end
|
575
|
+
|
576
|
+
# Parse an xml element
|
577
|
+
#
|
578
|
+
# Parameters:
|
579
|
+
# -response: The hash that the values are being returned in
|
580
|
+
# -node: The node that is currently being read
|
581
|
+
#
|
582
|
+
# Returns:
|
583
|
+
# - none (results are stored in the passed hash)
|
584
|
+
def parse_element(response, node)
|
585
|
+
if node.has_elements?
|
586
|
+
node.elements.each{|e| parse_element(response, e) }
|
587
|
+
else
|
588
|
+
response[node.name.underscore.to_sym] = node.text
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
def format_reference_number(number)
|
593
|
+
number.to_s.gsub(/[^A-Za-z0-9]/, '').rjust(6, "0").first(30)
|
594
|
+
end
|
595
|
+
end
|
596
|
+
end
|
597
|
+
end
|