aktivemerchant 2.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG +1596 -0
- data/CONTRIBUTORS +511 -0
- data/MIT-LICENSE +20 -0
- data/README.md +18 -0
- data/lib/active_merchant.rb +108 -0
- data/lib/active_merchant/billing.rb +13 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +72 -0
- data/lib/active_merchant/billing/check.rb +76 -0
- data/lib/active_merchant/billing/compatibility.rb +120 -0
- data/lib/active_merchant/billing/credit_card.rb +352 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +160 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +268 -0
- data/lib/active_merchant/billing/gateways.rb +17 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +209 -0
- data/lib/active_merchant/billing/gateways/alfabank.rb +117 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +419 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +976 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +256 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +105 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +314 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +188 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +393 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +506 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +140 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +210 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +515 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +20 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +189 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +23 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +220 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +191 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +201 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +229 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +213 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +209 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +709 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +219 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +348 -0
- data/lib/active_merchant/billing/gateways/epay.rb +275 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +308 -0
- data/lib/active_merchant/billing/gateways/eway.rb +214 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +291 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +524 -0
- data/lib/active_merchant/billing/gateways/exact.rb +218 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +173 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +160 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +23 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +160 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +355 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +257 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +183 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +288 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +251 -0
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +246 -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 +66 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +457 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +438 -0
- data/lib/active_merchant/billing/gateways/litle.rb +346 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +197 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +170 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +114 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +319 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +268 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +195 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +333 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +265 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +219 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +291 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +280 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +181 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +190 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +256 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +435 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +313 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +803 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +47 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +261 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +112 -0
- data/lib/active_merchant/billing/gateways/pay_u_latam.rb +462 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +304 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +209 -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 +224 -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 +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +281 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +117 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +670 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +65 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +264 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +199 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +197 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +216 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +303 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +292 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +276 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +367 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +391 -0
- data/lib/active_merchant/billing/gateways/sage.rb +175 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +87 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +114 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +102 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +398 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +252 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +201 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +281 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +105 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +452 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +283 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +247 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +411 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +157 -0
- data/lib/active_merchant/billing/gateways/tns.rb +227 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +126 -0
- data/lib/active_merchant/billing/gateways/transax.rb +23 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +10 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +416 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +25 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1516 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +254 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +225 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +183 -0
- data/lib/active_merchant/billing/gateways/vindicia.rb +385 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +421 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +91 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +29 -0
- data/lib/active_merchant/offsite_payments_shim.rb +19 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +25 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +400 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class EpayGateway < Gateway
|
4
|
+
API_HOST = 'ssl.ditonlinebetalingssystem.dk'
|
5
|
+
self.live_url = 'https://' + API_HOST + '/remote/payment'
|
6
|
+
|
7
|
+
self.default_currency = 'DKK'
|
8
|
+
self.money_format = :cents
|
9
|
+
self.supported_cardtypes = [:dankort, :forbrugsforeningen, :visa, :master,
|
10
|
+
:american_express, :diners_club, :jcb, :maestro]
|
11
|
+
self.supported_countries = ['DK', 'SE', 'NO']
|
12
|
+
self.homepage_url = 'http://epay.dk/'
|
13
|
+
self.display_name = 'ePay'
|
14
|
+
|
15
|
+
CURRENCY_CODES = {
|
16
|
+
:ADP => '020', :AED => '784', :AFA => '004', :ALL => '008', :AMD => '051',
|
17
|
+
:ANG => '532', :AOA => '973', :ARS => '032', :AUD => '036', :AWG => '533',
|
18
|
+
:AZM => '031', :BAM => '977', :BBD => '052', :BDT => '050', :BGL => '100',
|
19
|
+
:BGN => '975', :BHD => '048', :BIF => '108', :BMD => '060', :BND => '096',
|
20
|
+
:BOB => '068', :BOV => '984', :BRL => '986', :BSD => '044', :BTN => '064',
|
21
|
+
:BWP => '072', :BYR => '974', :BZD => '084', :CAD => '124', :CDF => '976',
|
22
|
+
:CHF => '756', :CLF => '990', :CLP => '152', :CNY => '156', :COP => '170',
|
23
|
+
:CRC => '188', :CUP => '192', :CVE => '132', :CYP => '196', :CZK => '203',
|
24
|
+
:DJF => '262', :DKK => '208', :DOP => '214', :DZD => '012', :ECS => '218',
|
25
|
+
:ECV => '983', :EEK => '233', :EGP => '818', :ERN => '232', :ETB => '230',
|
26
|
+
:EUR => '978', :FJD => '242', :FKP => '238', :GBP => '826', :GEL => '981',
|
27
|
+
:GHC => '288', :GIP => '292', :GMD => '270', :GNF => '324', :GTQ => '320',
|
28
|
+
:GWP => '624', :GYD => '328', :HKD => '344', :HNL => '340', :HRK => '191',
|
29
|
+
:HTG => '332', :HUF => '348', :IDR => '360', :ILS => '376', :INR => '356',
|
30
|
+
:IQD => '368', :IRR => '364', :ISK => '352', :JMD => '388', :JOD => '400',
|
31
|
+
:JPY => '392', :KES => '404', :KGS => '417', :KHR => '116', :KMF => '174',
|
32
|
+
:KPW => '408', :KRW => '410', :KWD => '414', :KYD => '136', :KZT => '398',
|
33
|
+
:LAK => '418', :LBP => '422', :LKR => '144', :LRD => '430', :LSL => '426',
|
34
|
+
:LTL => '440', :LVL => '428', :LYD => '434', :MAD => '504', :MDL => '498',
|
35
|
+
:MGF => '450', :MKD => '807', :MMK => '104', :MNT => '496', :MOP => '446',
|
36
|
+
:MRO => '478', :MTL => '470', :MUR => '480', :MVR => '462', :MWK => '454',
|
37
|
+
:MXN => '484', :MXV => '979', :MYR => '458', :MZM => '508', :NAD => '516',
|
38
|
+
:NGN => '566', :NIO => '558', :NOK => '578', :NPR => '524', :NZD => '554',
|
39
|
+
:OMR => '512', :PAB => '590', :PEN => '604', :PGK => '598', :PHP => '608',
|
40
|
+
:PKR => '586', :PLN => '985', :PYG => '600', :QAR => '634', :ROL => '642',
|
41
|
+
:RUB => '643', :RUR => '810', :RWF => '646', :SAR => '682', :SBD => '090',
|
42
|
+
:SCR => '690', :SDD => '736', :SEK => '752', :SGD => '702', :SHP => '654',
|
43
|
+
:SIT => '705', :SKK => '703', :SLL => '694', :SOS => '706', :SRG => '740',
|
44
|
+
:STD => '678', :SVC => '222', :SYP => '760', :SZL => '748', :THB => '764',
|
45
|
+
:TJS => '972', :TMM => '795', :TND => '788', :TOP => '776', :TPE => '626',
|
46
|
+
:TRL => '792', :TRY => '949', :TTD => '780', :TWD => '901', :TZS => '834',
|
47
|
+
:UAH => '980', :UGX => '800', :USD => '840', :UYU => '858', :UZS => '860',
|
48
|
+
:VEB => '862', :VND => '704', :VUV => '548', :XAF => '950', :XCD => '951',
|
49
|
+
:XOF => '952', :XPF => '953', :YER => '886', :YUM => '891', :ZAR => '710',
|
50
|
+
:ZMK => '894', :ZWD => '716'
|
51
|
+
}
|
52
|
+
|
53
|
+
# login: merchant number
|
54
|
+
# password: referrer url (for authorize authentication)
|
55
|
+
def initialize(options = {})
|
56
|
+
requires!(options, :login)
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def authorize(money, credit_card_or_reference, options = {})
|
61
|
+
post = {}
|
62
|
+
|
63
|
+
add_amount(post, money, options)
|
64
|
+
add_invoice(post, options)
|
65
|
+
add_creditcard_or_reference(post, credit_card_or_reference)
|
66
|
+
add_instant_capture(post, false)
|
67
|
+
|
68
|
+
commit(:authorize, post)
|
69
|
+
end
|
70
|
+
|
71
|
+
def purchase(money, credit_card_or_reference, options = {})
|
72
|
+
post = {}
|
73
|
+
|
74
|
+
add_amount(post, money, options)
|
75
|
+
add_creditcard_or_reference(post, credit_card_or_reference)
|
76
|
+
add_invoice(post, options)
|
77
|
+
add_instant_capture(post, true)
|
78
|
+
|
79
|
+
commit(:authorize, post)
|
80
|
+
end
|
81
|
+
|
82
|
+
def capture(money, authorization, options = {})
|
83
|
+
post = {}
|
84
|
+
|
85
|
+
add_reference(post, authorization)
|
86
|
+
add_amount_without_currency(post, money)
|
87
|
+
|
88
|
+
commit(:capture, post)
|
89
|
+
end
|
90
|
+
|
91
|
+
def void(identification, options = {})
|
92
|
+
post = {}
|
93
|
+
|
94
|
+
add_reference(post, identification)
|
95
|
+
|
96
|
+
commit(:void, post)
|
97
|
+
end
|
98
|
+
|
99
|
+
def refund(money, identification, options = {})
|
100
|
+
post = {}
|
101
|
+
|
102
|
+
add_amount_without_currency(post, money)
|
103
|
+
add_reference(post, identification)
|
104
|
+
|
105
|
+
commit(:credit, post)
|
106
|
+
end
|
107
|
+
|
108
|
+
def credit(money, identification, options = {})
|
109
|
+
ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
|
110
|
+
refund(money, identification, options)
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
def add_amount(post, money, options)
|
116
|
+
post[:amount] = amount(money)
|
117
|
+
post[:currency] = CURRENCY_CODES[(options[:currency] || currency(money)).to_sym]
|
118
|
+
end
|
119
|
+
|
120
|
+
def add_amount_without_currency(post, money)
|
121
|
+
post[:amount] = amount(money)
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_reference(post, identification)
|
125
|
+
post[:transaction] = identification
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_invoice(post, options)
|
129
|
+
post[:orderid] = format_order_number(options[:order_id])
|
130
|
+
end
|
131
|
+
|
132
|
+
def add_creditcard(post, credit_card)
|
133
|
+
post[:cardno] = credit_card.number
|
134
|
+
post[:cvc] = credit_card.verification_value
|
135
|
+
post[:expmonth] = credit_card.month
|
136
|
+
post[:expyear] = credit_card.year
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_creditcard_or_reference(post, credit_card_or_reference)
|
140
|
+
if credit_card_or_reference.respond_to?(:number)
|
141
|
+
add_creditcard(post, credit_card_or_reference)
|
142
|
+
else
|
143
|
+
add_reference(post, credit_card_or_reference.to_s)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def add_instant_capture(post, option)
|
148
|
+
post[:instantcapture] = option ? 1 : 0
|
149
|
+
end
|
150
|
+
|
151
|
+
def commit(action, params)
|
152
|
+
response = send("do_#{action}", params)
|
153
|
+
|
154
|
+
if action == :authorize
|
155
|
+
Response.new response['accept'].to_i == 1,
|
156
|
+
response['errortext'],
|
157
|
+
response,
|
158
|
+
:test => test?,
|
159
|
+
:authorization => response['tid']
|
160
|
+
else
|
161
|
+
Response.new response['result'] == 'true',
|
162
|
+
messages(response['epay'], response['pbs']),
|
163
|
+
response,
|
164
|
+
:test => test?,
|
165
|
+
:authorization => params[:transaction]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def messages(epay, pbs = nil)
|
170
|
+
response = "ePay: #{epay}"
|
171
|
+
response << " PBS: #{pbs}" if pbs
|
172
|
+
return response
|
173
|
+
end
|
174
|
+
|
175
|
+
def soap_post(method, params)
|
176
|
+
data = xml_builder(params, method)
|
177
|
+
headers = make_headers(data, method)
|
178
|
+
REXML::Document.new(ssl_post('https://' + API_HOST + '/remote/payment.asmx', data, headers))
|
179
|
+
end
|
180
|
+
|
181
|
+
def do_authorize(params)
|
182
|
+
headers = {}
|
183
|
+
headers['Referer'] = (options[:password] || "activemerchant.org")
|
184
|
+
|
185
|
+
response = raw_ssl_request(:post, 'https://' + API_HOST + '/auth/default.aspx', authorize_post_data(params), headers)
|
186
|
+
|
187
|
+
# Authorize gives the response back by redirecting with the values in
|
188
|
+
# the URL query
|
189
|
+
if location = response['Location']
|
190
|
+
query = CGI::parse(URI.parse(location.gsub(' ', '%20')).query)
|
191
|
+
else
|
192
|
+
return {
|
193
|
+
'accept' => '0',
|
194
|
+
'errortext' => 'ePay did not respond as expected. Please try again.',
|
195
|
+
'response_code' => response.code,
|
196
|
+
'response_message' => response.message
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
result = {}
|
201
|
+
query.each_pair do |k,v|
|
202
|
+
result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v'
|
203
|
+
end
|
204
|
+
result
|
205
|
+
end
|
206
|
+
|
207
|
+
def do_capture(params)
|
208
|
+
response = soap_post('capture', params)
|
209
|
+
{
|
210
|
+
'result' => response.elements['//captureResponse/captureResult'].text,
|
211
|
+
'pbs' => response.elements['//captureResponse/pbsResponse'].text,
|
212
|
+
'epay' => response.elements['//captureResponse/epayresponse'].text
|
213
|
+
}
|
214
|
+
end
|
215
|
+
|
216
|
+
def do_credit(params)
|
217
|
+
response = soap_post('credit', params)
|
218
|
+
{
|
219
|
+
'result' => response.elements['//creditResponse/creditResult'].text,
|
220
|
+
'pbs' => response.elements['//creditResponse/pbsresponse'].text,
|
221
|
+
'epay' => response.elements['//creditResponse/epayresponse'].text
|
222
|
+
}
|
223
|
+
end
|
224
|
+
|
225
|
+
def do_void(params)
|
226
|
+
response = soap_post('delete', params)
|
227
|
+
{
|
228
|
+
'result' => response.elements['//deleteResponse/deleteResult'].text,
|
229
|
+
'epay' => response.elements['//deleteResponse/epayresponse'].text
|
230
|
+
}
|
231
|
+
end
|
232
|
+
|
233
|
+
def make_headers(data, soap_call)
|
234
|
+
{
|
235
|
+
'Content-Type' => 'text/xml; charset=utf-8',
|
236
|
+
'Host' => API_HOST,
|
237
|
+
'Content-Length' => data.size.to_s,
|
238
|
+
'SOAPAction' => self.live_url + '/' + soap_call
|
239
|
+
}
|
240
|
+
end
|
241
|
+
|
242
|
+
def xml_builder(params, soap_call)
|
243
|
+
xml = Builder::XmlMarkup.new(:indent => 2)
|
244
|
+
xml.instruct!
|
245
|
+
xml.tag! 'soap:Envelope', { 'xmlns:xsi' => 'http://schemas.xmlsoap.org/soap/envelope/',
|
246
|
+
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
|
247
|
+
'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
|
248
|
+
xml.tag! 'soap:Body' do
|
249
|
+
xml.tag! soap_call, { 'xmlns' => self.live_url } do
|
250
|
+
xml.tag! 'merchantnumber', @options[:login]
|
251
|
+
xml.tag! 'transactionid', params[:transaction]
|
252
|
+
xml.tag! 'amount', params[:amount].to_s if soap_call != 'delete'
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
xml.target!
|
257
|
+
end
|
258
|
+
|
259
|
+
def authorize_post_data(params = {})
|
260
|
+
params[:language] = '2'
|
261
|
+
params[:cms] = 'activemerchant'
|
262
|
+
params[:accepturl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?accept=1'
|
263
|
+
params[:declineurl] = 'https://ssl.ditonlinebetalingssystem.dk/auth/default.aspx?decline=1'
|
264
|
+
params[:merchantnumber] = @options[:login]
|
265
|
+
|
266
|
+
params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
267
|
+
end
|
268
|
+
|
269
|
+
# Limited to 20 digits max
|
270
|
+
def format_order_number(number)
|
271
|
+
number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20]
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
@@ -0,0 +1,308 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# === EVO Canada payment gateway.
|
4
|
+
#
|
5
|
+
# EVO returns two different identifiers for most transactions, the
|
6
|
+
# +authcode+ and the +transactionid+. Since +transactionid+ is used more
|
7
|
+
# often (i.e. for {#capture}, {#refund}, {#void} and {#update}) we store it in the
|
8
|
+
# Response#authorization attribute. The +authcode+ from the merchant
|
9
|
+
# account is accessible via {Response#params}.
|
10
|
+
#
|
11
|
+
# Two different but related response messages are also returned from EVO.
|
12
|
+
# The message indicated by EVO's <tt>response_code</tt> parameter is returned as
|
13
|
+
# {Response#message} (Those messages can be seen in the {MESSAGES} hash.)
|
14
|
+
# The other, shorter message is available via {Response#params}.
|
15
|
+
#
|
16
|
+
# It's recommended to save the contents of the {Response#params} in your
|
17
|
+
# transaction log for future reference.
|
18
|
+
#
|
19
|
+
# === Sample Use
|
20
|
+
#
|
21
|
+
# gateway = ActiveMerchant::Billing::EvoCaGateway.new(username: 'demo', password: 'password')
|
22
|
+
#
|
23
|
+
# response = gateway.authorize(1000, credit_card, options)
|
24
|
+
#
|
25
|
+
# puts response.authorization # the transactionid
|
26
|
+
# puts response.params['authcode'] # the authcode from the merchant account
|
27
|
+
# puts response.message # the 'pretty' response message
|
28
|
+
# puts response.params['responsetext'] # the 'terse' response message
|
29
|
+
#
|
30
|
+
# gateway.capture(1000, response.authorization)
|
31
|
+
# gateway.update(response.authorization, shipping_carrier: 'fedex')
|
32
|
+
# gateway.refund(500, response.authorization)
|
33
|
+
#
|
34
|
+
class EvoCaGateway < Gateway
|
35
|
+
self.test_url = 'https://secure.evoepay.com/api/transact.php'
|
36
|
+
self.live_url = 'https://secure.evoepay.com/api/transact.php'
|
37
|
+
|
38
|
+
self.supported_countries = ['CA']
|
39
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :jcb, :discover]
|
40
|
+
self.money_format = :dollars
|
41
|
+
self.homepage_url = 'http://www.evocanada.com/'
|
42
|
+
self.display_name = 'EVO Canada'
|
43
|
+
|
44
|
+
APPROVED, DECLINED, ERROR = 1, 2, 3
|
45
|
+
|
46
|
+
MESSAGES = {
|
47
|
+
100 => 'Transaction was approved',
|
48
|
+
200 => 'Transaction was declined by processor',
|
49
|
+
201 => 'Do not honor',
|
50
|
+
202 => 'Insufficient funds',
|
51
|
+
203 => 'Over limit',
|
52
|
+
204 => 'Transaction not allowed',
|
53
|
+
220 => 'Incorrect payment data',
|
54
|
+
221 => 'No such card issuer',
|
55
|
+
222 => 'No card number on file with issuer',
|
56
|
+
223 => 'Expired card',
|
57
|
+
224 => 'Invalid expiration date',
|
58
|
+
225 => 'Invalid card security code',
|
59
|
+
240 => 'Call issuer for futher information',
|
60
|
+
250 => 'Pick up card',
|
61
|
+
251 => 'Lost card',
|
62
|
+
252 => 'Stolen card',
|
63
|
+
253 => 'Fraudulant card',
|
64
|
+
260 => 'Declined with further instructions available',
|
65
|
+
261 => 'Declined - stop all recurring payments',
|
66
|
+
262 => 'Declined - stop this recurring program',
|
67
|
+
263 => 'Declined - updated cardholder data available',
|
68
|
+
264 => 'Declined - retry in a few days',
|
69
|
+
300 => 'Transaction was rejected by gateway',
|
70
|
+
400 => 'Transaction error returned by processor',
|
71
|
+
410 => 'Invalid merchant configuration',
|
72
|
+
411 => 'Merchant account is inactive',
|
73
|
+
420 => 'Communication error',
|
74
|
+
421 => 'Communication error with issuer',
|
75
|
+
430 => 'Duplicate transaction at processor',
|
76
|
+
440 => 'Processor format error',
|
77
|
+
441 => 'Invalid transaction information',
|
78
|
+
460 => 'Processor feature not available',
|
79
|
+
461 => 'Unsupported card type'
|
80
|
+
}
|
81
|
+
|
82
|
+
# This gateway requires that a valid username and password be passed
|
83
|
+
# in the +options+ hash.
|
84
|
+
#
|
85
|
+
# === Required Options
|
86
|
+
#
|
87
|
+
# * <tt>:username</tt>
|
88
|
+
# * <tt>:password</tt>
|
89
|
+
def initialize(options = {})
|
90
|
+
requires!(options, :username, :password)
|
91
|
+
super
|
92
|
+
end
|
93
|
+
|
94
|
+
# Transaction sales are submitted and immediately flagged for settlement.
|
95
|
+
# These transactions will automatically be settled.
|
96
|
+
#
|
97
|
+
# Payment source can be either a {CreditCard} or {Check}.
|
98
|
+
#
|
99
|
+
# === Additional Options
|
100
|
+
# In addition to the standard options, this gateway supports
|
101
|
+
#
|
102
|
+
# * <tt>:tracking_number</tt> - Shipping tracking number
|
103
|
+
# * <tt>:shipping_carrier</tt> - ups/fedex/dhl/usps
|
104
|
+
# * <tt>:po_number</tt> - Purchase order
|
105
|
+
# * <tt>:tax</tt> - Tax amount
|
106
|
+
# * <tt>:shipping</tt> - Shipping cost
|
107
|
+
def purchase(money, credit_card_or_check, options = {})
|
108
|
+
post = {}
|
109
|
+
add_invoice(post, options)
|
110
|
+
add_order(post, options)
|
111
|
+
add_paymentmethod(post, credit_card_or_check)
|
112
|
+
add_address(post, options)
|
113
|
+
add_customer_data(post, options)
|
114
|
+
commit('sale', money, post)
|
115
|
+
end
|
116
|
+
|
117
|
+
# Transaction authorizations are authorized immediately but are not
|
118
|
+
# flagged for settlement. These transactions must be flagged for
|
119
|
+
# settlement using the _capture_ transaction type. Authorizations
|
120
|
+
# typically remain activate for three to seven business days.
|
121
|
+
#
|
122
|
+
# Payment source must be a {CreditCard}.
|
123
|
+
def authorize(money, credit_card, options = {})
|
124
|
+
post = {}
|
125
|
+
add_invoice(post, options)
|
126
|
+
add_order(post, options)
|
127
|
+
add_paymentmethod(post, credit_card)
|
128
|
+
add_address(post, options)
|
129
|
+
add_customer_data(post, options)
|
130
|
+
commit('auth', money, post)
|
131
|
+
end
|
132
|
+
|
133
|
+
# Transaction captures flag existing _authorizations_ for settlement. Only
|
134
|
+
# authorizations can be captured. Captures can be submitted for an amount
|
135
|
+
# equal to or less than the original authorization.
|
136
|
+
#
|
137
|
+
# The <tt>authorization</tt> parameter is the transaction ID, retrieved
|
138
|
+
# from Response#authorization. See EvoCaGateway#purchase for the
|
139
|
+
# <tt>options</tt>.
|
140
|
+
def capture(money, authorization, options = {})
|
141
|
+
post = {
|
142
|
+
:amount => amount(money),
|
143
|
+
:transactionid => authorization
|
144
|
+
}
|
145
|
+
add_order(post, options)
|
146
|
+
commit('capture', money, post)
|
147
|
+
end
|
148
|
+
|
149
|
+
# Transaction refunds will reverse a previously settled transaction. If
|
150
|
+
# the transaction has not been settled, it must be _voided_ instead of
|
151
|
+
# refunded.
|
152
|
+
#
|
153
|
+
# The <tt>identification</tt> parameter is the transaction ID, retrieved
|
154
|
+
# from {Response#authorization}.
|
155
|
+
def refund(money, identification)
|
156
|
+
post = {:transactionid => identification}
|
157
|
+
commit('refund', money, post)
|
158
|
+
end
|
159
|
+
|
160
|
+
# Transaction credits apply a negative amount to the cardholder's card.
|
161
|
+
# In most situations credits are disabled as transaction refunds should
|
162
|
+
# be used instead.
|
163
|
+
#
|
164
|
+
# Note that this is different from a {#refund} (which is usually what
|
165
|
+
# you'll be looking for).
|
166
|
+
def credit(money, credit_card, options = {})
|
167
|
+
post = {}
|
168
|
+
add_invoice(post, options)
|
169
|
+
add_order(post, options)
|
170
|
+
add_paymentmethod(post, credit_card)
|
171
|
+
add_address(post, options)
|
172
|
+
add_customer_data(post, options)
|
173
|
+
commit('credit', money, post)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Transaction voids will cancel an existing sale or captured
|
177
|
+
# authorization. In addition, non-captured authorizations can be voided to
|
178
|
+
# prevent any future capture. Voids can only occur if the transaction has
|
179
|
+
# not been settled.
|
180
|
+
#
|
181
|
+
# The <tt>identification</tt> parameter is the transaction ID, retrieved
|
182
|
+
# from {Response#authorization}.
|
183
|
+
def void(identification)
|
184
|
+
post = {:transactionid => identification}
|
185
|
+
commit('void', nil, post)
|
186
|
+
end
|
187
|
+
|
188
|
+
# Transaction updates can be used to update previous transactions with
|
189
|
+
# specific order information, such as a tracking number and shipping
|
190
|
+
# carrier. See EvoCaGateway#purchase for <tt>options</tt>.
|
191
|
+
#
|
192
|
+
# The <tt>identification</tt> parameter is the transaction ID, retrieved
|
193
|
+
# from {Response#authorization}.
|
194
|
+
def update(identification, options)
|
195
|
+
post = {:transactionid => identification}
|
196
|
+
add_order(post, options)
|
197
|
+
commit('update', nil, post)
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def add_customer_data(post, options)
|
203
|
+
post[:email] = options[:email]
|
204
|
+
post[:ipaddress] = options[:ip]
|
205
|
+
end
|
206
|
+
|
207
|
+
def add_address(post, options)
|
208
|
+
if address = options[:billing_address] || options[:address]
|
209
|
+
post[:firstname] = address[:first_name]
|
210
|
+
post[:lastname] = address[:last_name]
|
211
|
+
post[:address1] = address[:address1]
|
212
|
+
post[:address2] = address[:address2]
|
213
|
+
post[:company] = address[:company]
|
214
|
+
post[:phone] = address[:phone]
|
215
|
+
post[:city] = address[:city]
|
216
|
+
post[:state] = address[:state]
|
217
|
+
post[:zip] = address[:zip]
|
218
|
+
post[:country] = address[:country]
|
219
|
+
end
|
220
|
+
|
221
|
+
if address = options[:shipping_address]
|
222
|
+
post[:shipping_firstname] = address[:first_name]
|
223
|
+
post[:shipping_lastname] = address[:last_name]
|
224
|
+
post[:shipping_address1] = address[:address1]
|
225
|
+
post[:shipping_address2] = address[:address2]
|
226
|
+
post[:shipping_company] = address[:company]
|
227
|
+
post[:shipping_zip] = address[:zip]
|
228
|
+
post[:shipping_city] = address[:city]
|
229
|
+
post[:shipping_state] = address[:state]
|
230
|
+
post[:shipping_country] = address[:country]
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
def add_order(post, options)
|
235
|
+
post[:orderid] = options[:order_id]
|
236
|
+
post[:tracking_number] = options[:tracking_number]
|
237
|
+
post[:shipping_carrier] = options[:shipping_carrier]
|
238
|
+
end
|
239
|
+
|
240
|
+
def add_invoice(post, options)
|
241
|
+
post[:orderdescription] = options[:description]
|
242
|
+
post[:ponumber] = options[:po_number]
|
243
|
+
post[:shipping] = amount(options[:shipping])
|
244
|
+
post[:tax] = amount(options[:tax])
|
245
|
+
end
|
246
|
+
|
247
|
+
def add_paymentmethod(post, payment)
|
248
|
+
if card_brand(payment)=='check'
|
249
|
+
post[:payment] = 'check'
|
250
|
+
post[:checkname] = payment.name
|
251
|
+
post[:checkaba] = payment.routing_number
|
252
|
+
post[:checkaccount] = payment.account_number
|
253
|
+
post[:account_holder_type] = payment.account_holder_type
|
254
|
+
post[:account_type] = payment.account_type
|
255
|
+
else
|
256
|
+
post[:payment] = 'creditcard'
|
257
|
+
post[:ccnumber] = payment.number
|
258
|
+
post[:ccexp] = "#{format(payment.month, :two_digits)}#{format(payment.year, :two_digits)}"
|
259
|
+
post[:cvv] = payment.verification_value
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
def parse(body)
|
264
|
+
fields = {}
|
265
|
+
CGI::parse(body).each do |k, v|
|
266
|
+
fields[k.to_s] = v.kind_of?(Array) ? v[0] : v
|
267
|
+
end
|
268
|
+
fields
|
269
|
+
end
|
270
|
+
|
271
|
+
def success?(response)
|
272
|
+
response['response'].to_i == APPROVED
|
273
|
+
end
|
274
|
+
|
275
|
+
def commit(action, money, parameters)
|
276
|
+
parameters[:amount] = amount(money) unless action == 'void'
|
277
|
+
|
278
|
+
data = ssl_post self.live_url, post_data(action, parameters)
|
279
|
+
response = parse(data)
|
280
|
+
message = message_from(response)
|
281
|
+
|
282
|
+
Response.new(success?(response), message, response,
|
283
|
+
:test => test?,
|
284
|
+
:authorization => response['transactionid'],
|
285
|
+
:avs_result => { :code => response['avsresponse'] },
|
286
|
+
:cvv_result => response['cvvresponse']
|
287
|
+
)
|
288
|
+
end
|
289
|
+
|
290
|
+
def message_from(response)
|
291
|
+
MESSAGES.fetch(response['response_code'].to_i, false) || response['message']
|
292
|
+
end
|
293
|
+
|
294
|
+
def post_data(action, parameters = {})
|
295
|
+
post = {:type => action}
|
296
|
+
|
297
|
+
if test?
|
298
|
+
post[:username] = 'demo'
|
299
|
+
post[:password] = 'password'
|
300
|
+
else
|
301
|
+
post[:username] = options[:username]
|
302
|
+
post[:password] = options[:password]
|
303
|
+
end
|
304
|
+
post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" unless value.nil? }.compact.join("&")
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|