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,127 +0,0 @@
|
|
1
|
-
module ActiveMerchant #:nodoc:
|
2
|
-
module Billing #:nodoc:
|
3
|
-
class TransFirstGateway < Gateway
|
4
|
-
URL = 'https://webservices.primerchants.com/creditcard.asmx/CCSale'
|
5
|
-
|
6
|
-
self.supported_countries = ['US']
|
7
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
8
|
-
self.homepage_url = 'http://www.transfirst.com/'
|
9
|
-
self.display_name = 'TransFirst'
|
10
|
-
|
11
|
-
UNUSED_FIELDS = %w(ECIValue UserId CAVVData TrackData POSInd EComInd MerchZIP MerchCustPNum MCC InstallmentNum InstallmentOf POSEntryMode POSConditionCode AuthCharInd CardCertData)
|
12
|
-
|
13
|
-
DECLINED = 'The transaction was declined'
|
14
|
-
|
15
|
-
def initialize(options = {})
|
16
|
-
requires!(options, :login, :password)
|
17
|
-
@options = options
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def purchase(money, credit_card, options = {})
|
22
|
-
post = {}
|
23
|
-
|
24
|
-
add_amount(post, money)
|
25
|
-
add_invoice(post, options)
|
26
|
-
add_credit_card(post, credit_card)
|
27
|
-
add_address(post, options)
|
28
|
-
|
29
|
-
commit(post)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
def add_amount(post, money)
|
34
|
-
add_pair(post, :Amount, amount(money), :required => true)
|
35
|
-
end
|
36
|
-
|
37
|
-
def add_address(post, options)
|
38
|
-
address = options[:billing_address] || options[:address]
|
39
|
-
|
40
|
-
if address
|
41
|
-
add_pair(post, :Address, address[:address1])
|
42
|
-
add_pair(post, :ZipCode, address[:zip])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def add_invoice(post, options)
|
47
|
-
add_pair(post, :RefID, options[:order_id], :required => true)
|
48
|
-
add_pair(post, :PONumber, options[:invoice], :required => true)
|
49
|
-
add_pair(post, :SaleTaxAmount, amount(options[:tax] || 0))
|
50
|
-
add_pair(post, :PaymentDesc, options[:description], :required => true)
|
51
|
-
add_pair(post, :TaxIndicator, 0)
|
52
|
-
end
|
53
|
-
|
54
|
-
def add_credit_card(post, credit_card)
|
55
|
-
add_pair(post, :CardHolderName, credit_card.name, :required => true)
|
56
|
-
add_pair(post, :CardNumber, credit_card.number, :required => true)
|
57
|
-
|
58
|
-
add_pair(post, :Expiration, expdate(credit_card), :required => true)
|
59
|
-
add_pair(post, :CVV2, credit_card.verification_value)
|
60
|
-
end
|
61
|
-
|
62
|
-
def add_unused_fields(post)
|
63
|
-
UNUSED_FIELDS.each do |f|
|
64
|
-
post[f] = ""
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def expdate(credit_card)
|
69
|
-
year = format(credit_card.year, :two_digits)
|
70
|
-
month = format(credit_card.month, :two_digits)
|
71
|
-
|
72
|
-
"#{month}#{year}"
|
73
|
-
end
|
74
|
-
|
75
|
-
def parse(data)
|
76
|
-
response = {}
|
77
|
-
|
78
|
-
xml = REXML::Document.new(data)
|
79
|
-
root = REXML::XPath.first(xml, "//CCSaleDebitResponse")
|
80
|
-
|
81
|
-
if root.nil?
|
82
|
-
response[:message] = data.to_s.strip
|
83
|
-
else
|
84
|
-
root.elements.to_a.each do |node|
|
85
|
-
response[node.name.underscore.to_sym] = node.text
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
response
|
90
|
-
end
|
91
|
-
|
92
|
-
def commit(params)
|
93
|
-
response = parse( ssl_post(URL, post_data(params)) )
|
94
|
-
|
95
|
-
Response.new(response[:status] == "Authorized", message_from(response), response,
|
96
|
-
:test => test?,
|
97
|
-
:authorization => response[:trans_id],
|
98
|
-
:avs_result => { :code => response[:avs_code] },
|
99
|
-
:cvv_result => response[:cvv2_code]
|
100
|
-
)
|
101
|
-
end
|
102
|
-
|
103
|
-
def message_from(response)
|
104
|
-
case response[:message]
|
105
|
-
when 'Call Voice Center'
|
106
|
-
DECLINED
|
107
|
-
else
|
108
|
-
response[:message]
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
def post_data(params = {})
|
113
|
-
add_unused_fields(params)
|
114
|
-
params[:MerchantID] = @options[:login]
|
115
|
-
params[:RegKey] = @options[:password]
|
116
|
-
|
117
|
-
request = params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
|
118
|
-
request
|
119
|
-
end
|
120
|
-
|
121
|
-
def add_pair(post, key, value, options = {})
|
122
|
-
post[key] = value if !value.blank? || options[:required]
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),'smart_ps.rb')
|
2
|
-
|
3
|
-
module ActiveMerchant #:nodoc:
|
4
|
-
module Billing #:nodoc:
|
5
|
-
class TransaxGateway < SmartPs
|
6
|
-
def api_url
|
7
|
-
'https://secure.nelixtransax.net/api/transact.php'
|
8
|
-
end
|
9
|
-
|
10
|
-
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
11
|
-
self.supported_countries = ['US']
|
12
|
-
|
13
|
-
# The card types supported by the payment gateway
|
14
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
15
|
-
|
16
|
-
# The homepage URL of the gateway
|
17
|
-
self.homepage_url = 'https://www.nelixtransax.com/'
|
18
|
-
|
19
|
-
# The name of the gateway
|
20
|
-
self.display_name = 'NELiX TransaX'
|
21
|
-
|
22
|
-
end
|
23
|
-
TransaXGateway = TransaxGateway
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
@@ -1,418 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'tclink'
|
3
|
-
rescue LoadError
|
4
|
-
# Falls back to an SSL post to TrustCommerce
|
5
|
-
end
|
6
|
-
|
7
|
-
module ActiveMerchant #:nodoc:
|
8
|
-
module Billing #:nodoc:
|
9
|
-
# TO USE:
|
10
|
-
# First, make sure you have everything setup correctly and all of your dependencies in place with:
|
11
|
-
#
|
12
|
-
# require 'rubygems'
|
13
|
-
# require 'active_merchant'
|
14
|
-
#
|
15
|
-
# ActiveMerchant expects amounts to be Integer values in cents
|
16
|
-
#
|
17
|
-
# tendollar = 1000
|
18
|
-
#
|
19
|
-
# Next, create a credit card object using a TC approved test card.
|
20
|
-
#
|
21
|
-
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
22
|
-
# :number => '4111111111111111',
|
23
|
-
# :month => 8,
|
24
|
-
# :year => 2006,
|
25
|
-
# :first_name => 'Longbob',
|
26
|
-
# :last_name => 'Longsen'
|
27
|
-
# )
|
28
|
-
#
|
29
|
-
# To finish setting up, create the active_merchant object you will be using, with the TrustCommerce gateway. If you have a
|
30
|
-
# functional TrustCommerce account, replace login and password with your account info. Otherwise the defaults will work for
|
31
|
-
# testing.
|
32
|
-
#
|
33
|
-
# gateway = ActiveMerchant::Billing::Base.gateway(:trust_commerce).new(:login => "TestMerchant", :password => "password")
|
34
|
-
#
|
35
|
-
# Now we are ready to process our transaction
|
36
|
-
#
|
37
|
-
# response = gateway.purchase(tendollar, creditcard)
|
38
|
-
#
|
39
|
-
# Sending a transaction to TrustCommerce with active_merchant returns a Response object, which consistently allows you to:
|
40
|
-
#
|
41
|
-
# 1) Check whether the transaction was successful
|
42
|
-
#
|
43
|
-
# response.success?
|
44
|
-
#
|
45
|
-
# 2) Retrieve any message returned by TrustCommerce, either a "transaction was successful" note or an explanation of why the
|
46
|
-
# transaction was rejected.
|
47
|
-
#
|
48
|
-
# response.message
|
49
|
-
#
|
50
|
-
# 3) Retrieve and store the unique transaction ID returned by Trust Commerece, for use in referencing the transaction in the future.
|
51
|
-
#
|
52
|
-
# response.params["transid"]
|
53
|
-
#
|
54
|
-
# For higher performance and failover with the TrustCommerceGateway you can install the TCLink library from http://www.trustcommerce.com/tclink.html.
|
55
|
-
# Follow the instructions available there to get it working on your system. ActiveMerchant will automatically use tclink if available.
|
56
|
-
#
|
57
|
-
# The TCLink library has the following added benefits:
|
58
|
-
# * Good transaction times. Transaction duration under 1.2 seconds are common.
|
59
|
-
# * Fail-over to geographically distributed servers for extreme reliability
|
60
|
-
#
|
61
|
-
# Once it is installed, you should be able to make sure
|
62
|
-
# that it is visible to your ruby install by opening irb and typing "require 'tclink'", which should return "true".
|
63
|
-
#
|
64
|
-
# This should be enough to get you started with Trust Commerce and active_merchant. For further information, review the methods
|
65
|
-
# below and the rest of active_merchant's documentation, as well as Trust Commerce's user and developer documentation.
|
66
|
-
|
67
|
-
class TrustCommerceGateway < Gateway
|
68
|
-
URL = 'https://vault.trustcommerce.com/trans/'
|
69
|
-
|
70
|
-
SUCCESS_TYPES = ["approved", "accepted"]
|
71
|
-
|
72
|
-
DECLINE_CODES = {
|
73
|
-
"decline" => "The credit card was declined",
|
74
|
-
"avs" => "AVS failed; the address entered does not match the billing address on file at the bank",
|
75
|
-
"cvv" => "CVV failed; the number provided is not the correct verification number for the card",
|
76
|
-
"call" => "The card must be authorized manually over the phone",
|
77
|
-
"expiredcard" => "Issuer was not certified for card verification",
|
78
|
-
"carderror" => "Card number is invalid",
|
79
|
-
"authexpired" => "Attempt to postauth an expired (more than 14 days old) preauth",
|
80
|
-
"fraud" => "CrediGuard fraud score was below requested threshold",
|
81
|
-
"blacklist" => "CrediGuard blacklist value was triggered",
|
82
|
-
"velocity" => "CrediGuard velocity control value was triggered",
|
83
|
-
"dailylimit" => "Daily limit in transaction count or amount as been reached",
|
84
|
-
"weeklylimit" => "Weekly limit in transaction count or amount as been reached",
|
85
|
-
"monthlylimit" => "Monthly limit in transaction count or amount as been reached"
|
86
|
-
}
|
87
|
-
|
88
|
-
BADDATA_CODES = {
|
89
|
-
"missingfields" => "One or more parameters required for this transaction type were not sent",
|
90
|
-
"extrafields" => "Parameters not allowed for this transaction type were sent",
|
91
|
-
"badformat" => "A field was improperly formatted, such as non-digit characters in a number field",
|
92
|
-
"badlength" => "A field was longer or shorter than the server allows",
|
93
|
-
"merchantcantaccept" => "The merchant can't accept data passed in this field",
|
94
|
-
"mismatch" => "Data in one of the offending fields did not cross-check with the other offending field"
|
95
|
-
}
|
96
|
-
|
97
|
-
ERROR_CODES = {
|
98
|
-
"cantconnect" => "Couldn't connect to the TrustCommerce gateway",
|
99
|
-
"dnsfailure" => "The TCLink software was unable to resolve DNS hostnames",
|
100
|
-
"linkfailure" => "The connection was established, but was severed before the transaction could complete",
|
101
|
-
"failtoprocess" => "The bank servers are offline and unable to authorize transactions"
|
102
|
-
}
|
103
|
-
|
104
|
-
TEST_LOGIN = 'TestMerchant'
|
105
|
-
TEST_PASSWORD = 'password'
|
106
|
-
|
107
|
-
self.money_format = :cents
|
108
|
-
self.supported_cardtypes = [:visa, :master, :discover, :american_express, :diners_club, :jcb]
|
109
|
-
self.supported_countries = ['US']
|
110
|
-
self.homepage_url = 'http://www.trustcommerce.com/'
|
111
|
-
self.display_name = 'TrustCommerce'
|
112
|
-
|
113
|
-
def self.tclink?
|
114
|
-
defined?(TCLink)
|
115
|
-
end
|
116
|
-
|
117
|
-
# Creates a new TrustCommerceGateway
|
118
|
-
#
|
119
|
-
# The gateway requires that a valid login and password be passed
|
120
|
-
# in the +options+ hash.
|
121
|
-
#
|
122
|
-
# ==== Options
|
123
|
-
#
|
124
|
-
# * <tt>:login</tt> -- The TrustCommerce account login.
|
125
|
-
# * <tt>:password</tt> -- The TrustCommerce account password.
|
126
|
-
# * <tt>:test => +true+ or +false+</tt> -- Perform test transactions
|
127
|
-
#
|
128
|
-
# ==== Test Account Credentials
|
129
|
-
# * <tt>:login</tt> -- TestMerchant
|
130
|
-
# * <tt>:password</tt> -- password
|
131
|
-
def initialize(options = {})
|
132
|
-
requires!(options, :login, :password)
|
133
|
-
|
134
|
-
@options = options
|
135
|
-
super
|
136
|
-
end
|
137
|
-
|
138
|
-
def tclink?
|
139
|
-
self.class.tclink?
|
140
|
-
end
|
141
|
-
|
142
|
-
def test?
|
143
|
-
@options[:login] == TEST_LOGIN &&
|
144
|
-
@options[:password] == TEST_PASSWORD || @options[:test] || super
|
145
|
-
end
|
146
|
-
|
147
|
-
# authorize() is the first half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
148
|
-
# preauth, we preserve active_merchant's nomenclature of authorize() for consistency with the rest of the library. This
|
149
|
-
# method simply checks to make sure funds are available for a transaction, and returns a transid that can be used later to
|
150
|
-
# postauthorize (capture) the funds.
|
151
|
-
|
152
|
-
def authorize(money, creditcard_or_billing_id, options = {})
|
153
|
-
parameters = {
|
154
|
-
:amount => amount(money),
|
155
|
-
}
|
156
|
-
|
157
|
-
add_order_id(parameters, options)
|
158
|
-
add_customer_data(parameters, options)
|
159
|
-
add_payment_source(parameters, creditcard_or_billing_id)
|
160
|
-
add_addresses(parameters, options)
|
161
|
-
commit('preauth', parameters)
|
162
|
-
end
|
163
|
-
|
164
|
-
# purchase() is a simple sale. This is one of the most common types of transactions, and is extremely simple. All that you need
|
165
|
-
# to process a purchase are an amount in cents or a money object and a creditcard object or billingid string.
|
166
|
-
def purchase(money, creditcard_or_billing_id, options = {})
|
167
|
-
parameters = {
|
168
|
-
:amount => amount(money),
|
169
|
-
}
|
170
|
-
|
171
|
-
add_order_id(parameters, options)
|
172
|
-
add_customer_data(parameters, options)
|
173
|
-
add_payment_source(parameters, creditcard_or_billing_id)
|
174
|
-
add_addresses(parameters, options)
|
175
|
-
commit('sale', parameters)
|
176
|
-
end
|
177
|
-
|
178
|
-
# capture() is the second half of the preauth(authorize)/postauth(capture) model. The TC API docs call this
|
179
|
-
# postauth, we preserve active_merchant's nomenclature of capture() for consistency with the rest of the library. To process
|
180
|
-
# a postauthorization with TC, you need an amount in cents or a money object, and a TC transid.
|
181
|
-
def capture(money, authorization, options = {})
|
182
|
-
parameters = {
|
183
|
-
:amount => amount(money),
|
184
|
-
:transid => authorization,
|
185
|
-
}
|
186
|
-
|
187
|
-
commit('postauth', parameters)
|
188
|
-
end
|
189
|
-
|
190
|
-
# credit() allows you to return money to a card that was previously billed. You need to supply the amount, in cents or a money object,
|
191
|
-
# that you want to refund, and a TC transid for the transaction that you are refunding.
|
192
|
-
def credit(money, identification, options = {})
|
193
|
-
parameters = {
|
194
|
-
:amount => amount(money),
|
195
|
-
:transid => identification
|
196
|
-
}
|
197
|
-
|
198
|
-
commit('credit', parameters)
|
199
|
-
end
|
200
|
-
|
201
|
-
# void() clears an existing authorization and releases the reserved fund
|
202
|
-
# s back to the cardholder. The TC API refers to this transaction as a
|
203
|
-
# reversal. After voiding, you will no longer be able to capture funds
|
204
|
-
# from this authorization. TrustCommerce seems to always return a status
|
205
|
-
# of "accepted" even if the transid you are trying to deauthorize has
|
206
|
-
# already been captured. Note: Your account needs to be configured by
|
207
|
-
# TrustCommerce to allow for reversal transactions before you can use this
|
208
|
-
# method.
|
209
|
-
#
|
210
|
-
# NOTE: AMEX preauth's cannot be reversed. If you want to clear it more
|
211
|
-
# quickly than the automatic expiration (7-10 days), you will have to
|
212
|
-
# capture it and then immediately issue a credit for the same amount
|
213
|
-
# which should clear the customers credit card with 48 hours according to
|
214
|
-
# TC.
|
215
|
-
def void(authorization, options = {})
|
216
|
-
parameters = {
|
217
|
-
:transid => authorization,
|
218
|
-
}
|
219
|
-
|
220
|
-
commit('reversal', parameters)
|
221
|
-
end
|
222
|
-
|
223
|
-
# recurring() a TrustCommerce account that is activated for Citatdel, TrustCommerce's
|
224
|
-
# hosted customer billing info database.
|
225
|
-
#
|
226
|
-
# Recurring billing uses the same TC action as a plain-vanilla 'store', but we have a separate method for clarity. It can be called
|
227
|
-
# like store, with the addition of a required 'periodicity' parameter:
|
228
|
-
#
|
229
|
-
# The parameter :periodicity should be specified as either :bimonthly, :monthly, :biweekly, :weekly, :yearly or :daily
|
230
|
-
#
|
231
|
-
# gateway.recurring(tendollar, creditcard, :periodicity => :weekly)
|
232
|
-
#
|
233
|
-
# You can optionally specify how long you want payments to continue using 'payments'
|
234
|
-
def recurring(money, creditcard, options = {})
|
235
|
-
requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )
|
236
|
-
|
237
|
-
cycle = case options[:periodicity]
|
238
|
-
when :monthly
|
239
|
-
'1m'
|
240
|
-
when :bimonthly
|
241
|
-
'2m'
|
242
|
-
when :weekly
|
243
|
-
'1w'
|
244
|
-
when :biweekly
|
245
|
-
'2w'
|
246
|
-
when :yearly
|
247
|
-
'1y'
|
248
|
-
when :daily
|
249
|
-
'1d'
|
250
|
-
end
|
251
|
-
|
252
|
-
parameters = {
|
253
|
-
:amount => amount(money),
|
254
|
-
:cycle => cycle,
|
255
|
-
:verify => options[:verify] || 'y',
|
256
|
-
:billingid => options[:billingid] || nil,
|
257
|
-
:payments => options[:payments] || nil,
|
258
|
-
}
|
259
|
-
|
260
|
-
add_creditcard(parameters, creditcard)
|
261
|
-
|
262
|
-
commit('store', parameters)
|
263
|
-
end
|
264
|
-
|
265
|
-
# store() requires a TrustCommerce account that is activated for Citatdel. You can call it with a credit card and a billing ID
|
266
|
-
# you would like to use to reference the stored credit card info for future captures. Use 'verify' to specify whether you want
|
267
|
-
# to simply store the card in the DB, or you want TC to verify the data first.
|
268
|
-
|
269
|
-
def store(creditcard, options = {})
|
270
|
-
parameters = {
|
271
|
-
:verify => options[:verify] || 'y',
|
272
|
-
:billingid => options[:billingid] || options[:billing_id] || nil,
|
273
|
-
}
|
274
|
-
|
275
|
-
add_creditcard(parameters, creditcard)
|
276
|
-
add_addresses(parameters, options)
|
277
|
-
commit('store', parameters)
|
278
|
-
end
|
279
|
-
|
280
|
-
# To unstore a creditcard stored in Citadel using store() or recurring(), all that is required is the billing id. When you run
|
281
|
-
# unstore() the information will be removed and a Response object will be returned indicating the success of the action.
|
282
|
-
def unstore(identification, options = {})
|
283
|
-
parameters = {
|
284
|
-
:billingid => identification,
|
285
|
-
}
|
286
|
-
|
287
|
-
commit('unstore', parameters)
|
288
|
-
end
|
289
|
-
|
290
|
-
private
|
291
|
-
def add_payment_source(params, source)
|
292
|
-
if source.is_a?(String)
|
293
|
-
add_billing_id(params, source)
|
294
|
-
else
|
295
|
-
add_creditcard(params, source)
|
296
|
-
end
|
297
|
-
end
|
298
|
-
|
299
|
-
def expdate(creditcard)
|
300
|
-
year = sprintf("%.4i", creditcard.year)
|
301
|
-
month = sprintf("%.2i", creditcard.month)
|
302
|
-
|
303
|
-
"#{month}#{year[-2..-1]}"
|
304
|
-
end
|
305
|
-
|
306
|
-
def add_creditcard(params, creditcard)
|
307
|
-
params[:media] = "cc"
|
308
|
-
params[:name] = creditcard.name
|
309
|
-
params[:cc] = creditcard.number
|
310
|
-
params[:exp] = expdate(creditcard)
|
311
|
-
params[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
312
|
-
end
|
313
|
-
|
314
|
-
def add_order_id(params, options)
|
315
|
-
params[:ticket] = options[:order_id] unless options[:order_id].blank?
|
316
|
-
end
|
317
|
-
|
318
|
-
def add_billing_id(params, billingid)
|
319
|
-
params[:billingid] = billingid
|
320
|
-
end
|
321
|
-
|
322
|
-
def add_customer_data(params, options)
|
323
|
-
params[:email] = options[:email] unless options[:email].blank?
|
324
|
-
params[:ip] = options[:ip] unless options[:ip].blank?
|
325
|
-
end
|
326
|
-
|
327
|
-
def add_addresses(params, options)
|
328
|
-
address = options[:billing_address] || options[:address]
|
329
|
-
|
330
|
-
if address
|
331
|
-
params[:address1] = address[:address1] unless address[:address1].blank?
|
332
|
-
params[:address2] = address[:address2] unless address[:address2].blank?
|
333
|
-
params[:city] = address[:city] unless address[:city].blank?
|
334
|
-
params[:state] = address[:state] unless address[:state].blank?
|
335
|
-
params[:zip] = address[:zip] unless address[:zip].blank?
|
336
|
-
params[:country] = address[:country] unless address[:country].blank?
|
337
|
-
params[:avs] = 'n'
|
338
|
-
end
|
339
|
-
|
340
|
-
if shipping_address = options[:shipping_address]
|
341
|
-
params[:shipto_name] = shipping_address[:name] unless shipping_address[:name].blank?
|
342
|
-
params[:shipto_address1] = shipping_address[:address1] unless shipping_address[:address1].blank?
|
343
|
-
params[:shipto_address2] = shipping_address[:address2] unless shipping_address[:address2].blank?
|
344
|
-
params[:shipto_city] = shipping_address[:city] unless shipping_address[:city].blank?
|
345
|
-
params[:shipto_state] = shipping_address[:state] unless shipping_address[:state].blank?
|
346
|
-
params[:shipto_zip] = shipping_address[:zip] unless shipping_address[:zip].blank?
|
347
|
-
params[:shipto_country] = shipping_address[:country] unless shipping_address[:country].blank?
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
def clean_and_stringify_params(parameters)
|
352
|
-
# TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
|
353
|
-
# symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
|
354
|
-
# We also remove any pairs with nil values, as these confuse TCLink.
|
355
|
-
parameters.keys.reverse.each do |key|
|
356
|
-
if parameters[key]
|
357
|
-
parameters[key.to_s] = parameters[key]
|
358
|
-
end
|
359
|
-
parameters.delete(key)
|
360
|
-
end
|
361
|
-
end
|
362
|
-
|
363
|
-
def post_data(parameters)
|
364
|
-
parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join("&")
|
365
|
-
end
|
366
|
-
|
367
|
-
def commit(action, parameters)
|
368
|
-
parameters[:custid] = @options[:login]
|
369
|
-
parameters[:password] = @options[:password]
|
370
|
-
parameters[:demo] = test? ? 'y' : 'n'
|
371
|
-
parameters[:action] = action
|
372
|
-
|
373
|
-
clean_and_stringify_params(parameters)
|
374
|
-
|
375
|
-
data = if tclink?
|
376
|
-
TCLink.send(parameters)
|
377
|
-
else
|
378
|
-
parse( ssl_post(URL, post_data(parameters)) )
|
379
|
-
end
|
380
|
-
|
381
|
-
# to be considered successful, transaction status must be either "approved" or "accepted"
|
382
|
-
success = SUCCESS_TYPES.include?(data["status"])
|
383
|
-
message = message_from(data)
|
384
|
-
Response.new(success, message, data,
|
385
|
-
:test => test?,
|
386
|
-
:authorization => data["transid"],
|
387
|
-
:cvv_result => data["cvv"],
|
388
|
-
:avs_result => { :code => data["avs"] }
|
389
|
-
)
|
390
|
-
end
|
391
|
-
|
392
|
-
def parse(body)
|
393
|
-
results = {}
|
394
|
-
|
395
|
-
body.split(/\n/).each do |pair|
|
396
|
-
key,val = pair.split(/=/)
|
397
|
-
results[key] = val
|
398
|
-
end
|
399
|
-
|
400
|
-
results
|
401
|
-
end
|
402
|
-
|
403
|
-
def message_from(data)
|
404
|
-
status = case data["status"]
|
405
|
-
when "decline"
|
406
|
-
return DECLINE_CODES[data["declinetype"]]
|
407
|
-
when "baddata"
|
408
|
-
return BADDATA_CODES[data["error"]]
|
409
|
-
when "error"
|
410
|
-
return ERROR_CODES[data["errortype"]]
|
411
|
-
else
|
412
|
-
return "The transaction was successful"
|
413
|
-
end
|
414
|
-
end
|
415
|
-
|
416
|
-
end
|
417
|
-
end
|
418
|
-
end
|