start_activemerchant 1.50.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +1769 -0
- data/CONTRIBUTORS +540 -0
- data/MIT-LICENSE +20 -0
- data/README.md +226 -0
- data/lib/active_merchant.rb +67 -0
- data/lib/active_merchant/billing.rb +15 -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 +404 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +195 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/gateway.rb +291 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +203 -0
- data/lib/active_merchant/billing/gateways/app55.rb +176 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +510 -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/axcessms.rb +181 -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 +192 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +389 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +58 -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 +211 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -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 +574 -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 +238 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +202 -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/cenpos.rb +262 -0
- data/lib/active_merchant/billing/gateways/certo_direct.rb +278 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +216 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +210 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +720 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +600 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +206 -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 +274 -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 +522 -0
- data/lib/active_merchant/billing/gateways/exact.rb +227 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +206 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +213 -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 +413 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +261 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +179 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +207 -0
- data/lib/active_merchant/billing/gateways/hps.rb +287 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +277 -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 +219 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +163 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +175 -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 +345 -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_partners.rb +245 -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 +326 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +303 -0
- data/lib/active_merchant/billing/gateways/migs.rb +280 -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/monei.rb +307 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +309 -0
- data/lib/active_merchant/billing/gateways/moneris_us.rb +298 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +290 -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 +224 -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/omise.rb +319 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +194 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +314 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +834 -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_conex.rb +246 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -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/paybox_direct.rb +188 -0
- data/lib/active_merchant/billing/gateways/payex.rb +412 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +308 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +220 -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 +282 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +129 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +679 -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/payu_in.rb +247 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/pin.rb +207 -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/quickbooks.rb +280 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +26 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +240 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +179 -0
- data/lib/active_merchant/billing/gateways/realex.rb +298 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +406 -0
- data/lib/active_merchant/billing/gateways/s5.rb +226 -0
- data/lib/active_merchant/billing/gateways/sage.rb +173 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +89 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +115 -0
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +149 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +399 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +143 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +263 -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 +451 -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 +489 -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 +259 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +280 -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/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +205 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +420 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +331 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +204 -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/network_tokenization_credit_card.rb +24 -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 +92 -0
- data/lib/active_merchant/connection.rb +172 -0
- data/lib/active_merchant/country.rb +332 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +35 -0
- data/lib/active_merchant/network_connection_retries.rb +79 -0
- data/lib/active_merchant/post_data.rb +24 -0
- data/lib/active_merchant/posts_data.rb +84 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3866 -0
- data/lib/support/gateway_support.rb +71 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +93 -0
- metadata +387 -0
@@ -0,0 +1,259 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
|
4
|
+
class UsaEpayTransactionGateway < Gateway
|
5
|
+
self.live_url = 'https://www.usaepay.com/gate'
|
6
|
+
self.test_url = 'https://sandbox.usaepay.com/gate'
|
7
|
+
|
8
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
9
|
+
self.supported_countries = ['US']
|
10
|
+
self.homepage_url = 'http://www.usaepay.com/'
|
11
|
+
self.display_name = 'USA ePay'
|
12
|
+
|
13
|
+
TRANSACTIONS = {
|
14
|
+
:authorization => 'cc:authonly',
|
15
|
+
:purchase => 'cc:sale',
|
16
|
+
:capture => 'cc:capture',
|
17
|
+
:refund => 'cc:refund',
|
18
|
+
:void => 'cc:void',
|
19
|
+
:void_release => 'cc:void:release'
|
20
|
+
}
|
21
|
+
|
22
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
23
|
+
'00011' => STANDARD_ERROR_CODE[:incorrect_number],
|
24
|
+
'00012' => STANDARD_ERROR_CODE[:incorrect_number],
|
25
|
+
'00013' => STANDARD_ERROR_CODE[:incorrect_number],
|
26
|
+
'00014' => STANDARD_ERROR_CODE[:invalid_number],
|
27
|
+
'00015' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
28
|
+
'00016' => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
29
|
+
'00017' => STANDARD_ERROR_CODE[:expired_card],
|
30
|
+
'10116' => STANDARD_ERROR_CODE[:incorrect_cvc],
|
31
|
+
'10107' => STANDARD_ERROR_CODE[:incorrect_zip],
|
32
|
+
'10109' => STANDARD_ERROR_CODE[:incorrect_address],
|
33
|
+
'10110' => STANDARD_ERROR_CODE[:incorrect_address],
|
34
|
+
'10111' => STANDARD_ERROR_CODE[:incorrect_address],
|
35
|
+
'10127' => STANDARD_ERROR_CODE[:card_declined],
|
36
|
+
'10128' => STANDARD_ERROR_CODE[:processing_error],
|
37
|
+
'10132' => STANDARD_ERROR_CODE[:processing_error],
|
38
|
+
'00043' => STANDARD_ERROR_CODE[:call_issuer]
|
39
|
+
}
|
40
|
+
|
41
|
+
def initialize(options = {})
|
42
|
+
requires!(options, :login)
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def authorize(money, credit_card, options = {})
|
47
|
+
post = {}
|
48
|
+
|
49
|
+
add_amount(post, money)
|
50
|
+
add_invoice(post, options)
|
51
|
+
add_credit_card(post, credit_card)
|
52
|
+
unless credit_card.track_data.present?
|
53
|
+
add_address(post, credit_card, options)
|
54
|
+
add_customer_data(post, options)
|
55
|
+
end
|
56
|
+
add_split_payments(post, options)
|
57
|
+
|
58
|
+
commit(:authorization, post)
|
59
|
+
end
|
60
|
+
|
61
|
+
def purchase(money, credit_card, options = {})
|
62
|
+
post = {}
|
63
|
+
|
64
|
+
add_amount(post, money)
|
65
|
+
add_invoice(post, options)
|
66
|
+
add_credit_card(post, credit_card)
|
67
|
+
unless credit_card.track_data.present?
|
68
|
+
add_address(post, credit_card, options)
|
69
|
+
add_customer_data(post, options)
|
70
|
+
end
|
71
|
+
add_split_payments(post, options)
|
72
|
+
|
73
|
+
commit(:purchase, post)
|
74
|
+
end
|
75
|
+
|
76
|
+
def capture(money, authorization, options = {})
|
77
|
+
post = { :refNum => authorization }
|
78
|
+
|
79
|
+
add_amount(post, money)
|
80
|
+
commit(:capture, post)
|
81
|
+
end
|
82
|
+
|
83
|
+
def refund(money, authorization, options = {})
|
84
|
+
post = { :refNum => authorization }
|
85
|
+
|
86
|
+
add_amount(post, money)
|
87
|
+
commit(:refund, post)
|
88
|
+
end
|
89
|
+
|
90
|
+
def verify(creditcard, options = {})
|
91
|
+
MultiResponse.run(:use_first_response) do |r|
|
92
|
+
r.process { authorize(1, creditcard, options) }
|
93
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
# Pass `no_release: true` to keep the void from immediately settling
|
98
|
+
def void(authorization, options = {})
|
99
|
+
command = (options[:no_release] ? :void : :void_release)
|
100
|
+
commit(command, refNum: authorization)
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
|
105
|
+
def add_amount(post, money)
|
106
|
+
post[:amount] = amount(money)
|
107
|
+
end
|
108
|
+
|
109
|
+
def expdate(credit_card)
|
110
|
+
year = format(credit_card.year, :two_digits)
|
111
|
+
month = format(credit_card.month, :two_digits)
|
112
|
+
|
113
|
+
"#{month}#{year}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def add_customer_data(post, options)
|
117
|
+
address = options[:billing_address] || options[:address] || {}
|
118
|
+
post[:street] = address[:address1]
|
119
|
+
post[:zip] = address[:zip]
|
120
|
+
|
121
|
+
if options.has_key? :email
|
122
|
+
post[:custemail] = options[:email]
|
123
|
+
post[:custreceipt] = 'No'
|
124
|
+
end
|
125
|
+
|
126
|
+
if options.has_key? :customer
|
127
|
+
post[:custid] = options[:customer]
|
128
|
+
end
|
129
|
+
|
130
|
+
if options.has_key? :ip
|
131
|
+
post[:ip] = options[:ip]
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def add_address(post, credit_card, options)
|
136
|
+
billing_address = options[:billing_address] || options[:address]
|
137
|
+
|
138
|
+
add_address_for_type(:billing, post, credit_card, billing_address) if billing_address
|
139
|
+
add_address_for_type(:shipping, post, credit_card, options[:shipping_address]) if options[:shipping_address]
|
140
|
+
end
|
141
|
+
|
142
|
+
def add_address_for_type(type, post, credit_card, address)
|
143
|
+
prefix = address_key_prefix(type)
|
144
|
+
|
145
|
+
post[address_key(prefix, 'fname')] = credit_card.first_name
|
146
|
+
post[address_key(prefix, 'lname')] = credit_card.last_name
|
147
|
+
post[address_key(prefix, 'company')] = address[:company] unless address[:company].blank?
|
148
|
+
post[address_key(prefix, 'street')] = address[:address1] unless address[:address1].blank?
|
149
|
+
post[address_key(prefix, 'street2')] = address[:address2] unless address[:address2].blank?
|
150
|
+
post[address_key(prefix, 'city')] = address[:city] unless address[:city].blank?
|
151
|
+
post[address_key(prefix, 'state')] = address[:state] unless address[:state].blank?
|
152
|
+
post[address_key(prefix, 'zip')] = address[:zip] unless address[:zip].blank?
|
153
|
+
post[address_key(prefix, 'country')] = address[:country] unless address[:country].blank?
|
154
|
+
post[address_key(prefix, 'phone')] = address[:phone] unless address[:phone].blank?
|
155
|
+
end
|
156
|
+
|
157
|
+
def address_key_prefix(type)
|
158
|
+
case type
|
159
|
+
when :shipping then 'ship'
|
160
|
+
when :billing then 'bill'
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
def address_key(prefix, key)
|
165
|
+
"#{prefix}#{key}".to_sym
|
166
|
+
end
|
167
|
+
|
168
|
+
def add_invoice(post, options)
|
169
|
+
post[:invoice] = options[:order_id]
|
170
|
+
post[:description] = options[:description]
|
171
|
+
end
|
172
|
+
|
173
|
+
def add_credit_card(post, credit_card)
|
174
|
+
if credit_card.track_data.present?
|
175
|
+
post[:magstripe] = credit_card.track_data
|
176
|
+
post[:cardpresent] = true
|
177
|
+
else
|
178
|
+
post[:card] = credit_card.number
|
179
|
+
post[:cvv2] = credit_card.verification_value if credit_card.verification_value?
|
180
|
+
post[:expir] = expdate(credit_card)
|
181
|
+
post[:name] = credit_card.name unless credit_card.name.blank?
|
182
|
+
post[:cardpresent] = true if credit_card.manual_entry
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# see: http://wiki.usaepay.com/developer/transactionapi#split_payments
|
187
|
+
def add_split_payments(post, options)
|
188
|
+
return unless options[:split_payments].is_a?(Array)
|
189
|
+
options[:split_payments].each_with_index do |payment, index|
|
190
|
+
prefix = '%02d' % (index + 2)
|
191
|
+
post["#{prefix}key"] = payment[:key]
|
192
|
+
post["#{prefix}amount"] = amount(payment[:amount])
|
193
|
+
post["#{prefix}description"] = payment[:description]
|
194
|
+
end
|
195
|
+
|
196
|
+
# When blank it's 'Stop'. 'Continue' is another one
|
197
|
+
post['onError'] = options[:on_error] || 'Void'
|
198
|
+
end
|
199
|
+
|
200
|
+
def parse(body)
|
201
|
+
fields = {}
|
202
|
+
for line in body.split('&')
|
203
|
+
key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
|
204
|
+
fields[key] = CGI.unescape(value.to_s)
|
205
|
+
end
|
206
|
+
|
207
|
+
{
|
208
|
+
:status => fields['UMstatus'],
|
209
|
+
:auth_code => fields['UMauthCode'],
|
210
|
+
:ref_num => fields['UMrefNum'],
|
211
|
+
:batch => fields['UMbatch'],
|
212
|
+
:avs_result => fields['UMavsResult'],
|
213
|
+
:avs_result_code => fields['UMavsResultCode'],
|
214
|
+
:cvv2_result => fields['UMcvv2Result'],
|
215
|
+
:cvv2_result_code => fields['UMcvv2ResultCode'],
|
216
|
+
:vpas_result_code => fields['UMvpasResultCode'],
|
217
|
+
:result => fields['UMresult'],
|
218
|
+
:error => fields['UMerror'],
|
219
|
+
:error_code => fields['UMerrorcode'],
|
220
|
+
:acs_url => fields['UMacsurl'],
|
221
|
+
:payload => fields['UMpayload']
|
222
|
+
}.delete_if{|k, v| v.nil?}
|
223
|
+
end
|
224
|
+
|
225
|
+
def commit(action, parameters)
|
226
|
+
url = (test? ? self.test_url : self.live_url)
|
227
|
+
response = parse(ssl_post(url, post_data(action, parameters)))
|
228
|
+
Response.new(response[:status] == 'Approved', message_from(response), response,
|
229
|
+
:test => test?,
|
230
|
+
:authorization => response[:ref_num],
|
231
|
+
:cvv_result => response[:cvv2_result_code],
|
232
|
+
:avs_result => { :code => response[:avs_result_code] },
|
233
|
+
:error_code => STANDARD_ERROR_CODE_MAPPING[response[:error_code]]
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
237
|
+
def message_from(response)
|
238
|
+
if response[:status] == "Approved"
|
239
|
+
return 'Success'
|
240
|
+
else
|
241
|
+
return 'Unspecified error' if response[:error].blank?
|
242
|
+
return response[:error]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def post_data(action, parameters = {})
|
247
|
+
parameters[:command] = TRANSACTIONS[action]
|
248
|
+
parameters[:key] = @options[:login]
|
249
|
+
parameters[:software] = 'Active Merchant'
|
250
|
+
parameters[:testmode] = (@options[:test] ? 1 : 0)
|
251
|
+
seed = SecureRandom.hex(32).upcase
|
252
|
+
hash = Digest::SHA1.hexdigest("#{parameters[:command]}:#{@options[:password]}:#{parameters[:amount]}:#{parameters[:invoice]}:#{seed}")
|
253
|
+
parameters[:hash] = "s/#{seed}/#{hash}/n"
|
254
|
+
|
255
|
+
parameters.collect { |key, value| "UM#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
class VancoGateway < Gateway
|
6
|
+
include Empty
|
7
|
+
|
8
|
+
self.test_url = 'https://www.vancodev.com/cgi-bin/wstest2.vps'
|
9
|
+
self.live_url = 'https://www.vancoservices.com/cgi-bin/ws2.vps'
|
10
|
+
|
11
|
+
self.supported_countries = ['US']
|
12
|
+
self.default_currency = 'USD'
|
13
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
14
|
+
|
15
|
+
self.homepage_url = 'http://vancopayments.com/'
|
16
|
+
self.display_name = 'Vanco Payment Solutions'
|
17
|
+
|
18
|
+
def initialize(options={})
|
19
|
+
requires!(options, :user_id, :password, :client_id)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def purchase(money, payment_method, options={})
|
24
|
+
MultiResponse.run do |r|
|
25
|
+
r.process { commit(login_request) }
|
26
|
+
r.process { commit(purchase_request(money, payment_method, r.params["response_sessionid"], options)) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def refund(money, authorization, options={})
|
31
|
+
MultiResponse.run do |r|
|
32
|
+
r.process { commit(login_request) }
|
33
|
+
r.process { commit(refund_request(money, authorization, r.params["response_sessionid"])) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def supports_scrubbing?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def scrub(transcript)
|
42
|
+
transcript.
|
43
|
+
gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
|
44
|
+
gsub(%r((<CardCVV2>).+(</CardCVV2>))i, '\1[FILTERED]\2').
|
45
|
+
gsub(%r((<AccountNumber>).+(</AccountNumber>))i, '\1[FILTERED]\2')
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def parse(xml)
|
51
|
+
response = {}
|
52
|
+
|
53
|
+
doc = Nokogiri::XML(xml)
|
54
|
+
doc.root.xpath('*').each do |node|
|
55
|
+
if (node.elements.empty?)
|
56
|
+
response[node.name.downcase.to_sym] = node.text
|
57
|
+
else
|
58
|
+
node.elements.each do |childnode|
|
59
|
+
childnode_to_response(response, node, childnode)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
response
|
65
|
+
end
|
66
|
+
|
67
|
+
def childnode_to_response(response, node, childnode)
|
68
|
+
name = "#{node.name.downcase}_#{childnode.name.downcase}"
|
69
|
+
if name == "response_errors" && !childnode.elements.empty?
|
70
|
+
add_errors_to_response(response, childnode.to_s)
|
71
|
+
else
|
72
|
+
response[name.downcase.to_sym] = childnode.text
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_errors_to_response(response, errors_xml)
|
77
|
+
errors_hash = Hash.from_xml(errors_xml).values.first
|
78
|
+
response[:response_errors] = errors_hash
|
79
|
+
|
80
|
+
error = errors_hash["Error"]
|
81
|
+
if error.kind_of?(Hash)
|
82
|
+
response[:error_message] = error["ErrorDescription"]
|
83
|
+
response[:error_codes] = error["ErrorCode"]
|
84
|
+
elsif error.kind_of?(Array)
|
85
|
+
error_str = error.map { |e| e["ErrorDescription"]}.join(". ")
|
86
|
+
error_codes = error.map { |e| e["ErrorCode"]}.join(", ")
|
87
|
+
response[:error_message] = "#{error_str}."
|
88
|
+
response[:error_codes] = error_codes
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def commit(request)
|
93
|
+
response = parse(ssl_post(url, request, headers))
|
94
|
+
|
95
|
+
succeeded = success_from(response)
|
96
|
+
Response.new(
|
97
|
+
succeeded,
|
98
|
+
message_from(succeeded, response),
|
99
|
+
response,
|
100
|
+
authorization: authorization_from(response),
|
101
|
+
test: test?
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
def success_from(response)
|
106
|
+
!response[:response_errors]
|
107
|
+
end
|
108
|
+
|
109
|
+
def message_from(succeeded, response)
|
110
|
+
return "Success" if succeeded
|
111
|
+
response[:error_message]
|
112
|
+
end
|
113
|
+
|
114
|
+
def authorization_from(response)
|
115
|
+
[
|
116
|
+
response[:response_customerref],
|
117
|
+
response[:response_paymentmethodref],
|
118
|
+
response[:response_transactionref]
|
119
|
+
].join("|")
|
120
|
+
end
|
121
|
+
|
122
|
+
def split_authorization(authorization)
|
123
|
+
authorization.to_s.split('|')
|
124
|
+
end
|
125
|
+
|
126
|
+
def purchase_request(money, payment_method, session_id, options)
|
127
|
+
build_xml_request do |doc|
|
128
|
+
add_auth(doc, "EFTAddCompleteTransaction", session_id)
|
129
|
+
|
130
|
+
doc.Request do
|
131
|
+
doc.RequestVars do
|
132
|
+
add_client_id(doc)
|
133
|
+
add_amount(doc, money, options)
|
134
|
+
add_payment_method(doc, payment_method, options)
|
135
|
+
add_purchase_noise(doc)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def refund_request(money, authorization, session_id)
|
142
|
+
build_xml_request do |doc|
|
143
|
+
add_auth(doc, "EFTAddCredit", session_id)
|
144
|
+
|
145
|
+
doc.Request do
|
146
|
+
doc.RequestVars do
|
147
|
+
add_client_id(doc)
|
148
|
+
add_amount(doc, money, options)
|
149
|
+
add_reference(doc, authorization)
|
150
|
+
add_refund_noise(doc)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
def add_request(doc, request_type)
|
157
|
+
doc.RequestType(request_type)
|
158
|
+
doc.RequestID(SecureRandom.hex(15))
|
159
|
+
doc.RequestTime(Time.now)
|
160
|
+
doc.Version(2)
|
161
|
+
end
|
162
|
+
|
163
|
+
def add_auth(doc, request_type, session_id)
|
164
|
+
doc.Auth do
|
165
|
+
add_request(doc, request_type)
|
166
|
+
doc.SessionID(session_id)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def add_reference(doc, authorization)
|
171
|
+
customer_ref, payment_method_ref, transaction_ref = split_authorization(authorization)
|
172
|
+
doc.CustomerRef(customer_ref)
|
173
|
+
doc.PaymentMethodRef(payment_method_ref)
|
174
|
+
doc.TransactionRef(transaction_ref)
|
175
|
+
end
|
176
|
+
|
177
|
+
def add_amount(doc, money, options)
|
178
|
+
if empty?(options[:fund_id])
|
179
|
+
doc.Amount(amount(money))
|
180
|
+
else
|
181
|
+
doc.Funds do
|
182
|
+
doc.Fund do
|
183
|
+
doc.FundID(options[:fund_id])
|
184
|
+
doc.FundAmount(amount(money))
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def add_payment_method(doc, payment_method, options)
|
191
|
+
if card_brand(payment_method) == 'check'
|
192
|
+
add_echeck(doc, payment_method)
|
193
|
+
else
|
194
|
+
add_credit_card(doc, payment_method, options)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def add_credit_card(doc, credit_card, options)
|
199
|
+
address = options[:billing_address]
|
200
|
+
|
201
|
+
doc.AccountNumber(credit_card.number)
|
202
|
+
doc.CustomerName("#{credit_card.last_name}, #{credit_card.first_name}")
|
203
|
+
doc.CardExpMonth(format(credit_card.month, :two_digits))
|
204
|
+
doc.CardExpYear(format(credit_card.year, :two_digits))
|
205
|
+
doc.CardCVV2(credit_card.verification_value)
|
206
|
+
doc.CardBillingName(credit_card.name)
|
207
|
+
doc.CardBillingAddr1(address[:address1])
|
208
|
+
doc.CardBillingAddr2(address[:address2])
|
209
|
+
doc.CardBillingCity(address[:city])
|
210
|
+
doc.CardBillingState(address[:state])
|
211
|
+
doc.CardBillingZip(address[:zip])
|
212
|
+
doc.CardBillingCountryCode(address[:country])
|
213
|
+
doc.AccountType("CC")
|
214
|
+
end
|
215
|
+
|
216
|
+
def add_echeck(doc, echeck)
|
217
|
+
if echeck.account_type == "savings"
|
218
|
+
doc.AccountType("S")
|
219
|
+
else
|
220
|
+
doc.AccountType("C")
|
221
|
+
end
|
222
|
+
|
223
|
+
doc.CustomerName("#{echeck.last_name}, #{echeck.first_name}")
|
224
|
+
doc.AccountNumber(echeck.account_number)
|
225
|
+
doc.RoutingNumber(echeck.routing_number)
|
226
|
+
doc.TransactionTypeCode("TEL")
|
227
|
+
end
|
228
|
+
|
229
|
+
def add_purchase_noise(doc)
|
230
|
+
doc.StartDate("0000-00-00")
|
231
|
+
doc.FrequencyCode("O")
|
232
|
+
end
|
233
|
+
|
234
|
+
def add_refund_noise(doc)
|
235
|
+
doc.ContactName("Bilbo Baggins")
|
236
|
+
doc.ContactPhone("1234567890")
|
237
|
+
doc.ContactExtension("None")
|
238
|
+
doc.ReasonForCredit("Refund requested")
|
239
|
+
end
|
240
|
+
|
241
|
+
def add_client_id(doc)
|
242
|
+
doc.ClientID(@options[:client_id])
|
243
|
+
end
|
244
|
+
|
245
|
+
def login_request
|
246
|
+
build_xml_request do |doc|
|
247
|
+
doc.Auth do
|
248
|
+
add_request(doc, "Login")
|
249
|
+
end
|
250
|
+
|
251
|
+
doc.Request do
|
252
|
+
doc.RequestVars do
|
253
|
+
doc.UserID(@options[:user_id])
|
254
|
+
doc.Password(@options[:password])
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
def build_xml_request
|
261
|
+
builder = Nokogiri::XML::Builder.new
|
262
|
+
builder.__send__("VancoWS") do |doc|
|
263
|
+
yield(doc)
|
264
|
+
end
|
265
|
+
builder.to_xml
|
266
|
+
end
|
267
|
+
|
268
|
+
def url
|
269
|
+
(test? ? test_url : live_url)
|
270
|
+
end
|
271
|
+
|
272
|
+
def headers
|
273
|
+
{
|
274
|
+
'Content-Type' => 'text/xml'
|
275
|
+
}
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|