activemerchant 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +78 -0
- data/{CONTRIBUTERS → CONTRIBUTORS} +44 -0
- data/{README → README.rdoc} +4 -1
- data/Rakefile +7 -13
- data/lib/active_merchant.rb +11 -21
- data/lib/active_merchant/billing/avs_result.rb +13 -10
- data/lib/active_merchant/billing/base.rb +2 -2
- data/lib/active_merchant/billing/check.rb +1 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
- data/lib/active_merchant/billing/expiry_date.rb +10 -4
- data/lib/active_merchant/billing/gateway.rb +7 -6
- data/lib/active_merchant/billing/gateways.rb +18 -3
- data/lib/active_merchant/billing/gateways/authorize_net.rb +20 -12
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +40 -6
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +736 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +6 -211
- data/lib/active_merchant/billing/gateways/data_cash.rb +5 -7
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/eway.rb +7 -2
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +65 -12
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +12 -6
- data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +20 -32
- data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/psl_card.rb +4 -6
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +7 -1
- data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +60 -35
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +23 -10
- data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +38 -14
- data/lib/active_merchant/billing/gateways/wirecard.rb +15 -2
- data/lib/active_merchant/billing/integrations.rb +18 -11
- data/lib/active_merchant/billing/integrations/bogus.rb +4 -3
- data/lib/active_merchant/billing/integrations/chronopay.rb +4 -3
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +3 -1
- data/lib/active_merchant/billing/integrations/gestpay.rb +4 -5
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +3 -1
- data/lib/active_merchant/billing/integrations/hi_trust.rb +4 -3
- data/lib/active_merchant/billing/integrations/nochex.rb +4 -3
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal.rb +3 -4
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +9 -8
- data/lib/active_merchant/billing/integrations/quickpay.rb +2 -3
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
- data/lib/active_merchant/billing/integrations/two_checkout.rb +3 -3
- data/lib/active_merchant/lib/connection.rb +170 -0
- data/lib/active_merchant/lib/country.rb +4 -1
- data/lib/active_merchant/lib/posts_data.rb +22 -84
- data/test/fixtures.yml +39 -1
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +2 -1
- data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
- data/test/remote/gateways/remote_beanstream_interac_test.rb +1 -1
- data/test/remote/gateways/remote_beanstream_test.rb +1 -1
- data/test/remote/gateways/remote_braintree_test.rb +2 -9
- data/test/remote/gateways/remote_card_stream_test.rb +1 -1
- data/test/remote/gateways/remote_cyber_source_test.rb +1 -1
- data/test/remote/gateways/remote_data_cash_test.rb +1 -2
- data/test/remote/gateways/remote_efsnet_test.rb +1 -1
- data/test/remote/gateways/remote_elavon_test.rb +66 -0
- data/test/remote/gateways/remote_eway_test.rb +1 -1
- data/test/remote/gateways/remote_exact_test.rb +1 -1
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_jetpay_test.rb +103 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +11 -2
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +1 -1
- data/test/remote/gateways/remote_modern_payments_test.rb +23 -9
- data/test/remote/gateways/remote_moneris_test.rb +1 -1
- data/test/remote/gateways/remote_net_registry_test.rb +1 -1
- data/test/remote/gateways/remote_netbilling_test.rb +1 -1
- data/test/remote/gateways/remote_ogone_test.rb +115 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +1 -1
- data/test/remote/gateways/remote_pay_secure_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_express_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_uk_test.rb +1 -1
- data/test/remote/gateways/remote_payment_express_test.rb +17 -7
- data/test/remote/gateways/remote_paypal_express_test.rb +1 -1
- data/test/remote/gateways/remote_paypal_test.rb +26 -2
- data/test/remote/gateways/remote_plugnpay_test.rb +1 -1
- data/test/remote/gateways/remote_psigate_test.rb +1 -1
- data/test/remote/gateways/remote_psl_card_test.rb +1 -3
- data/test/remote/gateways/remote_quickpay_test.rb +1 -1
- data/test/remote/gateways/remote_realex_test.rb +1 -1
- data/test/remote/gateways/remote_sage_bankcard_test.rb +1 -1
- data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
- data/test/remote/gateways/remote_sage_test.rb +1 -1
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +1 -1
- data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +1 -1
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +1 -1
- data/test/remote/gateways/remote_secure_pay_test.rb +2 -2
- data/test/remote/gateways/remote_skipjack_test.rb +1 -1
- data/test/remote/gateways/remote_trans_first_test.rb +1 -1
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +1 -1
- data/test/remote/gateways/remote_usa_epay_test.rb +1 -1
- data/test/remote/gateways/remote_verifi_test.rb +1 -1
- data/test/remote/gateways/remote_viaklix_test.rb +1 -1
- data/test/remote/gateways/remote_wirecard_test.rb +34 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
- data/test/remote/integrations/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +81 -89
- data/test/unit/avs_result_test.rb +1 -1
- data/test/unit/base_test.rb +1 -2
- data/test/unit/check_test.rb +1 -1
- data/test/unit/connection_test.rb +129 -0
- 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 +10 -1
- data/test/unit/credit_card_test.rb +1 -1
- data/test/unit/cvv_result_test.rb +1 -1
- data/test/unit/expiry_date_test.rb +13 -2
- data/test/unit/gateways/authorize_net_cim_test.rb +39 -1
- data/test/unit/gateways/authorize_net_test.rb +1 -1
- data/test/unit/gateways/beanstream_interac_test.rb +1 -1
- data/test/unit/gateways/beanstream_test.rb +1 -1
- data/test/unit/gateways/bogus_test.rb +1 -1
- data/test/unit/gateways/braintree_test.rb +16 -14
- data/test/unit/gateways/card_stream_test.rb +1 -1
- data/test/unit/gateways/cyber_source_test.rb +1 -1
- data/test/unit/gateways/data_cash_test.rb +2 -1
- data/test/unit/gateways/efsnet_test.rb +1 -1
- data/test/unit/gateways/elavon_test.rb +139 -0
- data/test/unit/gateways/eway_test.rb +1 -1
- data/test/unit/gateways/exact_test.rb +1 -1
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +1 -1
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/jetpay_test.rb +185 -0
- data/test/unit/gateways/linkpoint_test.rb +37 -7
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +25 -34
- data/test/unit/gateways/moneris_test.rb +1 -1
- data/test/unit/gateways/net_registry_test.rb +1 -1
- data/test/unit/gateways/netbilling_test.rb +1 -1
- data/test/unit/gateways/ogone_test.rb +319 -0
- data/test/unit/gateways/pay_junction_test.rb +1 -1
- data/test/unit/gateways/pay_secure_test.rb +1 -1
- data/test/unit/gateways/payflow_express_test.rb +2 -2
- data/test/unit/gateways/payflow_express_uk_test.rb +73 -1
- data/test/unit/gateways/payflow_test.rb +1 -1
- data/test/unit/gateways/payflow_uk_test.rb +1 -1
- data/test/unit/gateways/payment_express_test.rb +3 -3
- data/test/unit/gateways/paypal_express_test.rb +1 -1
- data/test/unit/gateways/paypal_test.rb +50 -1
- data/test/unit/gateways/plugnpay_test.rb +1 -1
- data/test/unit/gateways/psigate_test.rb +1 -1
- data/test/unit/gateways/psl_card_test.rb +1 -1
- data/test/unit/gateways/quickpay_test.rb +1 -1
- data/test/unit/gateways/realex_test.rb +1 -1
- data/test/unit/gateways/sage_bankcard_test.rb +36 -2
- data/test/unit/gateways/{protx_test.rb → sage_pay_test.rb} +49 -32
- data/test/unit/gateways/sage_virtual_check_test.rb +1 -1
- data/test/unit/gateways/sallie_mae_test.rb +53 -0
- data/test/unit/gateways/secure_pay_au_test.rb +1 -1
- data/test/unit/gateways/secure_pay_tech_test.rb +1 -1
- data/test/unit/gateways/secure_pay_test.rb +24 -10
- data/test/unit/gateways/skip_jack_test.rb +81 -1
- data/test/unit/gateways/trans_first_test.rb +1 -1
- data/test/unit/gateways/trust_commerce_test.rb +1 -1
- data/test/unit/gateways/usa_epay_test.rb +1 -1
- data/test/unit/gateways/verifi_test.rb +1 -1
- data/test/unit/gateways/viaklix_test.rb +1 -1
- data/test/unit/gateways/wirecard_test.rb +19 -1
- data/test/unit/generators/test_generator_helper.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 +11 -2
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +1 -1
- 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 +1 -1
- data/test/unit/integrations/notifications/nochex_notification_test.rb +2 -2
- data/test/unit/integrations/notifications/notification_test.rb +1 -1
- 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 +1 -1
- 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/post_data_test.rb +1 -1
- data/test/unit/posts_data_test.rb +14 -66
- data/test/unit/response_test.rb +1 -1
- data/test/unit/utils_test.rb +1 -1
- data/test/unit/validateable_test.rb +1 -1
- metadata +41 -45
- metadata.gz.sig +0 -0
- data/test/extra/binding_of_caller.rb +0 -80
- data/test/extra/breakpoint.rb +0 -547
- data/test/remote/gateways/remote_protx_test.rb +0 -184
@@ -1,222 +1,17 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__),
|
2
|
-
|
1
|
+
require File.join(File.dirname(__FILE__),'smart_ps.rb')
|
3
2
|
module ActiveMerchant #:nodoc:
|
4
3
|
module Billing #:nodoc:
|
5
|
-
class BraintreeGateway <
|
6
|
-
|
4
|
+
class BraintreeGateway < SmartPs
|
5
|
+
def api_url
|
6
|
+
'https://secure.braintreepaymentgateway.com/api/transact.php'
|
7
|
+
end
|
7
8
|
|
8
9
|
self.supported_countries = ['US']
|
9
10
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
10
11
|
self.homepage_url = 'http://www.braintreepaymentsolutions.com'
|
11
12
|
self.display_name = 'Braintree'
|
12
|
-
|
13
|
-
def initialize(options = {})
|
14
|
-
requires!(options, :login, :password)
|
15
|
-
@options = options
|
16
|
-
super
|
17
|
-
end
|
18
|
-
|
19
|
-
# Pass :store => true in the options to store the
|
20
|
-
# payment info at BrainTree and get a generated
|
21
|
-
# customer_vault_id in the response.
|
22
|
-
# Pass :store => some_number_or_string to specify the
|
23
|
-
# customer_vault_id BrainTree should use (make sure it's
|
24
|
-
# unique).
|
25
|
-
def authorize(money, payment_source, options = {})
|
26
|
-
post = {}
|
27
|
-
add_invoice(post, options)
|
28
|
-
add_payment_source(post, payment_source, options)
|
29
|
-
add_address(post, payment_source, options)
|
30
|
-
add_customer_data(post, options)
|
31
|
-
|
32
|
-
commit('auth', money, post)
|
33
|
-
end
|
34
|
-
|
35
|
-
def purchase(money, payment_source, options = {})
|
36
|
-
post = {}
|
37
|
-
add_invoice(post, options)
|
38
|
-
add_payment_source(post, payment_source, options)
|
39
|
-
add_address(post, payment_source, options)
|
40
|
-
add_customer_data(post, options)
|
41
|
-
|
42
|
-
commit('sale', money, post)
|
43
|
-
end
|
44
|
-
|
45
|
-
def capture(money, authorization, options = {})
|
46
|
-
post ={}
|
47
|
-
post[:transactionid] = authorization
|
48
|
-
commit('capture', money, post)
|
49
|
-
end
|
50
|
-
|
51
|
-
def void(authorization, options = {})
|
52
|
-
post ={}
|
53
|
-
post[:transactionid] = authorization
|
54
|
-
commit('void', nil, post)
|
55
|
-
end
|
56
|
-
|
57
|
-
# Update the values (such as CC expiration) stored at
|
58
|
-
# BrainTree. The CC number must be supplied in the
|
59
|
-
# CreditCard object.
|
60
|
-
def update(vault_id, creditcard, options = {})
|
61
|
-
post = {}
|
62
|
-
post[:customer_vault] = "update_customer"
|
63
|
-
add_customer_vault_id(post, vault_id)
|
64
|
-
add_creditcard(post, creditcard, options)
|
65
|
-
add_address(post, creditcard, options)
|
66
|
-
add_customer_data(post, options)
|
67
|
-
|
68
|
-
commit(nil, nil, post)
|
69
|
-
end
|
70
|
-
|
71
|
-
def delete(vault_id)
|
72
|
-
post = {}
|
73
|
-
post[:customer_vault] = "delete_customer"
|
74
|
-
add_customer_vault_id(post, vault_id)
|
75
|
-
commit(nil, nil, post)
|
76
|
-
end
|
77
|
-
|
78
|
-
# To match the other stored-value gateways, like TrustCommerce,
|
79
|
-
# store and unstore need to be defined
|
80
|
-
def store(payment_source, options = {})
|
81
|
-
billing_id = options.delete(:billing_id).to_s || true
|
82
|
-
post = {}
|
83
|
-
post[:customer_vault] = 'add_customer'
|
84
|
-
if billing_id
|
85
|
-
post[:customer_vault_id] = billing_id
|
86
|
-
end
|
87
|
-
add_payment_source(post, payment_source, options)
|
88
|
-
add_address(post, payment_source, options)
|
89
|
-
add_customer_data(post, options)
|
90
|
-
commit(nil,nil, post)
|
91
|
-
end
|
92
|
-
|
93
|
-
alias_method :unstore, :delete
|
94
|
-
|
95
|
-
private
|
96
|
-
def add_customer_data(post, options)
|
97
|
-
if options.has_key? :email
|
98
|
-
post[:email] = options[:email]
|
99
|
-
end
|
100
|
-
|
101
|
-
if options.has_key? :ip
|
102
|
-
post[:ipaddress] = options[:ip]
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
def add_address(post, creditcard, options)
|
107
|
-
if address = options[:billing_address] || options[:address]
|
108
|
-
post[:address1] = address[:address1].to_s
|
109
|
-
post[:address2] = address[:address2].to_s unless address[:address2].blank?
|
110
|
-
post[:company] = address[:company].to_s
|
111
|
-
post[:phone] = address[:phone].to_s
|
112
|
-
post[:zip] = address[:zip].to_s
|
113
|
-
post[:city] = address[:city].to_s
|
114
|
-
post[:country] = address[:country].to_s
|
115
|
-
post[:state] = address[:state].blank? ? 'n/a' : address[:state]
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def add_invoice(post, options)
|
120
|
-
post[:orderid] = options[:order_id].to_s.gsub(/[^\w.]/, '')
|
121
|
-
end
|
122
|
-
|
123
|
-
def add_payment_source(params, source, options={})
|
124
|
-
case determine_funding_source(source)
|
125
|
-
when :vault then add_customer_vault_id(params, source)
|
126
|
-
when :credit_card then add_creditcard(params, source, options)
|
127
|
-
when :check then add_check(params, source)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def add_customer_vault_id(params,vault_id)
|
132
|
-
params[:customer_vault_id] = vault_id
|
133
|
-
end
|
134
|
-
|
135
|
-
def add_creditcard(post, creditcard,options)
|
136
|
-
if options[:store]
|
137
|
-
post[:customer_vault] = "add_customer"
|
138
|
-
post[:customer_vault_id] = options[:store] unless options[:store] == true
|
139
|
-
end
|
140
|
-
post[:ccnumber] = creditcard.number
|
141
|
-
post[:cvv] = creditcard.verification_value if creditcard.verification_value?
|
142
|
-
post[:ccexp] = expdate(creditcard)
|
143
|
-
post[:firstname] = creditcard.first_name
|
144
|
-
post[:lastname] = creditcard.last_name
|
145
|
-
end
|
146
|
-
|
147
|
-
def add_check(post, check)
|
148
|
-
post[:payment] = 'check' # Set transaction to ACH
|
149
|
-
post[:checkname] = check.name # The name on the customer's Checking Account
|
150
|
-
post[:checkaba] = check.routing_number # The customer's bank routing number
|
151
|
-
post[:checkaccount] = check.account_number # The customer's account number
|
152
|
-
post[:account_holder_type] = check.account_holder_type # The customer's type of ACH account
|
153
|
-
post[:account_type] = check.account_type # The customer's type of ACH account
|
154
|
-
end
|
155
|
-
|
156
|
-
def parse(body)
|
157
|
-
results = {}
|
158
|
-
body.split(/&/).each do |pair|
|
159
|
-
key,val = pair.split(/=/)
|
160
|
-
results[key] = val
|
161
|
-
end
|
162
|
-
|
163
|
-
results
|
164
|
-
end
|
165
|
-
|
166
|
-
def commit(action, money, parameters)
|
167
|
-
parameters[:amount] = amount(money) if money
|
168
|
-
|
169
|
-
response = parse( ssl_post(URL, post_data(action,parameters)) )
|
170
|
-
|
171
|
-
Response.new(response["response"] == "1", message_from(response), response,
|
172
|
-
:authorization => response["transactionid"],
|
173
|
-
:test => test?,
|
174
|
-
:cvv_result => response["cvvresponse"],
|
175
|
-
:avs_result => { :code => response["avsresponse"] }
|
176
|
-
)
|
177
|
-
|
178
|
-
end
|
179
|
-
|
180
|
-
def expdate(creditcard)
|
181
|
-
year = sprintf("%.4i", creditcard.year)
|
182
|
-
month = sprintf("%.2i", creditcard.month)
|
183
|
-
|
184
|
-
"#{month}#{year[-2..-1]}"
|
185
|
-
end
|
186
|
-
|
187
|
-
|
188
|
-
def message_from(response)
|
189
|
-
case response["responsetext"]
|
190
|
-
when "SUCCESS","Approved"
|
191
|
-
"This transaction has been approved"
|
192
|
-
when "DECLINE"
|
193
|
-
"This transaction has been declined"
|
194
|
-
else
|
195
|
-
response["responsetext"]
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def post_data(action, parameters = {})
|
200
|
-
post = {}
|
201
|
-
post[:username] = @options[:login]
|
202
|
-
post[:password] = @options[:password]
|
203
|
-
post[:type] = action if action
|
204
|
-
|
205
|
-
request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join("&")
|
206
|
-
request
|
207
|
-
end
|
208
|
-
|
209
|
-
def determine_funding_source(source)
|
210
|
-
case
|
211
|
-
when source.is_a?(String) then :vault
|
212
|
-
when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
|
213
|
-
when card_brand(source) == 'check' then :check
|
214
|
-
else raise ArgumentError, "Unsupported funding source provided"
|
215
|
-
end
|
216
|
-
end
|
13
|
+
self.default_currency = 'USD'
|
217
14
|
end
|
218
|
-
|
219
|
-
BrainTreeGateway = BraintreeGateway
|
220
15
|
end
|
221
16
|
end
|
222
17
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
# Authors:: MoneySpyder, http://moneyspyder.co.uk and E-consultancy, http://www.e-consultancy.com
|
2
|
-
|
3
1
|
module ActiveMerchant
|
4
2
|
module Billing
|
5
3
|
class DataCashGateway < Gateway
|
@@ -58,7 +56,7 @@ module ActiveMerchant
|
|
58
56
|
# Perform a purchase, which is essentially an authorization and capture in a single operation.
|
59
57
|
#
|
60
58
|
# ==== Parameters
|
61
|
-
# * <tt>money</tt> The amount to be authorized
|
59
|
+
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
|
62
60
|
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
63
61
|
# * <tt>options</tt> A hash of optional parameters.
|
64
62
|
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
@@ -86,7 +84,7 @@ module ActiveMerchant
|
|
86
84
|
#
|
87
85
|
# ==== Parameters
|
88
86
|
#
|
89
|
-
# * <tt>money</tt> The amount to be authorized
|
87
|
+
# * <tt>money</tt> The amount to be authorized as an Integer value in cents.
|
90
88
|
# * <tt>authorization_or_credit_card</tt>:: The continuous authority reference or CreditCard details for the transaction.
|
91
89
|
# * <tt>options</tt> A hash of optional parameters.
|
92
90
|
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
@@ -113,7 +111,7 @@ module ActiveMerchant
|
|
113
111
|
#
|
114
112
|
# ==== Parameters
|
115
113
|
#
|
116
|
-
# * <tt>money</tt> -- The amount to be captured
|
114
|
+
# * <tt>money</tt> -- The amount to be captured as anInteger value in cents.
|
117
115
|
# * <tt>authorization</tt> -- The authorization returned from the previous authorize request.
|
118
116
|
def capture(money, authorization, options = {})
|
119
117
|
commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
|
@@ -134,7 +132,7 @@ module ActiveMerchant
|
|
134
132
|
#
|
135
133
|
# ==== Parameters
|
136
134
|
#
|
137
|
-
# * <tt>money</tt> The amount to be refunded
|
135
|
+
# * <tt>money</tt> The amount to be refunded as an Integer value in cents. Set to nil for a full refund on existing transaction.
|
138
136
|
# * <tt>reference_or_credit_card</tt> The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding
|
139
137
|
# * <tt>options</tt> Are ignored when refunding via reference to an existing transaction, otherwise
|
140
138
|
# * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
|
@@ -177,7 +175,7 @@ module ActiveMerchant
|
|
177
175
|
#
|
178
176
|
# Parameters:
|
179
177
|
# * <tt>type</tt> must be FULFILL_TYPE or CANCEL_TYPE
|
180
|
-
# * <tt>money</tt> - optional -
|
178
|
+
# * <tt>money</tt> - optional - Integer value in cents
|
181
179
|
# * <tt>authorization</tt> - the Datacash authorization from a previous succesful authorize transaction
|
182
180
|
# * <tt>options</tt>
|
183
181
|
# * <tt>order_id</tt> - A unique reference for the transaction
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/viaklix'
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
module Billing #:nodoc:
|
5
|
+
# = Elavon Virtual Merchant Gateway
|
6
|
+
#
|
7
|
+
# == Example use:
|
8
|
+
#
|
9
|
+
# gateway = ActiveMerchant::Billing::ElavonGateway.new(
|
10
|
+
# :login => "my_virtual_merchant_id",
|
11
|
+
# :password => "my_virtual_merchant_pin",
|
12
|
+
# :user => "my_virtual_merchant_user_id" # optional
|
13
|
+
# )
|
14
|
+
#
|
15
|
+
# # set up credit card obj as in main ActiveMerchant example
|
16
|
+
# creditcard = ActiveMerchant::Billing::CreditCard.new(
|
17
|
+
# :type => 'visa',
|
18
|
+
# :number => '41111111111111111',
|
19
|
+
# :month => 10,
|
20
|
+
# :year => 2011,
|
21
|
+
# :first_name => 'Bob',
|
22
|
+
# :last_name => 'Bobsen'
|
23
|
+
# )
|
24
|
+
#
|
25
|
+
# # run request
|
26
|
+
# response = gateway.purchase(1000, creditcard) # authorize and capture 10 USD
|
27
|
+
#
|
28
|
+
# puts response.success? # Check whether the transaction was successful
|
29
|
+
# puts response.message # Retrieve the message returned by Elavon
|
30
|
+
# puts response.authorization # Retrieve the unique transaction ID returned by Elavon
|
31
|
+
#
|
32
|
+
class ElavonGateway < ViaklixGateway
|
33
|
+
self.test_url = self.live_url = 'https://www.myvirtualmerchant.com/VirtualMerchant/process.do'
|
34
|
+
|
35
|
+
self.display_name = 'Elavon MyVirtualMerchant'
|
36
|
+
self.supported_countries = ['US', 'CA']
|
37
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
38
|
+
self.homepage_url = 'http://www.elavon.com/'
|
39
|
+
|
40
|
+
self.delimiter = "\n"
|
41
|
+
self.actions = {
|
42
|
+
:purchase => 'CCSALE',
|
43
|
+
:credit => 'CCCREDIT',
|
44
|
+
:authorize => 'CCAUTHONLY',
|
45
|
+
:capture => 'CCFORCE'
|
46
|
+
}
|
47
|
+
|
48
|
+
# Authorize a credit card for a given amount.
|
49
|
+
#
|
50
|
+
# ==== Parameters
|
51
|
+
# * <tt>money</tt> - The amount to be authorized as an Integer value in cents.
|
52
|
+
# * <tt>credit_card</tt> - The CreditCard details for the transaction.
|
53
|
+
# * <tt>options</tt>
|
54
|
+
# * <tt>:billing_address</tt> - The billing address for the cardholder.
|
55
|
+
def authorize(money, creditcard, options = {})
|
56
|
+
form = {}
|
57
|
+
add_invoice(form, options)
|
58
|
+
add_creditcard(form, creditcard)
|
59
|
+
add_address(form, options)
|
60
|
+
add_customer_data(form, options)
|
61
|
+
commit(:authorize, money, form)
|
62
|
+
end
|
63
|
+
|
64
|
+
# Capture authorized funds from a credit card.
|
65
|
+
#
|
66
|
+
# ==== Parameters
|
67
|
+
# * <tt>money</tt> - The amount to be captured as an Integer value in cents.
|
68
|
+
# * <tt>authorization</tt> - The approval code returned from the initial authorization.
|
69
|
+
# * <tt>options</tt>
|
70
|
+
# * <tt>:credit_card</tt> - The CreditCard details from the initial transaction (required).
|
71
|
+
def capture(money, authorization, options = {})
|
72
|
+
requires!(options, :credit_card)
|
73
|
+
|
74
|
+
form = {}
|
75
|
+
add_reference(form, authorization)
|
76
|
+
add_invoice(form, options)
|
77
|
+
add_creditcard(form, options[:credit_card])
|
78
|
+
add_customer_data(form, options)
|
79
|
+
commit(:capture, money, form)
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def add_reference(form, authorization)
|
84
|
+
form[:approval_code] = authorization
|
85
|
+
end
|
86
|
+
|
87
|
+
def authorization_from(response)
|
88
|
+
response['approval_code']
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_verification_value(form, creditcard)
|
92
|
+
form[:cvv2cvc2] = creditcard.verification_value
|
93
|
+
form[:cvv2cvc2_indicator] = '1'
|
94
|
+
end
|
95
|
+
|
96
|
+
def add_address(form,options)
|
97
|
+
billing_address = options[:billing_address] || options[:address]
|
98
|
+
|
99
|
+
if billing_address
|
100
|
+
form[:avs_address] = billing_address[:address1].to_s.slice(0, 30)
|
101
|
+
form[:address2] = billing_address[:address2].to_s.slice(0, 30)
|
102
|
+
form[:avs_zip] = billing_address[:zip].to_s.slice(0, 10)
|
103
|
+
form[:city] = billing_address[:city].to_s.slice(0, 30)
|
104
|
+
form[:state] = billing_address[:state].to_s.slice(0, 10)
|
105
|
+
form[:company] = billing_address[:company].to_s.slice(0, 50)
|
106
|
+
form[:phone] = billing_address[:phone].to_s.slice(0, 20)
|
107
|
+
form[:country] = billing_address[:country].to_s.slice(0, 50)
|
108
|
+
end
|
109
|
+
|
110
|
+
if shipping_address = options[:shipping_address]
|
111
|
+
first_name, last_name = parse_first_and_last_name(shipping_address[:name])
|
112
|
+
form[:ship_to_first_name] = first_name.to_s.slice(0, 20)
|
113
|
+
form[:ship_to_last_name] = last_name.to_s.slice(0, 30)
|
114
|
+
form[:ship_to_address1] = shipping_address[:address1].to_s.slice(0, 30)
|
115
|
+
form[:ship_to_address2] = shipping_address[:address2].to_s.slice(0, 30)
|
116
|
+
form[:ship_to_city] = shipping_address[:city].to_s.slice(0, 30)
|
117
|
+
form[:ship_to_state] = shipping_address[:state].to_s.slice(0, 10)
|
118
|
+
form[:ship_to_company] = shipping_address[:company].to_s.slice(0, 50)
|
119
|
+
form[:ship_to_country] = shipping_address[:country].to_s.slice(0, 50)
|
120
|
+
form[:ship_to_zip] = shipping_address[:zip].to_s.slice(0, 10)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def message_from(response)
|
125
|
+
success?(response) ? response['result_message'] : response['errorMessage']
|
126
|
+
end
|
127
|
+
|
128
|
+
def success?(response)
|
129
|
+
!response.has_key?('errorMessage')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
@@ -131,7 +131,7 @@ module ActiveMerchant #:nodoc:
|
|
131
131
|
|
132
132
|
self.money_format = :cents
|
133
133
|
self.supported_countries = ['AU']
|
134
|
-
self.supported_cardtypes = [:visa, :master]
|
134
|
+
self.supported_cardtypes = [:visa, :master, :american_express]
|
135
135
|
self.homepage_url = 'http://www.eway.com.au/'
|
136
136
|
self.display_name = 'eWAY'
|
137
137
|
|
@@ -155,7 +155,11 @@ module ActiveMerchant #:nodoc:
|
|
155
155
|
|
156
156
|
commit(money, post)
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
|
+
def test?
|
160
|
+
@options[:test] || super
|
161
|
+
end
|
162
|
+
|
159
163
|
private
|
160
164
|
def add_creditcard(post, creditcard)
|
161
165
|
post[:CardNumber] = creditcard.number
|
@@ -267,6 +271,7 @@ module ActiveMerchant #:nodoc:
|
|
267
271
|
test ? TEST_URL : LIVE_URL
|
268
272
|
end
|
269
273
|
end
|
274
|
+
|
270
275
|
end
|
271
276
|
end
|
272
277
|
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class FirstPayGateway < Gateway
|
4
|
+
class FirstPayPostData < PostData
|
5
|
+
# Fields that will be sent even if they are blank
|
6
|
+
self.required_fields = [ :action, :amount, :trackid ]
|
7
|
+
end
|
8
|
+
|
9
|
+
# both URLs are IP restricted
|
10
|
+
TEST_URL = 'https://apgcert.first-pay.com/AcqENGIN/SecureCapture'
|
11
|
+
LIVE_URL = 'https://acqengin.first-pay.com/AcqENGIN/SecureCapture'
|
12
|
+
|
13
|
+
# The countries the gateway supports merchants from as 2 digit ISO country codes
|
14
|
+
self.supported_countries = ['US']
|
15
|
+
|
16
|
+
# The card types supported by the payment gateway
|
17
|
+
self.supported_cardtypes = [:visa, :master]
|
18
|
+
|
19
|
+
# The homepage URL of the gateway
|
20
|
+
self.homepage_url = 'http://www.first-pay.com'
|
21
|
+
|
22
|
+
# The name of the gateway
|
23
|
+
self.display_name = 'First Pay'
|
24
|
+
|
25
|
+
# all transactions are in cents
|
26
|
+
self.money_format = :cents
|
27
|
+
|
28
|
+
ACTIONS = {
|
29
|
+
'sale' => 1,
|
30
|
+
'credit' => 2,
|
31
|
+
'void' => 3
|
32
|
+
}
|
33
|
+
|
34
|
+
def initialize(options = {})
|
35
|
+
requires!(options, :login, :password)
|
36
|
+
@options = options
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def purchase(money, creditcard, options = {})
|
41
|
+
post = FirstPayPostData.new
|
42
|
+
add_invoice(post, options)
|
43
|
+
add_creditcard(post, creditcard)
|
44
|
+
add_address(post, options)
|
45
|
+
add_customer_data(post, options)
|
46
|
+
|
47
|
+
commit('sale', money, post)
|
48
|
+
end
|
49
|
+
|
50
|
+
def credit(money, reference, options = {})
|
51
|
+
raise ArgumentError, "Both TransactionID and CreditCard are required" unless reference.is_a?(String) && options[:credit_card]
|
52
|
+
|
53
|
+
post = FirstPayPostData.new
|
54
|
+
add_invoice(post, options)
|
55
|
+
add_creditcard(post, options[:credit_card])
|
56
|
+
add_address(post, options)
|
57
|
+
add_customer_data(post, options)
|
58
|
+
add_credit_data(post, reference)
|
59
|
+
|
60
|
+
commit('credit', money, post)
|
61
|
+
end
|
62
|
+
|
63
|
+
def void(money, creditcard, options = {})
|
64
|
+
post = FirstPayPostData.new
|
65
|
+
add_creditcard(post, creditcard)
|
66
|
+
add_void_data(post, options)
|
67
|
+
add_invoice(post, options)
|
68
|
+
add_customer_data(post, options)
|
69
|
+
|
70
|
+
commit('void', money, post)
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def add_customer_data(post, options)
|
77
|
+
post[:cardip] = options[:ip]
|
78
|
+
post[:email] = options[:email]
|
79
|
+
end
|
80
|
+
|
81
|
+
def add_address(post, options)
|
82
|
+
if billing_address = options[:billing_address] || options[:address]
|
83
|
+
post[:addr] = billing_address[:address1].to_s + ' ' + billing_address[:address2].to_s
|
84
|
+
post[:city] = billing_address[:city]
|
85
|
+
post[:state] = billing_address[:state]
|
86
|
+
post[:zip] = billing_address[:zip]
|
87
|
+
post[:country] = billing_address[:country]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def add_invoice(post, options)
|
92
|
+
post[:trackid] = rand(Time.now)
|
93
|
+
end
|
94
|
+
|
95
|
+
def add_creditcard(post, creditcard)
|
96
|
+
post[:member] = creditcard.first_name.to_s + " " + creditcard.last_name.to_s
|
97
|
+
post[:card] = creditcard.number
|
98
|
+
post[:exp] = expdate(creditcard)
|
99
|
+
end
|
100
|
+
|
101
|
+
def expdate(credit_card)
|
102
|
+
year = sprintf("%.4i", credit_card.year)
|
103
|
+
month = sprintf("%.2i", credit_card.month)
|
104
|
+
|
105
|
+
"#{month}#{year[-2..-1]}"
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_credit_data(post, transaction_id)
|
109
|
+
post[:transid] = transaction_id
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_void_data(post, options)
|
113
|
+
post[:transid] = options[:transactionid]
|
114
|
+
end
|
115
|
+
|
116
|
+
def commit(action, money, post)
|
117
|
+
response = parse( ssl_post(test? ? TEST_URL : LIVE_URL, post_data(action, post, money)) )
|
118
|
+
|
119
|
+
Response.new(response[:response] == 'CAPTURED', response[:message], response,
|
120
|
+
:test => test?,
|
121
|
+
:authorization => response[:authorization],
|
122
|
+
:avs_result => { :code => response[:avsresponse] },
|
123
|
+
:cvv_result => response[:cvvresponse])
|
124
|
+
end
|
125
|
+
|
126
|
+
def parse(body)
|
127
|
+
response = {}
|
128
|
+
|
129
|
+
# check for an error first
|
130
|
+
if body.include?('!ERROR!')
|
131
|
+
response[:response] = 'ERROR'
|
132
|
+
response[:message] = error_message_from(body)
|
133
|
+
else
|
134
|
+
# a capture / not captured response will be : delimited
|
135
|
+
split = body.split(':')
|
136
|
+
response[:response] = split[0]
|
137
|
+
|
138
|
+
# FirstPay docs are worthless. turns out the transactionid is required for credits
|
139
|
+
# so we need to store that in authorization, not the actual auth.
|
140
|
+
if response[:response] == 'CAPTURED'
|
141
|
+
response[:message] = 'CAPTURED'
|
142
|
+
response[:authorization] = split[9] # actually the transactionid
|
143
|
+
response[:auth] = split[1]
|
144
|
+
response[:avsresponse] = split[3]
|
145
|
+
response[:cvvresponse] = split[17]
|
146
|
+
else
|
147
|
+
# NOT CAPTURED response
|
148
|
+
response[:message] = split[1]
|
149
|
+
response[:transactionid] = split[9]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
return response
|
154
|
+
end
|
155
|
+
|
156
|
+
def error_message_from(response)
|
157
|
+
# error messages use this format - '!ERROR! 704-MISSING BASIC DATA TYPE:card, exp, zip, addr, member, amount\n'
|
158
|
+
response.split("! ")[1].chomp
|
159
|
+
end
|
160
|
+
|
161
|
+
def post_data(action, post, money)
|
162
|
+
post[:vid] = @options[:login]
|
163
|
+
post[:password] = @options[:password]
|
164
|
+
post[:action] = ACTIONS[action]
|
165
|
+
post[:amount] = amount(money)
|
166
|
+
|
167
|
+
return post.to_post_data
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|