abtain_billing 1.0 → 1.02
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -472
- data/CONTRIBUTORS +0 -126
- data/MIT-LICENSE +2 -2
- data/Rakefile +3 -3
- data/init.rb +3 -3
- data/lib/{active_merchant.rb → abtain_billing.rb} +18 -18
- data/lib/{active_merchant → abtain_billing}/billing/avs_result.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/base.rb +7 -7
- data/lib/{active_merchant → abtain_billing}/billing/check.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/credit_card.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/credit_card_formatting.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/credit_card_methods.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/cvv_result.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/expiry_date.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/gateway.rb +5 -5
- data/lib/{active_merchant → abtain_billing}/billing/gateways.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/gateways/authorize_net.rb +3 -1
- data/lib/{active_merchant → abtain_billing}/billing/gateways/authorize_net_cim.rb +2 -1
- data/lib/{active_merchant → abtain_billing}/billing/gateways/bogus.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/gateways/cyber_source.rb +1 -1
- data/lib/abtain_billing/billing/integrations.rb +22 -0
- data/lib/{active_merchant → abtain_billing}/billing/integrations/action_view_helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus.rb +4 -4
- data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/bogus/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay.rb +4 -4
- data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/chronopay/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/common.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/gestpay/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/notification.rb +3 -3
- data/lib/{active_merchant → abtain_billing}/billing/integrations/hi_trust/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex.rb +5 -5
- data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/notification.rb +3 -3
- data/lib/{active_merchant → abtain_billing}/billing/integrations/nochex/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal.rb +5 -5
- data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/notification.rb +3 -3
- data/lib/{active_merchant → abtain_billing}/billing/integrations/paypal/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay/helper.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/quickpay/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/return.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/helper.rb +3 -3
- data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/notification.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/integrations/two_checkout/return.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/billing/response.rb +2 -2
- data/lib/{active_merchant → abtain_billing}/lib/connection.rb +3 -3
- data/lib/{active_merchant → abtain_billing}/lib/country.rb +1 -1
- data/lib/abtain_billing/lib/error.rb +4 -0
- data/lib/{active_merchant → abtain_billing}/lib/post_data.rb +0 -0
- data/lib/{active_merchant → abtain_billing}/lib/posts_data.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/lib/requires_parameters.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/lib/utils.rb +1 -1
- data/lib/{active_merchant → abtain_billing}/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +3 -3
- data/test/fixtures.yml +2 -2
- data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
- data/test/remote/integrations/remote_paypal_integration_test.rb +3 -3
- data/test/test_helper.rb +10 -10
- data/test/unit/base_test.rb +2 -2
- data/test/unit/connection_test.rb +11 -11
- data/test/unit/country_code_test.rb +1 -1
- data/test/unit/country_test.rb +1 -1
- data/test/unit/credit_card_formatting_test.rb +1 -1
- data/test/unit/credit_card_methods_test.rb +2 -2
- data/test/unit/gateways/authorize_net_test.rb +2 -2
- data/test/unit/gateways/bogus_test.rb +1 -1
- data/test/unit/gateways/data_cash_test.rb +1 -1
- data/test/unit/gateways/jetpay_test.rb +1 -1
- data/test/unit/gateways/merchant_ware_test.rb +1 -1
- data/test/unit/gateways/payflow_express_test.rb +1 -1
- data/test/unit/gateways/payflow_test.rb +5 -5
- data/test/unit/gateways/paypal_express_test.rb +2 -2
- data/test/unit/gateways/paypal_test.rb +2 -2
- data/test/unit/gateways/realex_test.rb +1 -1
- data/test/unit/gateways/verifi_test.rb +1 -1
- data/test/unit/integrations/action_view_helper_test.rb +1 -1
- data/test/unit/integrations/bogus_module_test.rb +1 -1
- data/test/unit/integrations/chronopay_module_test.rb +1 -1
- data/test/unit/integrations/gestpay_module_test.rb +1 -1
- data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/paypal_helper_test.rb +2 -2
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +4 -4
- data/test/unit/integrations/hi_trust_module_test.rb +1 -1
- data/test/unit/integrations/nochex_module_test.rb +1 -1
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +4 -4
- data/test/unit/integrations/notifications/nochex_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/notification_test.rb +4 -4
- data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
- data/test/unit/integrations/paypal_module_test.rb +4 -4
- data/test/unit/integrations/quickpay_module_test.rb +1 -1
- data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
- data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
- data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
- data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
- data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
- data/test/unit/integrations/returns/return_test.rb +1 -1
- data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
- data/test/unit/integrations/two_checkout_module_test.rb +1 -1
- data/test/unit/posts_data_test.rb +5 -5
- data/test/unit/utils_test.rb +1 -1
- data/test/unit/validateable_test.rb +2 -2
- metadata +63 -174
- data/lib/active_merchant/billing/gateways/beanstream.rb +0 -102
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +0 -233
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +0 -54
- data/lib/active_merchant/billing/gateways/braintree.rb +0 -17
- data/lib/active_merchant/billing/gateways/card_stream.rb +0 -230
- data/lib/active_merchant/billing/gateways/data_cash.rb +0 -595
- data/lib/active_merchant/billing/gateways/efsnet.rb +0 -229
- data/lib/active_merchant/billing/gateways/elavon.rb +0 -106
- data/lib/active_merchant/billing/gateways/eway.rb +0 -277
- data/lib/active_merchant/billing/gateways/exact.rb +0 -222
- data/lib/active_merchant/billing/gateways/first_pay.rb +0 -172
- data/lib/active_merchant/billing/gateways/instapay.rb +0 -164
- data/lib/active_merchant/billing/gateways/jetpay.rb +0 -270
- data/lib/active_merchant/billing/gateways/linkpoint.rb +0 -449
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -154
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +0 -283
- data/lib/active_merchant/billing/gateways/modern_payments.rb +0 -36
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +0 -214
- data/lib/active_merchant/billing/gateways/moneris.rb +0 -205
- data/lib/active_merchant/billing/gateways/net_registry.rb +0 -189
- data/lib/active_merchant/billing/gateways/netbilling.rb +0 -168
- data/lib/active_merchant/billing/gateways/ogone.rb +0 -279
- data/lib/active_merchant/billing/gateways/pay_junction.rb +0 -392
- data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -120
- data/lib/active_merchant/billing/gateways/payflow.rb +0 -236
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +0 -207
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +0 -39
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +0 -13
- data/lib/active_merchant/billing/gateways/payflow_express.rb +0 -138
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -15
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +0 -21
- data/lib/active_merchant/billing/gateways/payment_express.rb +0 -230
- data/lib/active_merchant/billing/gateways/paypal.rb +0 -121
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +0 -326
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +0 -38
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +0 -13
- data/lib/active_merchant/billing/gateways/paypal_express.rb +0 -130
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +0 -20
- data/lib/active_merchant/billing/gateways/plugnpay.rb +0 -292
- data/lib/active_merchant/billing/gateways/psigate.rb +0 -214
- data/lib/active_merchant/billing/gateways/psl_card.rb +0 -306
- data/lib/active_merchant/billing/gateways/quickpay.rb +0 -213
- data/lib/active_merchant/billing/gateways/realex.rb +0 -200
- data/lib/active_merchant/billing/gateways/sage.rb +0 -146
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -88
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -116
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
- data/lib/active_merchant/billing/gateways/sage_pay.rb +0 -308
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +0 -144
- data/lib/active_merchant/billing/gateways/secure_pay.rb +0 -31
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +0 -157
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -113
- data/lib/active_merchant/billing/gateways/skip_jack.rb +0 -452
- data/lib/active_merchant/billing/gateways/smart_ps.rb +0 -254
- data/lib/active_merchant/billing/gateways/trans_first.rb +0 -127
- data/lib/active_merchant/billing/gateways/transax.rb +0 -26
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +0 -418
- data/lib/active_merchant/billing/gateways/usa_epay.rb +0 -194
- data/lib/active_merchant/billing/gateways/verifi.rb +0 -228
- data/lib/active_merchant/billing/gateways/viaklix.rb +0 -189
- data/lib/active_merchant/billing/gateways/wirecard.rb +0 -318
- data/lib/active_merchant/billing/integrations.rb +0 -22
- data/lib/active_merchant/lib/error.rb +0 -4
- data/test/remote/gateways/remote_beanstream_interac_test.rb +0 -53
- data/test/remote/gateways/remote_beanstream_test.rb +0 -150
- data/test/remote/gateways/remote_braintree_test.rb +0 -154
- data/test/remote/gateways/remote_card_stream_test.rb +0 -148
- data/test/remote/gateways/remote_data_cash_test.rb +0 -357
- data/test/remote/gateways/remote_efsnet_test.rb +0 -81
- data/test/remote/gateways/remote_elavon_test.rb +0 -66
- data/test/remote/gateways/remote_eway_test.rb +0 -74
- data/test/remote/gateways/remote_exact_test.rb +0 -60
- data/test/remote/gateways/remote_first_pay_test.rb +0 -87
- data/test/remote/gateways/remote_instapay_test.rb +0 -61
- data/test/remote/gateways/remote_jetpay_test.rb +0 -103
- data/test/remote/gateways/remote_linkpoint_test.rb +0 -121
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +0 -173
- data/test/remote/gateways/remote_merchant_ware_test.rb +0 -113
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +0 -58
- data/test/remote/gateways/remote_modern_payments_test.rb +0 -43
- data/test/remote/gateways/remote_moneris_test.rb +0 -82
- data/test/remote/gateways/remote_net_registry_test.rb +0 -85
- data/test/remote/gateways/remote_netbilling_test.rb +0 -70
- data/test/remote/gateways/remote_ogone_test.rb +0 -115
- data/test/remote/gateways/remote_pay_junction_test.rb +0 -143
- data/test/remote/gateways/remote_pay_secure_test.rb +0 -39
- data/test/remote/gateways/remote_payflow_express_test.rb +0 -50
- data/test/remote/gateways/remote_payflow_test.rb +0 -237
- data/test/remote/gateways/remote_payflow_uk_test.rb +0 -173
- data/test/remote/gateways/remote_payment_express_test.rb +0 -136
- data/test/remote/gateways/remote_paypal_express_test.rb +0 -49
- data/test/remote/gateways/remote_paypal_test.rb +0 -191
- data/test/remote/gateways/remote_plugnpay_test.rb +0 -72
- data/test/remote/gateways/remote_psigate_test.rb +0 -50
- data/test/remote/gateways/remote_psl_card_test.rb +0 -125
- data/test/remote/gateways/remote_quickpay_test.rb +0 -190
- data/test/remote/gateways/remote_realex_test.rb +0 -224
- data/test/remote/gateways/remote_sage_bankcard_test.rb +0 -109
- data/test/remote/gateways/remote_sage_pay_test.rb +0 -219
- data/test/remote/gateways/remote_sage_test.rb +0 -87
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +0 -62
- data/test/remote/gateways/remote_sallie_mae_test.rb +0 -51
- data/test/remote/gateways/remote_secure_pay_au_test.rb +0 -40
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +0 -37
- data/test/remote/gateways/remote_secure_pay_test.rb +0 -28
- data/test/remote/gateways/remote_skipjack_test.rb +0 -105
- data/test/remote/gateways/remote_trans_first_test.rb +0 -34
- data/test/remote/gateways/remote_transax_test.rb +0 -112
- data/test/remote/gateways/remote_trust_commerce_test.rb +0 -152
- data/test/remote/gateways/remote_usa_epay_test.rb +0 -46
- data/test/remote/gateways/remote_verifi_test.rb +0 -107
- data/test/remote/gateways/remote_viaklix_test.rb +0 -43
- data/test/remote/gateways/remote_wirecard_test.rb +0 -111
@@ -1,154 +0,0 @@
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
2
|
-
module Billing #:nodoc:
|
3
|
-
class MerchantESolutionsGateway < Gateway
|
4
|
-
|
5
|
-
TEST_URL = 'https://test.merchante-solutions.com/mes-api/tridentApi'
|
6
|
-
LIVE_URL = 'https://api.merchante-solutions.com/mes-api/tridentApi'
|
7
|
-
|
8
|
-
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
9
|
-
self.supported_countries = ['US']
|
10
|
-
|
11
|
-
# The card types supported by the payment gateway
|
12
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb]
|
13
|
-
|
14
|
-
# The homepage URL of the gateway
|
15
|
-
self.homepage_url = 'http://www.merchante-solutions.com/'
|
16
|
-
|
17
|
-
# The name of the gateway
|
18
|
-
self.display_name = 'Merchant e-Solutions'
|
19
|
-
|
20
|
-
def initialize(options = {})
|
21
|
-
requires!(options, :login, :password)
|
22
|
-
@options = options
|
23
|
-
super
|
24
|
-
end
|
25
|
-
|
26
|
-
def authorize(money, creditcard_or_card_id, options = {})
|
27
|
-
post = {}
|
28
|
-
add_invoice(post, options)
|
29
|
-
add_payment_source(post, creditcard_or_card_id, options)
|
30
|
-
add_address(post, options)
|
31
|
-
commit('P', money, post)
|
32
|
-
end
|
33
|
-
|
34
|
-
def purchase(money, creditcard_or_card_id, options = {})
|
35
|
-
post = {}
|
36
|
-
add_invoice(post, options)
|
37
|
-
add_payment_source(post, creditcard_or_card_id, options)
|
38
|
-
add_address(post, options)
|
39
|
-
commit('D', money, post)
|
40
|
-
end
|
41
|
-
|
42
|
-
def capture(money, transaction_id, options = {})
|
43
|
-
post ={}
|
44
|
-
post[:transaction_id] = transaction_id
|
45
|
-
commit('S', money, post)
|
46
|
-
end
|
47
|
-
|
48
|
-
def store(creditcard, options = {})
|
49
|
-
post = {}
|
50
|
-
add_creditcard(post, creditcard, options)
|
51
|
-
commit('T', nil, post)
|
52
|
-
end
|
53
|
-
|
54
|
-
def unstore(card_id)
|
55
|
-
post = {}
|
56
|
-
post[:card_id] = card_id
|
57
|
-
commit('X', nil, post)
|
58
|
-
end
|
59
|
-
|
60
|
-
def credit(money, creditcard_or_card_id, options = {})
|
61
|
-
post ={}
|
62
|
-
add_payment_source(post, creditcard_or_card_id, options)
|
63
|
-
commit('C', money, post)
|
64
|
-
end
|
65
|
-
|
66
|
-
def void(transaction_id)
|
67
|
-
post = {}
|
68
|
-
post[:transaction_id] = transaction_id
|
69
|
-
commit('V', nil, post)
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def add_address(post, options)
|
75
|
-
if address = options[:billing_address] || options[:address]
|
76
|
-
post[:cardholder_street_address] = address[:address1].to_s.gsub(/[^\w.]/, '+')
|
77
|
-
post[:cardholder_zip] = address[:zip].to_s
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def add_invoice(post, options)
|
82
|
-
if options.has_key? :order_id
|
83
|
-
post[:invoice_number] = options[:order_id].to_s.gsub(/[^\w.]/, '')
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def add_payment_source(post, creditcard_or_card_id, options)
|
88
|
-
if creditcard_or_card_id.is_a?(String)
|
89
|
-
# using stored card
|
90
|
-
post[:card_id] = creditcard_or_card_id
|
91
|
-
else
|
92
|
-
# card info is provided
|
93
|
-
add_creditcard(post, creditcard_or_card_id, options)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def add_creditcard(post, creditcard, options)
|
98
|
-
post[:card_number] = creditcard.number
|
99
|
-
post[:cvv2] = creditcard.verification_value if creditcard.verification_value?
|
100
|
-
post[:card_exp_date] = expdate(creditcard)
|
101
|
-
end
|
102
|
-
|
103
|
-
def parse(body)
|
104
|
-
results = {}
|
105
|
-
body.split(/&/).each do |pair|
|
106
|
-
key,val = pair.split(/=/)
|
107
|
-
results[key] = val
|
108
|
-
end
|
109
|
-
results
|
110
|
-
end
|
111
|
-
|
112
|
-
def commit(action, money, parameters)
|
113
|
-
|
114
|
-
url = test? ? TEST_URL : LIVE_URL
|
115
|
-
parameters[:transaction_amount] = amount(money) if money unless action == 'V'
|
116
|
-
|
117
|
-
response = parse( ssl_post(url, post_data(action,parameters)) )
|
118
|
-
|
119
|
-
Response.new(response["error_code"] == "000", message_from(response), response,
|
120
|
-
:authorization => response["transaction_id"],
|
121
|
-
:test => test?,
|
122
|
-
:cvv_result => response["cvv2_result"],
|
123
|
-
:avs_result => { :code => response["avs_result"] }
|
124
|
-
)
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
def expdate(creditcard)
|
129
|
-
year = sprintf("%.4i", creditcard.year)
|
130
|
-
month = sprintf("%.2i", creditcard.month)
|
131
|
-
"#{month}#{year[-2..-1]}"
|
132
|
-
end
|
133
|
-
|
134
|
-
def message_from(response)
|
135
|
-
if response["error_code"] == "000"
|
136
|
-
"This transaction has been approved"
|
137
|
-
else
|
138
|
-
response["auth_response_text"]
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
def post_data(action, parameters = {})
|
143
|
-
post = {}
|
144
|
-
post[:profile_id] = @options[:login]
|
145
|
-
post[:profile_key] = @options[:password]
|
146
|
-
post[:transaction_type] = action if action
|
147
|
-
|
148
|
-
request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
|
149
|
-
request
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
@@ -1,283 +0,0 @@
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
2
|
-
module Billing #:nodoc:
|
3
|
-
class MerchantWareGateway < Gateway
|
4
|
-
URL = 'https://ps1.merchantware.net/MerchantWARE/ws/RetailTransaction/TXRetail.asmx'
|
5
|
-
|
6
|
-
self.supported_countries = ['US']
|
7
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
-
self.homepage_url = 'http://merchantwarehouse.com/merchantware'
|
9
|
-
self.display_name = 'MerchantWARE'
|
10
|
-
|
11
|
-
ENV_NAMESPACES = { "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|
12
|
-
"xmlns:xsd" => "http://www.w3.org/2001/XMLSchema",
|
13
|
-
"xmlns:env" => "http://schemas.xmlsoap.org/soap/envelope/"
|
14
|
-
}
|
15
|
-
TX_NAMESPACE = "http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail"
|
16
|
-
|
17
|
-
ACTIONS = {
|
18
|
-
:purchase => "IssueKeyedSale",
|
19
|
-
:authorize => "IssueKeyedPreAuth",
|
20
|
-
:capture => "IssuePostAuth",
|
21
|
-
:void => "IssueVoid",
|
22
|
-
:credit => "IssueKeyedRefund",
|
23
|
-
:reference_credit => "IssueRefundByReference"
|
24
|
-
}
|
25
|
-
|
26
|
-
# Creates a new MerchantWareGateway
|
27
|
-
#
|
28
|
-
# The gateway requires that a valid login, password, and name be passed
|
29
|
-
# in the +options+ hash.
|
30
|
-
#
|
31
|
-
# ==== Options
|
32
|
-
#
|
33
|
-
# * <tt>:login</tt> - The MerchantWARE SiteID.
|
34
|
-
# * <tt>:password</tt> - The MerchantWARE Key.
|
35
|
-
# * <tt>:name</tt> - The MerchantWARE Name.
|
36
|
-
def initialize(options = {})
|
37
|
-
requires!(options, :login, :password, :name)
|
38
|
-
@options = options
|
39
|
-
super
|
40
|
-
end
|
41
|
-
|
42
|
-
# Authorize a credit card for a given amount.
|
43
|
-
#
|
44
|
-
# ==== Parameters
|
45
|
-
# * <tt>money</tt> - The amount to be authorized. Either an Integer value in cents or a Money object.
|
46
|
-
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
47
|
-
# * <tt>options</tt>
|
48
|
-
# * <tt>:order_id</tt> - A unique reference for this order (required).
|
49
|
-
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
50
|
-
def authorize(money, credit_card, options = {})
|
51
|
-
request = build_purchase_request(:authorize, money, credit_card, options)
|
52
|
-
commit(:authorize, request)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Authorize and immediately capture funds from a credit card.
|
56
|
-
#
|
57
|
-
# ==== Parameters
|
58
|
-
# * <tt>money</tt> - The amount to be authorized. Either an Integer value in cents or a Money object.
|
59
|
-
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
60
|
-
# * <tt>options</tt>
|
61
|
-
# * <tt>:order_id</tt> - A unique reference for this order (required).
|
62
|
-
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
63
|
-
def purchase(money, credit_card, options = {})
|
64
|
-
request = build_purchase_request(:purchase, money, credit_card, options)
|
65
|
-
commit(:purchase, request)
|
66
|
-
end
|
67
|
-
|
68
|
-
# Capture authorized funds from a credit card.
|
69
|
-
#
|
70
|
-
# ==== Parameters
|
71
|
-
# * <tt>money</tt> - The amount to be captured. Either an Integer value in cents or a Money object.
|
72
|
-
# * <tt>authorization</tt> - The authorization string returned from the initial authorization.
|
73
|
-
def capture(money, authorization, options = {})
|
74
|
-
request = build_capture_request(:capture, money, authorization, options)
|
75
|
-
commit(:capture, request)
|
76
|
-
end
|
77
|
-
|
78
|
-
# Void a transaction.
|
79
|
-
#
|
80
|
-
# ==== Parameters
|
81
|
-
# * <tt>authorization</tt> - The authorization string returned from the initial authorization or purchase.
|
82
|
-
def void(authorization, options = {})
|
83
|
-
reference, options[:order_id] = split_reference(authorization)
|
84
|
-
|
85
|
-
request = soap_request(:void) do |xml|
|
86
|
-
add_reference(xml, reference)
|
87
|
-
end
|
88
|
-
commit(:void, request)
|
89
|
-
end
|
90
|
-
|
91
|
-
# Refund an amount back a cardholder
|
92
|
-
#
|
93
|
-
# ==== Parameters
|
94
|
-
#
|
95
|
-
# * <tt>money</tt> - The amount to be refunded. Either an Integer value in cents or a Money object.
|
96
|
-
# * <tt>identification</tt> - The credit card you want to refund or the authorization for the existing transaction you are refunding.
|
97
|
-
# * <tt>options</tt>
|
98
|
-
# * <tt>:order_id</tt> - A unique reference for this order (required when performing a non-referenced credit)
|
99
|
-
def credit(money, identification, options = {})
|
100
|
-
if identification.is_a?(String)
|
101
|
-
perform_reference_credit(money, identification, options)
|
102
|
-
else
|
103
|
-
perform_credit(money, identification, options)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
|
109
|
-
def soap_request(action)
|
110
|
-
xml = Builder::XmlMarkup.new :indent => 2
|
111
|
-
xml.instruct!
|
112
|
-
xml.tag! "env:Envelope", ENV_NAMESPACES do
|
113
|
-
xml.tag! "env:Body" do
|
114
|
-
xml.tag! ACTIONS[action], "xmlns" => TX_NAMESPACE do
|
115
|
-
add_credentials(xml)
|
116
|
-
yield xml
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
xml.target!
|
121
|
-
end
|
122
|
-
|
123
|
-
def build_purchase_request(action, money, credit_card, options)
|
124
|
-
requires!(options, :order_id)
|
125
|
-
|
126
|
-
request = soap_request(action) do |xml|
|
127
|
-
add_invoice(xml, options)
|
128
|
-
add_amount(xml, money)
|
129
|
-
add_credit_card(xml, credit_card)
|
130
|
-
add_address(xml, options)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
def build_capture_request(action, money, identification, options)
|
135
|
-
reference, options[:order_id] = split_reference(identification)
|
136
|
-
|
137
|
-
request = soap_request(action) do |xml|
|
138
|
-
add_reference(xml, reference)
|
139
|
-
add_invoice(xml, options)
|
140
|
-
add_amount(xml, money)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
def perform_reference_credit(money, identification, options)
|
145
|
-
reference, options[:order_id] = split_reference(identification)
|
146
|
-
|
147
|
-
request = soap_request(:reference_credit) do |xml|
|
148
|
-
add_reference(xml, reference)
|
149
|
-
add_invoice(xml, options)
|
150
|
-
add_amount(xml, money, "strOverrideAmount")
|
151
|
-
end
|
152
|
-
|
153
|
-
commit(:reference_credit, request)
|
154
|
-
end
|
155
|
-
|
156
|
-
def perform_credit(money, credit_card, options)
|
157
|
-
requires!(options, :order_id)
|
158
|
-
|
159
|
-
request = soap_request(:credit) do |xml|
|
160
|
-
add_invoice(xml, options)
|
161
|
-
add_amount(xml, money)
|
162
|
-
add_credit_card(xml, credit_card)
|
163
|
-
end
|
164
|
-
|
165
|
-
commit(:credit, request)
|
166
|
-
end
|
167
|
-
|
168
|
-
def add_credentials(xml)
|
169
|
-
xml.tag! "strSiteId", @options[:login]
|
170
|
-
xml.tag! "strKey", @options[:password]
|
171
|
-
xml.tag! "strName", @options[:name]
|
172
|
-
end
|
173
|
-
|
174
|
-
def expdate(credit_card)
|
175
|
-
year = sprintf("%.4i", credit_card.year)
|
176
|
-
month = sprintf("%.2i", credit_card.month)
|
177
|
-
|
178
|
-
"#{month}#{year[-2..-1]}"
|
179
|
-
end
|
180
|
-
|
181
|
-
def add_invoice(xml, options)
|
182
|
-
xml.tag! "strOrderNumber", options[:order_id].to_s.gsub(/[^\w]/, '').slice(0, 25)
|
183
|
-
end
|
184
|
-
|
185
|
-
def add_amount(xml, money, tag = "strAmount")
|
186
|
-
xml.tag! tag, amount(money)
|
187
|
-
end
|
188
|
-
|
189
|
-
def add_reference(xml, reference)
|
190
|
-
xml.tag! "strReferenceCode", reference
|
191
|
-
end
|
192
|
-
|
193
|
-
def add_address(xml, options)
|
194
|
-
if address = options[:billing_address] || options[:address]
|
195
|
-
xml.tag! "strAVSStreetAddress", address[:address1]
|
196
|
-
xml.tag! "strAVSZipCode", address[:zip]
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def add_credit_card(xml, credit_card)
|
201
|
-
xml.tag! "strPAN", credit_card.number
|
202
|
-
xml.tag! "strExpDate", expdate(credit_card)
|
203
|
-
xml.tag! "strCardHolder", credit_card.name
|
204
|
-
xml.tag! "strCVCode", credit_card.verification_value if credit_card.verification_value?
|
205
|
-
end
|
206
|
-
|
207
|
-
def split_reference(reference)
|
208
|
-
reference.to_s.split(";")
|
209
|
-
end
|
210
|
-
|
211
|
-
def parse(action, data)
|
212
|
-
response = {}
|
213
|
-
xml = REXML::Document.new(data)
|
214
|
-
|
215
|
-
root = REXML::XPath.first(xml, "//#{ACTIONS[action]}Response/#{ACTIONS[action]}Result")
|
216
|
-
|
217
|
-
root.elements.each do |element|
|
218
|
-
response[element.name] = element.text
|
219
|
-
end
|
220
|
-
|
221
|
-
status, code, message = response["ApprovalStatus"].split(";")
|
222
|
-
response[:status] = status
|
223
|
-
|
224
|
-
if response[:success] = status == "APPROVED"
|
225
|
-
response[:message] = status
|
226
|
-
else
|
227
|
-
response[:message] = message
|
228
|
-
response[:failure_code] = code
|
229
|
-
end
|
230
|
-
|
231
|
-
response
|
232
|
-
end
|
233
|
-
|
234
|
-
def parse_error(http_response)
|
235
|
-
response = {}
|
236
|
-
response[:http_code] = http_response.code
|
237
|
-
response[:http_message] = http_response.message
|
238
|
-
response[:success] = false
|
239
|
-
|
240
|
-
document = REXML::Document.new(http_response.body)
|
241
|
-
|
242
|
-
node = REXML::XPath.first(document, "//soap:Fault")
|
243
|
-
|
244
|
-
node.elements.each do |element|
|
245
|
-
response[element.name] = element.text
|
246
|
-
end
|
247
|
-
|
248
|
-
response[:message] = response["faultstring"].to_s.gsub("\n", " ")
|
249
|
-
response
|
250
|
-
rescue REXML::ParseException => e
|
251
|
-
response[:http_body] = http_response.body
|
252
|
-
response[:message] = "Failed to parse the failed response"
|
253
|
-
response
|
254
|
-
end
|
255
|
-
|
256
|
-
def commit(action, request)
|
257
|
-
begin
|
258
|
-
data = ssl_post(URL, request,
|
259
|
-
"Content-Type" => 'text/xml; charset=utf-8',
|
260
|
-
"SOAPAction" => "http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail/#{ACTIONS[action]}"
|
261
|
-
)
|
262
|
-
response = parse(action, data)
|
263
|
-
rescue ActiveMerchant::ResponseError => e
|
264
|
-
response = parse_error(e.response)
|
265
|
-
end
|
266
|
-
|
267
|
-
Response.new(response[:success], response[:message], response,
|
268
|
-
:test => test?,
|
269
|
-
:authorization => authorization_from(response),
|
270
|
-
:avs_result => { :code => response["AVSResponse"] },
|
271
|
-
:cvv_result => response["CVResponse"]
|
272
|
-
)
|
273
|
-
end
|
274
|
-
|
275
|
-
def authorization_from(response)
|
276
|
-
if response[:success]
|
277
|
-
[ response["ReferenceID"], response["OrderNumber"] ].join(";")
|
278
|
-
end
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/modern_payments_cim'
|
2
|
-
|
3
|
-
module ActiveMerchant #:nodoc:
|
4
|
-
module Billing #:nodoc:
|
5
|
-
class ModernPaymentsGateway < Gateway
|
6
|
-
self.supported_countries = ModernPaymentsCimGateway.supported_countries
|
7
|
-
self.supported_cardtypes = ModernPaymentsCimGateway.supported_cardtypes
|
8
|
-
self.homepage_url = ModernPaymentsCimGateway.homepage_url
|
9
|
-
self.display_name = ModernPaymentsCimGateway.display_name
|
10
|
-
|
11
|
-
def initialize(options = {})
|
12
|
-
requires!(options, :login, :password)
|
13
|
-
@options = options
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
def purchase(money, credit_card, options = {})
|
18
|
-
customer_response = cim.create_customer(options)
|
19
|
-
return customer_response unless customer_response.success?
|
20
|
-
|
21
|
-
customer_id = customer_response.params["create_customer_result"]
|
22
|
-
|
23
|
-
card_response = cim.modify_customer_credit_card(customer_id, credit_card)
|
24
|
-
return card_response unless card_response.success?
|
25
|
-
|
26
|
-
cim.authorize_credit_card_payment(customer_id, money)
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
def cim
|
31
|
-
@cim ||= ModernPaymentsCimGateway.new(@options)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|