tlconnor-activemerchant 1.20.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +805 -0
- data/CONTRIBUTORS +274 -0
- data/MIT-LICENSE +20 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant.rb +63 -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 +264 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +129 -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 +694 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +944 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +308 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +167 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +388 -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 +308 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +21 -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/certo_direct.rb +279 -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 +135 -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 +265 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -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 +157 -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 +239 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +244 -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 +330 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +277 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +344 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +46 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +397 -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 +261 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +208 -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 +229 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +25 -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 +298 -0
- data/lib/active_merchant/billing/gateways/realex.rb +315 -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/samurai.rb +121 -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 +280 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +458 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +271 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +244 -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 +23 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1496 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +206 -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 +72 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +38 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +228 -0
- data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +340 -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 +31 -0
- data/lib/active_merchant/billing/integrations/dwolla/notification.rb +55 -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 +113 -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 +100 -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 +127 -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 +22 -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 +411 -0
@@ -0,0 +1,308 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class BarclaysEpdqGateway < Gateway
|
4
|
+
TEST_URL = 'https://secure2.mde.epdq.co.uk:11500'
|
5
|
+
LIVE_URL = 'https://secure2.epdq.co.uk:11500'
|
6
|
+
|
7
|
+
self.supported_countries = ['UK']
|
8
|
+
self.default_currency = 'GBP'
|
9
|
+
self.supported_cardtypes = [:visa, :master, :maestro, :switch ]
|
10
|
+
self.money_format = :cents
|
11
|
+
self.homepage_url = 'http://www.barclaycard.co.uk/business/accepting-payments/epdq-mpi/'
|
12
|
+
self.display_name = 'Barclays ePDQ'
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
requires!(options, :login, :password, :client_id)
|
16
|
+
@options = options
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize(money, creditcard, options = {})
|
21
|
+
document = Document.new(self, @options) do
|
22
|
+
add_order_form(options[:order_id]) do
|
23
|
+
add_consumer(options) do
|
24
|
+
add_creditcard(creditcard)
|
25
|
+
end
|
26
|
+
add_transaction(:PreAuth, money)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
commit(document)
|
31
|
+
end
|
32
|
+
|
33
|
+
def purchase(money, creditcard, options = {})
|
34
|
+
# disable fraud checks if this is a repeat order:
|
35
|
+
if options[:payment_number] && (options[:payment_number] > 1)
|
36
|
+
no_fraud = true
|
37
|
+
else
|
38
|
+
no_fraud = options[:no_fraud]
|
39
|
+
end
|
40
|
+
document = Document.new(self, @options, :no_fraud => no_fraud) do
|
41
|
+
add_order_form(options[:order_id], options[:group_id]) do
|
42
|
+
add_consumer(options) do
|
43
|
+
add_creditcard(creditcard)
|
44
|
+
end
|
45
|
+
add_transaction(:Auth, money, options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
commit(document)
|
49
|
+
end
|
50
|
+
|
51
|
+
# authorization is your unique order ID, not the authorization
|
52
|
+
# code returned by ePDQ
|
53
|
+
def capture(money, authorization, options = {})
|
54
|
+
document = Document.new(self, @options) do
|
55
|
+
add_order_form(authorization) do
|
56
|
+
add_transaction(:PostAuth, money)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
commit(document)
|
61
|
+
end
|
62
|
+
|
63
|
+
# authorization is your unique order ID, not the authorization
|
64
|
+
# code returned by ePDQ
|
65
|
+
def credit(money, creditcard_or_authorization, options = {})
|
66
|
+
if creditcard_or_authorization.is_a?(String)
|
67
|
+
deprecated CREDIT_DEPRECATION_MESSAGE
|
68
|
+
refund(money, creditcard_or_authorization, options)
|
69
|
+
else
|
70
|
+
credit_new_order(money, creditcard_or_authorization, options)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def refund(money, authorization, options = {})
|
75
|
+
credit_existing_order(money, authorization, options)
|
76
|
+
end
|
77
|
+
|
78
|
+
def void(authorization, options = {})
|
79
|
+
document = Document.new(self, @options) do
|
80
|
+
add_order_form(authorization) do
|
81
|
+
add_transaction(:Void)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
commit(document)
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
def credit_new_order(money, creditcard, options)
|
90
|
+
document = Document.new(self, @options) do
|
91
|
+
add_order_form do
|
92
|
+
add_consumer(options) do
|
93
|
+
add_creditcard(creditcard)
|
94
|
+
end
|
95
|
+
add_transaction(:Credit, money)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
commit(document)
|
100
|
+
end
|
101
|
+
|
102
|
+
def credit_existing_order(money, authorization, options)
|
103
|
+
order_id, _ = authorization.split(":")
|
104
|
+
document = Document.new(self, @options) do
|
105
|
+
add_order_form(order_id) do
|
106
|
+
add_transaction(:Credit, money)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
commit(document)
|
111
|
+
end
|
112
|
+
|
113
|
+
def parse(body)
|
114
|
+
parser = Parser.new(body)
|
115
|
+
response = parser.parse
|
116
|
+
Response.new(response[:success], response[:message], response,
|
117
|
+
:test => test?,
|
118
|
+
:authorization => response[:authorization],
|
119
|
+
:avs_result => response[:avsresponse],
|
120
|
+
:cvv_result => response[:cvv_result],
|
121
|
+
:order_id => response[:order_id],
|
122
|
+
:raw_response => response[:raw_response]
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
126
|
+
def commit(document)
|
127
|
+
url = (test? ? TEST_URL : LIVE_URL)
|
128
|
+
data = ssl_post(url, document.to_xml)
|
129
|
+
parse(data)
|
130
|
+
end
|
131
|
+
|
132
|
+
class Parser
|
133
|
+
def initialize(response)
|
134
|
+
@response = response
|
135
|
+
end
|
136
|
+
|
137
|
+
def parse
|
138
|
+
doc = REXML::Document.new(@response)
|
139
|
+
auth_type = find(doc, "//Transaction/Type").to_s
|
140
|
+
|
141
|
+
message = find(doc, "//Message/Text")
|
142
|
+
if message.blank?
|
143
|
+
message = find(doc, "//Transaction/CardProcResp/CcReturnMsg")
|
144
|
+
end
|
145
|
+
|
146
|
+
case auth_type
|
147
|
+
when 'Credit', 'Void'
|
148
|
+
success = find(doc, "//CcReturnMsg") == "Approved."
|
149
|
+
else
|
150
|
+
success = find(doc, "//Transaction/AuthCode").present?
|
151
|
+
end
|
152
|
+
|
153
|
+
{
|
154
|
+
:success => success,
|
155
|
+
:message => message,
|
156
|
+
:authorization => find(doc, "//Transaction/Id"),
|
157
|
+
:avs_result => find(doc, "//Transaction/AvsRespCode"),
|
158
|
+
:cvv_result => find(doc, "//Transaction/Cvv2Resp"),
|
159
|
+
:order_id => find(doc, "//OrderFormDoc/Transaction/Id"),
|
160
|
+
:raw_response => @response
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
def find(doc, xpath)
|
165
|
+
REXML::XPath.first(doc, xpath).try(:text)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
class Document
|
170
|
+
attr_reader :type, :xml
|
171
|
+
|
172
|
+
PAYMENT_INTERVALS = {
|
173
|
+
:days => 'D',
|
174
|
+
:months => 'M'
|
175
|
+
}
|
176
|
+
|
177
|
+
EPDQ_CARD_TYPES = {
|
178
|
+
:visa => 1,
|
179
|
+
:master => 2,
|
180
|
+
:switch => 9,
|
181
|
+
:maestro => 10,
|
182
|
+
}
|
183
|
+
|
184
|
+
def initialize(gateway, options = {}, document_options = {}, &block)
|
185
|
+
@gateway = gateway
|
186
|
+
@options = options
|
187
|
+
@document_options = document_options
|
188
|
+
@xml = Builder::XmlMarkup.new(:indent => 2)
|
189
|
+
build(&block)
|
190
|
+
end
|
191
|
+
|
192
|
+
def to_xml
|
193
|
+
@xml.target!
|
194
|
+
end
|
195
|
+
|
196
|
+
def build(&block)
|
197
|
+
xml.instruct!(:xml, :version => '1.0')
|
198
|
+
xml.EngineDocList do
|
199
|
+
xml.DocVersion "1.0"
|
200
|
+
xml.EngineDoc do
|
201
|
+
xml.ContentType "OrderFormDoc"
|
202
|
+
xml.User do
|
203
|
+
xml.Name(@options[:login])
|
204
|
+
xml.Password(@options[:password])
|
205
|
+
xml.ClientId({ :DataType => "S32" }, @options[:client_id])
|
206
|
+
end
|
207
|
+
xml.Instructions do
|
208
|
+
if @document_options[:no_fraud]
|
209
|
+
xml.Pipeline "PaymentNoFraud"
|
210
|
+
else
|
211
|
+
xml.Pipeline "Payment"
|
212
|
+
end
|
213
|
+
end
|
214
|
+
instance_eval(&block)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def add_order_form(order_id=nil, group_id=nil, &block)
|
220
|
+
xml.OrderFormDoc do
|
221
|
+
xml.Mode 'P'
|
222
|
+
xml.Id(order_id) if order_id
|
223
|
+
xml.GroupId(group_id) if group_id
|
224
|
+
instance_eval(&block)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def add_consumer(options=nil, &block)
|
229
|
+
xml.Consumer do
|
230
|
+
if options
|
231
|
+
xml.Email(options[:email]) if options[:email]
|
232
|
+
billing_address = options[:billing_address] || options[:address]
|
233
|
+
if billing_address
|
234
|
+
xml.BillTo do
|
235
|
+
xml.Location do
|
236
|
+
xml.Address do
|
237
|
+
xml.Street1 billing_address[:address1]
|
238
|
+
xml.Street2 billing_address[:address2]
|
239
|
+
xml.City billing_address[:city]
|
240
|
+
xml.StateProv billing_address[:state]
|
241
|
+
xml.PostalCode billing_address[:zip]
|
242
|
+
xml.Country billing_address[:country_code]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
instance_eval(&block)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
def add_creditcard(creditcard)
|
253
|
+
xml.PaymentMech do
|
254
|
+
xml.CreditCard do
|
255
|
+
xml.Type({ :DataType => 'S32' }, EPDQ_CARD_TYPES[creditcard.brand.to_sym])
|
256
|
+
xml.Number creditcard.number
|
257
|
+
xml.Expires({ :DataType => 'ExpirationDate', :Locale => 826 }, format_expiry_date(creditcard))
|
258
|
+
if creditcard.verification_value.present?
|
259
|
+
xml.Cvv2Indicator 1
|
260
|
+
xml.Cvv2Val creditcard.verification_value
|
261
|
+
else
|
262
|
+
xml.Cvv2Indicator 5
|
263
|
+
end
|
264
|
+
xml.IssueNum(creditcard.issue_number) if creditcard.issue_number.present?
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def add_transaction(auth_type, amount = nil, options = {})
|
270
|
+
@auth_type = auth_type
|
271
|
+
xml.Transaction do
|
272
|
+
xml.Type @auth_type.to_s
|
273
|
+
if options[:payment_number] && options[:payment_number] > 1
|
274
|
+
xml.CardholderPresentCode({ :DataType => 'S32' }, 8)
|
275
|
+
else
|
276
|
+
xml.CardholderPresentCode({ :DataType => 'S32' }, 7)
|
277
|
+
end
|
278
|
+
if options[:payment_number]
|
279
|
+
xml.PaymentNumber({ :DataType => 'S32' }, options[:payment_number])
|
280
|
+
end
|
281
|
+
if options[:total_payments]
|
282
|
+
xml.TotalNumberPayments({ :DataType => 'S32' }, options[:total_payments])
|
283
|
+
end
|
284
|
+
if amount
|
285
|
+
xml.CurrentTotals do
|
286
|
+
xml.Totals do
|
287
|
+
xml.Total({ :DataType => 'Money', :Currency => 826 }, amount)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
# date must be formatted MM/YY
|
295
|
+
def format_expiry_date(creditcard)
|
296
|
+
month_str = "%02d" % creditcard.month
|
297
|
+
if match = creditcard.year.to_s.match(/^\d{2}(\d{2})$/)
|
298
|
+
year_str = "%02d" % match[1].to_i
|
299
|
+
else
|
300
|
+
year_str = "%02d" % creditcard.year
|
301
|
+
end
|
302
|
+
"#{month_str}/#{year_str}"
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
@@ -0,0 +1,167 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/beanstream/beanstream_core'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# This class implements the Canadian {Beanstream}[http://www.beanstream.com] payment gateway.
|
6
|
+
# It is also named TD Canada Trust Online Mart payment gateway.
|
7
|
+
# To learn more about the specification of Beanstream gateway, please read the OM_Direct_Interface_API.pdf,
|
8
|
+
# which you can get from your Beanstream account or get from me by email.
|
9
|
+
#
|
10
|
+
# == Supported transaction types by Beanstream:
|
11
|
+
# * +P+ - Purchase
|
12
|
+
# * +PA+ - Pre Authorization
|
13
|
+
# * +PAC+ - Pre Authorization Completion
|
14
|
+
#
|
15
|
+
# == Secure Payment Profiles:
|
16
|
+
# BeanStream supports payment profiles (vaults). This allows you to store cc information with BeanStream and process subsequent transactions with a customer id.
|
17
|
+
# Secure Payment Profiles must be enabled on your account (must be done over the phone).
|
18
|
+
# Your API Access Passcode must be set in Administration => account settings => order settings.
|
19
|
+
# To learn more about storing credit cards with the Beanstream gateway, please read the BEAN_Payment_Profiles.pdf (I had to phone BeanStream to request it.)
|
20
|
+
#
|
21
|
+
# == Notes
|
22
|
+
# * Adding of order products information is not implemented.
|
23
|
+
# * Ensure that country and province data is provided as a code such as "CA", "US", "QC".
|
24
|
+
# * login is the Beanstream merchant ID, username and password should be enabled in your Beanstream account and passed in using the <tt>:user</tt> and <tt>:password</tt> options.
|
25
|
+
# * Test your app with your true merchant id and test credit card information provided in the api pdf document.
|
26
|
+
# * Beanstream does not allow Payment Profiles to be deleted with their API. The accounts are 'closed', but have to be deleted manually.
|
27
|
+
#
|
28
|
+
# Example authorization (Beanstream PA transaction type):
|
29
|
+
#
|
30
|
+
# twenty = 2000
|
31
|
+
# gateway = BeanstreamGateway.new(
|
32
|
+
# :login => '100200000',
|
33
|
+
# :user => 'xiaobozz',
|
34
|
+
# :password => 'password'
|
35
|
+
# )
|
36
|
+
#
|
37
|
+
# credit_card = CreditCard.new(
|
38
|
+
# :number => '4030000010001234',
|
39
|
+
# :month => 8,
|
40
|
+
# :year => 2011,
|
41
|
+
# :first_name => 'xiaobo',
|
42
|
+
# :last_name => 'zzz',
|
43
|
+
# :verification_value => 137
|
44
|
+
# )
|
45
|
+
# response = gateway.authorize(twenty, credit_card,
|
46
|
+
# :order_id => '1234',
|
47
|
+
# :billing_address => {
|
48
|
+
# :name => 'xiaobo zzz',
|
49
|
+
# :phone => '555-555-5555',
|
50
|
+
# :address1 => '1234 Levesque St.',
|
51
|
+
# :address2 => 'Apt B',
|
52
|
+
# :city => 'Montreal',
|
53
|
+
# :state => 'QC',
|
54
|
+
# :country => 'CA',
|
55
|
+
# :zip => 'H2C1X8'
|
56
|
+
# },
|
57
|
+
# :email => 'xiaobozzz@example.com',
|
58
|
+
# :subtotal => 800,
|
59
|
+
# :shipping => 100,
|
60
|
+
# :tax1 => 100,
|
61
|
+
# :tax2 => 100,
|
62
|
+
# :custom => 'reference one'
|
63
|
+
# )
|
64
|
+
class BeanstreamGateway < Gateway
|
65
|
+
include BeanstreamCore
|
66
|
+
|
67
|
+
def authorize(money, source, options = {})
|
68
|
+
post = {}
|
69
|
+
add_amount(post, money)
|
70
|
+
add_invoice(post, options)
|
71
|
+
add_source(post, source)
|
72
|
+
add_address(post, options)
|
73
|
+
add_transaction_type(post, :authorization)
|
74
|
+
commit(post)
|
75
|
+
end
|
76
|
+
|
77
|
+
def purchase(money, source, options = {})
|
78
|
+
post = {}
|
79
|
+
add_amount(post, money)
|
80
|
+
add_invoice(post, options)
|
81
|
+
add_source(post, source)
|
82
|
+
add_address(post, options)
|
83
|
+
add_transaction_type(post, purchase_action(source))
|
84
|
+
commit(post)
|
85
|
+
end
|
86
|
+
|
87
|
+
def void(authorization, options = {})
|
88
|
+
reference, amount, type = split_auth(authorization)
|
89
|
+
|
90
|
+
post = {}
|
91
|
+
add_reference(post, reference)
|
92
|
+
add_original_amount(post, amount)
|
93
|
+
add_transaction_type(post, void_action(type))
|
94
|
+
commit(post)
|
95
|
+
end
|
96
|
+
|
97
|
+
def recurring(money, source, options = {})
|
98
|
+
post = {}
|
99
|
+
add_amount(post, money)
|
100
|
+
add_invoice(post, options)
|
101
|
+
add_credit_card(post, source)
|
102
|
+
add_address(post, options)
|
103
|
+
add_transaction_type(post, purchase_action(source))
|
104
|
+
add_recurring_type(post, options)
|
105
|
+
commit(post)
|
106
|
+
end
|
107
|
+
|
108
|
+
def update_recurring(amount, source, options = {})
|
109
|
+
post = {}
|
110
|
+
add_recurring_amount(post, amount)
|
111
|
+
add_recurring_invoice(post, options)
|
112
|
+
add_credit_card(post, source)
|
113
|
+
add_address(post, options)
|
114
|
+
add_recurring_operation_type(post, :update)
|
115
|
+
add_recurring_service(post, options)
|
116
|
+
recurring_commit(post)
|
117
|
+
end
|
118
|
+
|
119
|
+
def cancel_recurring(options = {})
|
120
|
+
post = {}
|
121
|
+
add_recurring_operation_type(post, :cancel)
|
122
|
+
add_recurring_service(post, options)
|
123
|
+
recurring_commit(post)
|
124
|
+
end
|
125
|
+
|
126
|
+
def interac
|
127
|
+
@interac ||= BeanstreamInteracGateway.new(@options)
|
128
|
+
end
|
129
|
+
|
130
|
+
# To match the other stored-value gateways, like TrustCommerce,
|
131
|
+
# store and unstore need to be defined
|
132
|
+
def store(credit_card, options = {})
|
133
|
+
post = {}
|
134
|
+
add_address(post, options)
|
135
|
+
add_credit_card(post, credit_card)
|
136
|
+
add_secure_profile_variables(post,options)
|
137
|
+
commit(post, true)
|
138
|
+
end
|
139
|
+
|
140
|
+
#can't actually delete a secure profile with the supplicaed API. This function sets the status of the profile to closed (C).
|
141
|
+
#Closed profiles will have to removed manually.
|
142
|
+
def delete(vault_id)
|
143
|
+
update(vault_id, false, {:status => "C"})
|
144
|
+
end
|
145
|
+
|
146
|
+
alias_method :unstore, :delete
|
147
|
+
|
148
|
+
# Update the values (such as CC expiration) stored at
|
149
|
+
# the gateway. The CC number must be supplied in the
|
150
|
+
# CreditCard object.
|
151
|
+
def update(vault_id, credit_card, options = {})
|
152
|
+
post = {}
|
153
|
+
add_address(post, options)
|
154
|
+
add_credit_card(post, credit_card)
|
155
|
+
options.merge!({:vault_id => vault_id, :operation => secure_profile_action(:modify)})
|
156
|
+
add_secure_profile_variables(post,options)
|
157
|
+
commit(post, true)
|
158
|
+
end
|
159
|
+
|
160
|
+
private
|
161
|
+
def build_response(*args)
|
162
|
+
Response.new(*args)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|